* [patch] fs/file.c: silence a static checker warning
@ 2014-10-21 14:22 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2014-10-21 14:22 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-fsdevel, kernel-janitors
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-10-21 14:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-21 14:22 [patch] fs/file.c: silence a static checker warning 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).