Skip to content

Commit 7f125ff

Browse files
pcloudsgitster
authored andcommitted
diff-parseopt: correct variable types that are used by parseopt
Most number-related OPT_ macros store the value in an 'int' variable. Many of the variables in 'struct diff_options' have a different type, but during the conversion to using parse_options() I failed to notice and correct. The problem was reported on s360x which is a big-endian architechture. The variable to store '-w' option in this case is xdl_opts, 'long' type, 8 bytes. But since parse_options() assumes 'int' (4 bytes), it will store bits in the wrong part of xdl_opts. The problem was found on little-endian platforms because parse_options() will accidentally store at the right part of xdl_opts. There aren't much to say about the type change (except that 'int' for xdl_opts should still be big enough, since Windows' long is the same size as 'int' and nobody has complained so far). Some safety checks may be implemented in the future to prevent class of bugs. Reported-by: Todd Zullinger <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed88148 commit 7f125ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct diff_options {
169169
const char *prefix;
170170
int prefix_length;
171171
const char *stat_sep;
172-
long xdl_opts;
172+
int xdl_opts;
173173

174174
/* see Documentation/diff-options.txt */
175175
char **anchors;

0 commit comments

Comments
 (0)