* [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
* Re: [patch] CIFS: cleanup min_t() cast in cifs_read()
[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>
0 siblings, 1 reply; 5+ messages in thread
From: Steve French @ 2011-10-17 14:10 UTC (permalink / raw)
To: Dan Carpenter
Cc: Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
I prefer the change to unsigned int rather than u32 so it is clearer
that you are not casting the value from 64 bit to 32 bit on some
architectures. To avoid reformatting can't you can use "uint" if you
want the shorter form see:
include/linux/types.h:typedef unsigned int uint;
On Mon, Oct 17, 2011 at 2:30 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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;
>
--
Thanks,
Steve
--
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] 5+ messages in thread
* Re: [patch] CIFS: cleanup min_t() cast in cifs_read()
[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
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2011-10-17 14:18 UTC (permalink / raw)
To: Steve French
Cc: Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
On Mon, Oct 17, 2011 at 09:10:01AM -0500, Steve French wrote:
> I prefer the change to unsigned int rather than u32 so it is clearer
> that you are not casting the value from 64 bit to 32 bit on some
> architectures. To avoid reformatting can't you can use "uint" if you
> want the shorter form see:
>
> include/linux/types.h:typedef unsigned int uint;
>
Yes. That looks nicer. I'll resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch v2] CIFS: cleanup min_t() cast in cifs_read()
[not found] ` <CAH2r5mufq0=BsZvfGuVdd1BU-gxRpnUmWAm-vzhsOR4KbvGSbg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-17 14:18 ` Dan Carpenter
@ 2011-10-18 9:41 ` Dan Carpenter
[not found] ` <20111018094135.GE25814-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2011-10-18 9:41 UTC (permalink / raw)
To: Steve French
Cc: Steve French, 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. I removed the const as well, as that
doesn't do anything here.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: use "uint" instead of "u32".
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index ab85699..34be15a 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1900,13 +1900,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(uint, 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(uint, current_read_size,
CIFSMaxBufSize);
}
rc = -EAGAIN;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [patch v2] CIFS: cleanup min_t() cast in cifs_read()
[not found] ` <20111018094135.GE25814-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
@ 2011-10-18 15:42 ` Steve French
0 siblings, 0 replies; 5+ messages in thread
From: Steve French @ 2011-10-18 15:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
merged.
On Tue, Oct 18, 2011 at 4:41 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 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. I removed the const as well, as that
> doesn't do anything here.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: use "uint" instead of "u32".
>
> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
> index ab85699..34be15a 100644
> --- a/fs/cifs/file.c
> +++ b/fs/cifs/file.c
> @@ -1900,13 +1900,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(uint, 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(uint, current_read_size,
> CIFSMaxBufSize);
> }
> rc = -EAGAIN;
>
--
Thanks,
Steve
--
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] 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