aboutsummaryrefslogtreecommitdiff
path: root/lib/memory-notifier-error-inject.c
diff options
context:
space:
mode:
authorRasmus Villemoes <[email protected]>2014-12-05 16:40:07 +0100
committerJ. Bruce Fields <[email protected]>2014-12-09 11:29:14 -0500
commitef17af2a817db97d42dd2ec0a425231748e23dbc (patch)
treedf3e419603dbd79e454915e0bad53f048abca527 /lib/memory-notifier-error-inject.c
parent83a712e0afefaf68555f816ea78ecd2862c6cf30 (diff)
fs: nfsd: Fix signedness bug in compare_blob
Bugs similar to the one in acbbe6fbb240 (kcmp: fix standard comparison bug) are in rich supply. In this variant, the problem is that struct xdr_netobj::len has type unsigned int, so the expression o1->len - o2->len _also_ has type unsigned int; it has completely well-defined semantics, and the result is some non-negative integer, which is always representable in a long long. But this means that if the conditional triggers, we are guaranteed to return a positive value from compare_blob. In this case it could be fixed by - res = o1->len - o2->len; + res = (long long)o1->len - (long long)o2->len; but I'd rather eliminate the usually broken 'return a - b;' idiom. Reviewed-by: Jeff Layton <[email protected]> Cc: <[email protected]> Signed-off-by: Rasmus Villemoes <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
Diffstat (limited to 'lib/memory-notifier-error-inject.c')
0 files changed, 0 insertions, 0 deletions