public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] CIFS: cleanup min_t() cast in cifs_read()
@ 2011-10-17  7:30 Dan Carpenter
       [not found] ` <20111017073018.GC7812-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2011-10-17  7:30 UTC (permalink / raw)
  To: Steve French
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

Smatch complains that the cast to "int" in min_t() changes very large
values of current_read_size into negative values and so min_t()
could return the wrong value.

Also casting the "const" here doesn't make sense.

I've changed it to u32 ("unsigned int" take puts us past the 80
character limit).

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 9f41a10..a61f581 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1861,13 +1861,13 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
 	for (total_read = 0, current_offset = read_data;
 	     read_size > total_read;
 	     total_read += bytes_read, current_offset += bytes_read) {
-		current_read_size = min_t(const int, read_size - total_read,
+		current_read_size = min_t(u32, read_size - total_read,
 					  cifs_sb->rsize);
 		/* For windows me and 9x we do not want to request more
 		than it negotiated since it will refuse the read then */
 		if ((pTcon->ses) &&
 			!(pTcon->ses->capabilities & CAP_LARGE_FILES)) {
-			current_read_size = min_t(const int, current_read_size,
+			current_read_size = min_t(u32, current_read_size,
 					pTcon->ses->server->maxBuf - 128);
 		}
 		rc = -EAGAIN;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-10-18 15:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17  7:30 [patch] CIFS: cleanup min_t() cast in cifs_read() Dan Carpenter
     [not found] ` <20111017073018.GC7812-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2011-10-17 14:10   ` Steve French
     [not found]     ` <CAH2r5mufq0=BsZvfGuVdd1BU-gxRpnUmWAm-vzhsOR4KbvGSbg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-17 14:18       ` Dan Carpenter
2011-10-18  9:41       ` [patch v2] " Dan Carpenter
     [not found]         ` <20111018094135.GE25814-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2011-10-18 15:42           ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox