Commit Graph

1462 Commits (3e3ef8901c1c9b938b469ee59d324bcd7147c8d0)

Author SHA1 Message Date
Erik Larsson 3e3ef8901c Fixes for making strict endians branch compile after merge. 2016-02-05 18:04:22 +01:00
Erik Larsson 34bb449324 Merge branch 'edge' into edge.strict_endians
Conflicts:
	libntfs-3g/dir.c
	libntfs-3g/index.c
	libntfs-3g/runlist.c
	ntfsprogs/ntfsfix.c
	ntfsprogs/ntfsinfo.c
2016-02-05 18:02:02 +01:00
Erik Larsson a2efc3ec9f Change type of all LSN struct members in ntfsrecover.h to leLSN.
This is done to match the type of the LSN struct members in layout.h.
The effect of this change is that while these members were declared with
the le64 type previously, leLSN resolves to sle64. I.e. what was
previously unsigned fields are now signed.

Following this change we also need to switch over a few macros from
unsigned to signed versions in the code that uses these struct
definitions.
2016-01-29 12:36:06 +01:00
Erik Larsson ee4c48f4b1 playlog.c: Use const macro for byteswapping const expression. 2016-01-29 10:49:52 +01:00
Erik Larsson 81fce3b70e playlog.c: Fix improper byteswapping macros used for sle64 members. 2016-01-29 10:49:25 +01:00
Erik Larsson 9893ea9ee6 Merge endianness fixes.
Conflicts:
	libntfs-3g/attrib.c
2016-01-28 09:22:42 +01:00
Erik Larsson 760ddd62cf Merge endianness fixes required for the strict endians code to compile.
Conflicts:
	libntfs-3g/attrib.c
	libntfs-3g/dir.c
	libntfs-3g/logfile.c
	libntfs-3g/volume.c
	ntfsprogs/ntfscp.c
	ntfsprogs/ntfsdump_logfile.c
	ntfsprogs/ntfsfallocate.c
	ntfsprogs/ntfsfix.c
	ntfsprogs/ntfsinfo.c
	ntfsprogs/ntfsresize.c
	ntfsprogs/ntfstruncate.c
2016-01-28 09:21:09 +01:00
Erik Larsson e37258bf01 ntfscmp.c: Fix missing byteswap of little-endian attribute type value. 2016-01-28 09:11:55 +01:00
Erik Larsson 1984a714e5 Enable strict checking of endian-specific types.
Strict checking of endian-specific types mean that types that have a
fixed endianness in the data representation of the value are now defined
as complex types, enabling the compiler to catch mixed usage of these
types with native-endian types. This allows us to catch most issues
relating to usage on big-endian systems since we cannot anymore assign a
fixed-endian value to a native-endian variable and vice-versa without a
compiler error.

