* [PATCH] fs/compat: remove redundant 'less than zero' check
@ 2015-04-24 10:07 Firo Yang
2015-04-24 10:10 ` Julia Lawall
2015-04-24 12:04 ` Dan Carpenter
0 siblings, 2 replies; 6+ messages in thread
From: Firo Yang @ 2015-04-24 10:07 UTC (permalink / raw)
To: viro; +Cc: kernel-janitors, linux-fsdevel, Firo Yang
Smatch complains about the check in compat.c.
fs/compat.c:565 compat_rw_copy_check_uvector() warn:
unsigned 'nr_segs' is never less than zero.
I think, there is no reason to check if the value nr_segs
is less than zero. So I removed it.
Signed-off-by: Firo Yang <firogm@gmail.com>
---
fs/compat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/compat.c b/fs/compat.c
index 6fd272d..beaf15b 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
goto out;
ret = -EINVAL;
- if (nr_segs > UIO_MAXIOV || nr_segs < 0)
+ if (nr_segs > UIO_MAXIOV)
goto out;
if (nr_segs > fast_segs) {
ret = -ENOMEM;
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] fs/compat: remove redundant 'less than zero' check
2015-04-24 10:07 [PATCH] fs/compat: remove redundant 'less than zero' check Firo Yang
@ 2015-04-24 10:10 ` Julia Lawall
[not found] ` <CAOXNuu2VKCWNSiePoSw4-G3TqxpXDE9fR75B75-fhQLa-SPcJg@mail.gmail.com>
2015-04-24 12:04 ` Dan Carpenter
1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-04-24 10:10 UTC (permalink / raw)
To: Firo Yang; +Cc: viro, kernel-janitors, linux-fsdevel
On Fri, 24 Apr 2015, Firo Yang wrote:
> Smatch complains about the check in compat.c.
> fs/compat.c:565 compat_rw_copy_check_uvector() warn:
> unsigned 'nr_segs' is never less than zero.
>
> I think, there is no reason to check if the value nr_segs
> is less than zero. So I removed it.
It would be good to explain why you think this. What other statements in
the code imply this property?
julia
>
> Signed-off-by: Firo Yang <firogm@gmail.com>
> ---
> fs/compat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/compat.c b/fs/compat.c
> index 6fd272d..beaf15b 100644
> --- a/fs/compat.c
> +++ b/fs/compat.c
> @@ -562,7 +562,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
> goto out;
>
> ret = -EINVAL;
> - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
> + if (nr_segs > UIO_MAXIOV)
> goto out;
> if (nr_segs > fast_segs) {
> ret = -ENOMEM;
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fs/compat: remove redundant 'less than zero' check
2015-04-24 10:07 [PATCH] fs/compat: remove redundant 'less than zero' check Firo Yang
2015-04-24 10:10 ` Julia Lawall
@ 2015-04-24 12:04 ` Dan Carpenter
2015-04-24 12:23 ` Julia Lawall
1 sibling, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2015-04-24 12:04 UTC (permalink / raw)
To: Firo Yang; +Cc: viro, kernel-janitors, linux-fsdevel
On Fri, Apr 24, 2015 at 06:07:50PM +0800, Firo Yang wrote:
> - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
> + if (nr_segs > UIO_MAXIOV)
Linus said at kernel summit that he thinks this kind of checks are ok.
Smatch already ignores checks like:
if (nr_segs < 0 || nr_segs > UIO_MAXIOV)
So making it ignore this one as well shouldn't be hard... I'll change
Smatch to ignore this one as well.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fs/compat: remove redundant 'less than zero' check
2015-04-24 12:04 ` Dan Carpenter
@ 2015-04-24 12:23 ` Julia Lawall
2015-04-24 13:00 ` Dan Carpenter
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-04-24 12:23 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Firo Yang, viro, kernel-janitors, linux-fsdevel
On Fri, 24 Apr 2015, Dan Carpenter wrote:
> On Fri, Apr 24, 2015 at 06:07:50PM +0800, Firo Yang wrote:
>
> > - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
> > + if (nr_segs > UIO_MAXIOV)
>
> Linus said at kernel summit that he thinks this kind of checks are ok.
>
> Smatch already ignores checks like:
>
> if (nr_segs < 0 || nr_segs > UIO_MAXIOV)
>
> So making it ignore this one as well shouldn't be hard... I'll change
> Smatch to ignore this one as well.
It is unsigned. What is the point of cluttering the code?
julia
>
> regards,
> dan carpenter
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] fs/compat: remove redundant 'less than zero' check
2015-04-24 12:23 ` Julia Lawall
@ 2015-04-24 13:00 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2015-04-24 13:00 UTC (permalink / raw)
To: Julia Lawall; +Cc: Firo Yang, viro, kernel-janitors, linux-fsdevel
On Fri, Apr 24, 2015 at 02:23:23PM +0200, Julia Lawall wrote:
> On Fri, 24 Apr 2015, Dan Carpenter wrote:
>
> > On Fri, Apr 24, 2015 at 06:07:50PM +0800, Firo Yang wrote:
> >
> > > - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
> > > + if (nr_segs > UIO_MAXIOV)
> >
> > Linus said at kernel summit that he thinks this kind of checks are ok.
> >
> > Smatch already ignores checks like:
> >
> > if (nr_segs < 0 || nr_segs > UIO_MAXIOV)
> >
> > So making it ignore this one as well shouldn't be hard... I'll change
> > Smatch to ignore this one as well.
>
> It is unsigned. What is the point of cluttering the code?
I guess I don't feel strongly either way. It was Linus who said
something like "the intent is clear from the code" so he isn't a fan of
these particular static checker fixes.
These are easy enough for me to filter out so they needn't cause a false
positive.
They're more of a style issue than anything else. With coccinelle, it's
easier to care about style issues because you can fix them automatically.
In Smatch caring about style issues is a time suck.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-04-24 13:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-24 10:07 [PATCH] fs/compat: remove redundant 'less than zero' check Firo Yang
2015-04-24 10:10 ` Julia Lawall
[not found] ` <CAOXNuu2VKCWNSiePoSw4-G3TqxpXDE9fR75B75-fhQLa-SPcJg@mail.gmail.com>
2015-04-24 10:29 ` Julia Lawall
2015-04-24 12:04 ` Dan Carpenter
2015-04-24 12:23 ` Julia Lawall
2015-04-24 13:00 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).