Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "fanotify: remove unneeded sub-zero check for unsigned value"

This reverts commit e6595224464b692ddae193d783402130d1625147.

These kinds of patches are only making the code worse.

Compilers don't care about the unnecessary check, but removing it makes
the code less obvious to a human. The declaration of 'len' is more than
80 lines earlier, so a human won't easily see that 'len' is of an
unsigned type, so to a human the range check that checks against zero is
much more explicit and obvious.

Any tool that complains about a range check like this just because the
variable is unsigned is actively detrimental, and should be ignored.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+1 -1
+1 -1
fs/notify/fanotify/fanotify_user.c
··· 502 502 } 503 503 504 504 /* Pad with 0's */ 505 - WARN_ON_ONCE(len >= FANOTIFY_EVENT_ALIGN); 505 + WARN_ON_ONCE(len < 0 || len >= FANOTIFY_EVENT_ALIGN); 506 506 if (len > 0 && clear_user(buf, len)) 507 507 return -EFAULT; 508 508