diff options
author | Jeff Layton <jlayton@redhat.com> | 2011-03-31 17:32:54 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2011-04-12 00:56:46 +0000 |
commit | c0c7b905e911a1f1faf515a24e849d4ffcdd0a8a (patch) | |
tree | 8449fe54d28dc94b78ec43d48c99300c023f2de0 /fs | |
parent | 2b6c26a0a62cc0bab0ad487533d5581d7c293fef (diff) | |
download | linux-c0c7b905e911a1f1faf515a24e849d4ffcdd0a8a.tar.bz2 |
cifs: clean up length checks in check2ndT2
Thus spake David Howells:
The code that follows this:
remaining = total_data_size - data_in_this_rsp;
if (remaining == 0)
return 0;
else if (remaining < 0) {
generates better code if you drop the 'remaining' variable and compare
the values directly.
Clean it up per his recommendation...
Reported-and-acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/connect.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 5eacb89d4a4f..709fd9d9b78f 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -248,24 +248,24 @@ static int check2ndT2(struct smb_hdr *pSMB, unsigned int maxBufSize) total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount); data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount); - remaining = total_data_size - data_in_this_rsp; - - if (remaining == 0) + if (total_data_size == data_in_this_rsp) return 0; - else if (remaining < 0) { + else if (total_data_size < data_in_this_rsp) { cFYI(1, "total data %d smaller than data in frame %d", total_data_size, data_in_this_rsp); return -EINVAL; - } else { - cFYI(1, "missing %d bytes from transact2, check next response", - remaining); - if (total_data_size > maxBufSize) { - cERROR(1, "TotalDataSize %d is over maximum buffer %d", - total_data_size, maxBufSize); - return -EINVAL; - } - return remaining; } + + remaining = total_data_size - data_in_this_rsp; + + cFYI(1, "missing %d bytes from transact2, check next response", + remaining); + if (total_data_size > maxBufSize) { + cERROR(1, "TotalDataSize %d is over maximum buffer %d", + total_data_size, maxBufSize); + return -EINVAL; + } + return remaining; } static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) |