The downside is that we aren't able to apply simple binary operators to
the fixed-endian types anymore since they are complex... so all
combining fixed-endian constants and values with |, &, etc. and
comparison with ==, !=, <=, etc. must be replaced with a macro which
unpacks the wrapped value and performs the operation. Lots of changes,
lots of work but in the interest of good code quality it's justified.
2016-01-28 08:29:03 +01:00
Erik Larsson 7e85b4ccd4 Replace switch statements for le/be types with equivalent if statements.
Since the le/be-types are now typedef'd to aggregate types, we can't use
those in switch statements.
2016-01-28 08:29:02 +01:00
Erik Larsson 1fdd4fbb71 Replace all le64 "not" negations with le64_not(...). 2016-01-28 08:29:01 +01:00
Erik Larsson 597adff2bb Replace all le32 "not" negations with le32_not(...). 2016-01-28 08:29:00 +01:00
Erik Larsson 85588b8e92 Replace all le16 "not" negations with le16_not(...). 2016-01-28 08:28:59 +01:00
Erik Larsson 46dfbe17ec Replace all le64 "xor" calculations with le64_xor(...). 2016-01-28 08:28:58 +01:00
Erik Larsson cc414d9e8b Replace all le64 "or" calculations with le64_or(...). 2016-01-28 08:28:55 +01:00
Erik Larsson 1500a77676 Replace all le32 "or" calculations with le32_or(...). 2016-01-28 08:28:54 +01:00
Erik Larsson b61e7ff449 Replace all le16 "or" calculations with le16_or(...). 2016-01-28 08:28:53 +01:00
Erik Larsson 66d7b85573 Replace all le64 "and" calculations with le64_and(...). 2016-01-28 08:28:52 +01:00
Erik Larsson 7b3700ed5e Replace all le32 "and" calculations with le32_and(...). 2016-01-28 08:28:51 +01:00
Erik Larsson 2b4c3a618c Replace all le16 "and" calculations with le16_and(...). 2016-01-28 08:28:50 +01:00
Erik Larsson e970b57c74 Replace all le32 zero "and" test conditions with le32_andz(...). 2016-01-28 08:28:49 +01:00
Erik Larsson 9f5ad52e5f Replace all le32 non-zero "and" test conditions with !le32_andz(...). 2016-01-28 08:28:48 +01:00
Erik Larsson 1b7bfaa133 Replace all le16 zero "and" test conditions with le16_andz(...). 2016-01-28 08:28:47 +01:00
Erik Larsson 35c72761c7 Replace all le16 non-zero "and" test conditions with !le16_andz(...). 2016-01-28 08:28:46 +01:00
Erik Larsson 5097bb9ea3 Replace all sle64 zero test conditions with "sle64_cmpz(...)". 2016-01-28 08:28:44 +01:00
Erik Larsson 65eea3fe0a Replace all le64 zero test conditions with "le64_cmpz(...)". 2016-01-28 08:28:42 +01:00
Erik Larsson 17a2c5f58e Replace all le64 non-zero test conditions with "!le64_cmpz(...)". 2016-01-28 08:28:41 +01:00
Erik Larsson ed87a4dffa Replace all le32 zero test conditions with "le32_cmpz(...)". 2016-01-28 08:28:40 +01:00
Erik Larsson 18990412fa Replace all le32 non-zero test conditions with "!le32_cmpz(...)". 2016-01-28 08:28:39 +01:00
Erik Larsson e366bef954 Replace all le16 zero test conditions with "le16_cmpz(...)". 2016-01-28 08:28:38 +01:00
Erik Larsson 90697bb5ab Replace all le16 non-zero test conditions with "!le16_cmpz(...)". 2016-01-28 08:28:37 +01:00
Erik Larsson 0657987a0b Replace all sle64 usage of the '!=' operation with "!sle64_eq(...)". 2016-01-28 08:28:34 +01:00
Erik Larsson 7b85755080 Replace all sle64 usage of the '==' operation with "sle64_eq(...)". 2016-01-28 08:28:33 +01:00
Erik Larsson e1bd02ed74 Replace all sle16 usage of the '!=' operation with "!sle16_eq(...)". 2016-01-28 08:28:32 +01:00
Erik Larsson d61f8615d9 Replace all le64 usage of the '!=' operation with "!le64_eq(...)". 2016-01-28 08:28:30 +01:00
Erik Larsson 0876896169 Replace all le32 usage of the '!=' operation with "!le32_eq(...)". 2016-01-28 08:28:27 +01:00
Erik Larsson 011a9e9e5e Replace all le32 usage of the '==' operation with "le32_eq(...)". 2016-01-28 08:28:26 +01:00
Erik Larsson 8aca3d4800 ntfsmove.c: Fix multiple cases of raw usage of little-endian fields.
There were multiple cases of little-endian fields being used as
CPU-endian without byte swapping. This would result in incorrect
behaviour on big-endian systems.
2016-01-27 15:28:55 +01:00
Erik Larsson 8daa92717e ntfsdump_logfile.c: Fix use of wrong byteswapping macro for le16 field. 2016-01-27 15:26:51 +01:00
Erik Larsson 0741f54b2e ntfsdump_logfile.c: Fix incorrectly parenthesized expression.
On big-endian systems the result of the '!=' operation would be
endian-swapped rather than the first argument (which must have been the
intended action).
2016-01-27 15:24:52 +01:00
Erik Larsson 55dafda732 ntfsck.c: Fix comparing le32 values as u32.
This is harmless except when we do strict endianness checking, in which
case this results in a compile error. Fixed by converting values to
CPU endianness before comparing them.
2016-01-27 15:23:13 +01:00
Erik Larsson ec18534f31 ntfsck.c: Fix comparison between little-endian and native-endian data.
This comparison would yield the wrong result on big-endian systems.
2016-01-27 15:21:05 +01:00
Erik Larsson ef09702b0c ntfstruncate.c: Fix mixed endianness usage of variable 'i'.
In 'dump_resident_attr_val', 'i' was sometimes used as a native-endian
'int'-precision string length value and sometimes used as a little-
endian 16-bit flags value. This type of mixed usage is bad practice and
results in a hard error when strict endianness checking is used.

Fixed by introducing new variable 'flags' to hold the little-endian 16-
bit flags value.
2016-01-26 10:28:38 +01:00
Erik Larsson 7e9003b147 ntfstruncate.c: Fix incorrect type for CPU-endian value in 'ucstos'. 2016-01-26 10:19:44 +01:00
Erik Larsson 1b67b943df ntfstruncate.c: Fix conflicting endianness for variable 'attr_type'.
If the attribute type is specified by the user, 'attr_type' was assigned
a CPU-endian value, however if the attribute type was not specified it
would be assigned the attribute type AT_DATA, which is a little-endian
value. The rest of the code seems to assume that 'attr_type' is
CPU-endian, so this is clearly a bug.

Resolved by fixing the endianness of the variable at little-endian,
converting the input value to little-endian when specified.
2016-01-26 10:18:51 +01:00
Erik Larsson efa876d31b ntfstruncate.c: Fix mixed endianness usage of variable 'u'.
In 'dump_attr_record' the variable 'u' was first used to store a
CPU-endian 32-bit value, and then to store a 16-bit little-endian value.
This is bad practice and results in a hard error when strict endian type
checking is used.

Fixed by storing the 16-bit little-endian flags value in a new variable
'flags'.
2016-01-26 10:03:36 +01:00
Erik Larsson 75da0ce302 Fix inverted usage of endian conversion macros.
This is mostly a semantic issue since the end result would be the same.
2016-01-04 10:08:15 +01:00
Erik Larsson 9cf04fd2cd Fix incorrect usage of native/little-endian types, signed types, etc.
This is harmless with regard to code generation but if we turn on strict
type checking these type mismatches will result in errors.
2015-12-21 23:55:31 +01:00
Erik Larsson f076fae75a Fix endianness issues in log and terminal output.
This commit addresses issues where little-endian variables are emitted
raw to a log or output stream which is to be interpreted by the user.

Outputting data in non-native endianness can cause confusion for anybody
attempting to debug issues with a file system.
2015-12-21 23:31:09 +01:00
Erik Larsson dfa4a6647f Fix code to use const_cpu_to_X/const_X_to_cpu macros for constants.
This enables the compiler to optimize this code in cases where compiler
support for endianness swapping is not present.
2015-12-21 23:21:00 +01:00