X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Flzms-common.c;h=95682d53a56490fd382d57b7d779b001e78782b7;hb=1c1c12926f4de39cb35d8d4c5a5280ab0d6ba931;hp=4363623a4b1fba1e7267d6881f4e8f97501d28be;hpb=93110bb18090d4d2c00294a56f819c7edeef318f;p=wimlib diff --git a/src/lzms-common.c b/src/lzms-common.c index 4363623a..95682d53 100644 --- a/src/lzms-common.c +++ b/src/lzms-common.c @@ -8,20 +8,18 @@ /* * Copyright (C) 2013, 2014 Eric Biggers * - * This file is part of wimlib, a library for working with WIM files. + * This file is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your option) any + * later version. * - * wimlib is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * - * You should have received a copy of the GNU General Public License - * along with wimlib; if not, see http://www.gnu.org/licenses/. + * You should have received a copy of the GNU Lesser General Public License + * along with this file; if not, see http://www.gnu.org/licenses/. */ #ifdef HAVE_CONFIG_H @@ -30,6 +28,7 @@ #include "wimlib/endianness.h" #include "wimlib/lzms.h" +#include "wimlib/unaligned.h" #include "wimlib/util.h" #include @@ -159,20 +158,20 @@ lzms_maybe_do_x86_translation(u8 data[restrict], s32 i, s32 num_op_bytes, if (i - *closest_target_usage_p <= max_trans_offset) { LZMS_DEBUG("Undid x86 translation at position %d " "(opcode 0x%02x)", i, data[i]); - le32 *p32 = (le32*)&data[i + num_op_bytes]; - u32 n = le32_to_cpu(*p32); - *p32 = cpu_to_le32(n - i); + void *p32 = &data[i + num_op_bytes]; + u32 n = le32_to_cpu(load_le32_unaligned(p32)); + store_le32_unaligned(cpu_to_le32(n - i), p32); } - pos = i + le16_to_cpu(*(const le16*)&data[i + num_op_bytes]); + pos = i + le16_to_cpu(load_le16_unaligned(&data[i + num_op_bytes])); } else { - pos = i + le16_to_cpu(*(const le16*)&data[i + num_op_bytes]); + pos = i + le16_to_cpu(load_le16_unaligned(&data[i + num_op_bytes])); if (i - *closest_target_usage_p <= max_trans_offset) { LZMS_DEBUG("Did x86 translation at position %d " "(opcode 0x%02x)", i, data[i]); - le32 *p32 = (le32*)&data[i + num_op_bytes]; - u32 n = le32_to_cpu(*p32); - *p32 = cpu_to_le32(n + i); + void *p32 = &data[i + num_op_bytes]; + u32 n = le32_to_cpu(load_le32_unaligned(p32)); + store_le32_unaligned(cpu_to_le32(n + i), p32); } }