diff mbox series

fanotify: remove always false comparison in copy_fid_to_user

Message ID 1567475654-6133-1-git-send-email-zhengbin13@huawei.com (mailing list archive)
State New, archived
Headers show
Series fanotify: remove always false comparison in copy_fid_to_user | expand

Commit Message

Zheng Bin Sept. 3, 2019, 1:54 a.m. UTC
Fixes gcc warning:

fs/notify/fanotify/fanotify_user.c:252:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/notify/fanotify/fanotify_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.7.4

Comments

Matthew Wilcox (Oracle) Sept. 3, 2019, 11:28 a.m. UTC | #1
On Tue, Sep 03, 2019 at 09:54:14AM +0800, zhengbin wrote:
> Fixes gcc warning:
> 
> fs/notify/fanotify/fanotify_user.c:252:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>

When fixing bugs like this, please do a git log -p and cc the person
responsible for introducing the code you're fixing.  Also add a Fixes:
line.

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Jan Kara Sept. 3, 2019, 11:40 a.m. UTC | #2
On Tue 03-09-19 09:54:14, zhengbin wrote:
> Fixes gcc warning:
> 
> fs/notify/fanotify/fanotify_user.c:252:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>

Thanks for the patch! I've added it to my tree.

								Honza

> ---
>  fs/notify/fanotify/fanotify_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 8508ab5..e15547d 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -249,7 +249,7 @@ static int copy_fid_to_user(struct fanotify_event *event, char __user *buf)
>  	/* Pad with 0's */
>  	buf += fh_len;
>  	len -= fh_len;
> -	WARN_ON_ONCE(len < 0 || len >= FANOTIFY_EVENT_ALIGN);
> +	WARN_ON_ONCE(len >= FANOTIFY_EVENT_ALIGN);
>  	if (len > 0 && clear_user(buf, len))
>  		return -EFAULT;
> 
> --
> 2.7.4
>
Jan Kara Sept. 3, 2019, 8:10 p.m. UTC | #3
On Tue 03-09-19 04:28:21, Matthew Wilcox wrote:
> On Tue, Sep 03, 2019 at 09:54:14AM +0800, zhengbin wrote:
> > Fixes gcc warning:
> > 
> > fs/notify/fanotify/fanotify_user.c:252:19: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
> > 
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: zhengbin <zhengbin13@huawei.com>
> 
> When fixing bugs like this, please do a git log -p and cc the person
> responsible for introducing the code you're fixing.  Also add a Fixes:
> line.

Generally I agree although in this particular case it is just a cosmetic
fix so I don't find that very important. 

> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Thanks for review!

								Honza
diff mbox series

Patch

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 8508ab5..e15547d 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -249,7 +249,7 @@  static int copy_fid_to_user(struct fanotify_event *event, char __user *buf)
 	/* Pad with 0's */
 	buf += fh_len;
 	len -= fh_len;
-	WARN_ON_ONCE(len < 0 || len >= FANOTIFY_EVENT_ALIGN);
+	WARN_ON_ONCE(len >= FANOTIFY_EVENT_ALIGN);
 	if (len > 0 && clear_user(buf, len))
 		return -EFAULT;