From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] fs/file.c: silence a static checker warning
Date: Tue, 21 Oct 2014 14:22:49 +0000 [thread overview]
Message-ID: <20141021142249.GA29255@mwanda> (raw)
This doesn't matter because all the callers verify "nr" before calling
but really "nr" should be unsigned. Otherwise, if we could get a
negative here then it would be able to go around our tests.
193 /* Do we need to expand? */
194 if (nr < fdt->max_fds)
^^^^^^^^^^^^^^^^^
For this test "nr" is type promoted to a high positive so we continue.
195 return 0;
196
197 /* Can we expand? */
198 if (nr >= sysctl_nr_open)
^^^^^^^^^^^^^^^^^^^^
For this test it's treated as a negative so it's less than the max.
199 return -EMFILE;
200
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/file.c b/fs/file.c
index ee738ea..029b19b 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -184,7 +184,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
* expanded and execution may have blocked.
* The files->file_lock should be held on entry, and will be held on exit.
*/
-static int expand_files(struct files_struct *files, int nr)
+static int expand_files(struct files_struct *files, unsigned int nr)
{
struct fdtable *fdt;
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] fs/file.c: silence a static checker warning
Date: Tue, 21 Oct 2014 17:22:49 +0300 [thread overview]
Message-ID: <20141021142249.GA29255@mwanda> (raw)
This doesn't matter because all the callers verify "nr" before calling
but really "nr" should be unsigned. Otherwise, if we could get a
negative here then it would be able to go around our tests.
193 /* Do we need to expand? */
194 if (nr < fdt->max_fds)
^^^^^^^^^^^^^^^^^
For this test "nr" is type promoted to a high positive so we continue.
195 return 0;
196
197 /* Can we expand? */
198 if (nr >= sysctl_nr_open)
^^^^^^^^^^^^^^^^^^^^
For this test it's treated as a negative so it's less than the max.
199 return -EMFILE;
200
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/file.c b/fs/file.c
index ee738ea..029b19b 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -184,7 +184,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
* expanded and execution may have blocked.
* The files->file_lock should be held on entry, and will be held on exit.
*/
-static int expand_files(struct files_struct *files, int nr)
+static int expand_files(struct files_struct *files, unsigned int nr)
{
struct fdtable *fdt;
next reply other threads:[~2014-10-21 14:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 14:22 Dan Carpenter [this message]
2014-10-21 14:22 ` [patch] fs/file.c: silence a static checker warning Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141021142249.GA29255@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.