Use min_t() instead of min() in fs/cifs/cifssmb.c
PATCH 1/1 Use min_t() instead of min() in fs/cifs/cifssmb.c
This change removes "duplicate 'const'" compiler warnings.
fs/cifs/cifssmb.c +12 -9
@@ -483,9 +483,10 @@ pSMB->OffsetLow =cpu_to_le32 (lseek &0xFFFFFFFF ); pSMB->OffsetHigh =cpu_to_le32 (lseek >>32 ); pSMB->Remaining =0 ; - pSMB->MaxCount =cpu_to_le16 (min (count, - (tcon->ses->maxBuf - -MAX_CIFS_HDR_SIZE ) &0xFFFFFF00 )); + pSMB->MaxCount = cpu_to_le16(min_t(const unsigned int, + count, + (tcon->ses->maxBuf - +MAX_CIFS_HDR_SIZE ) &0xFFFFFF00 )); pSMB->MaxCountHigh =0 ; pSMB->ByteCount =0 ;/* no need to do le conversion since it is 0 */
@@ -1023,9 +1024,10 @@ Protocol + pSMBr-> DataOffset), - min(buflen, - (int) pSMBr-> - DataCount) / 2); + min_t(const int, + buflen, + (int) pSMBr-> + DataCount) / 2); cifs_strfromUCS_le(symlinkinfo, (wchar_t *) ((char *) &pSMBr->
@@ -1037,9 +1039,10 @@ }else {strncpy (symlinkinfo, (char *) &pSMBr->hdr.Protocol + - pSMBr->DataOffset,min (buflen, (int ) - pSMBr-> - DataCount)); + pSMBr->DataOffset, min_t(const int, + buflen, + pSMBr-> + DataCount)); } symlinkinfo[buflen] =0 ;/* just in case so the calling code does not go off the end of the buffer */ }
Signature · 2 lines
Bob Miller Email: [email protected] Open Source Development Lab Phone: 503.626.2455 Ext. 17
In message <[email protected]> you write:
Quoted 2 lines
This change removes "duplicate 'const'" compiler warnings.
Um, might want to remove the const from min() and max(), which would be much nicer. It was only there because it worked fine with older compilers, and I don't think it will effect code generation one bit.
Someone wanna test before and after?
Thanks,
Rusty.
Quoted 34 lines
diff -Nru
a/fs/cifs/cifssmb.cb/fs/cifs/cifssmb.cfs/cifs/cifssmb.c +8
-6@@ -483,9 +483,10 @@ pSMB->OffsetLow =cpu_to_le32 (lseek &0xFFFFFFFF ); pSMB->OffsetHigh =cpu_to_le32 (lseek >>32 ); pSMB->Remaining =0 ; - pSMB->MaxCount =cpu_to_le16 (min (count, - (tcon->ses->maxBuf - -MAX_CIFS_HDR_SIZE ) &0xFFFFFF00 )); + pSMB->MaxCount = cpu_to_le16(min_t(const unsigned int, + count, + (tcon->ses->maxBuf - +MAX_CIFS_HDR_SIZE ) &0xFFFFFF00 )); pSMB->MaxCountHigh =0 ; pSMB->ByteCount =0 ;/* no need to do le conversion since it is 0 */ @@ -1023,9 +1024,10 @@ Protocol + pSMBr-> DataOffset), - min(buflen, - (int) pSMBr-> - DataCount) / 2); + min_t(const int, + buflen, + (int) pSMBr-> + DataCount) / 2); cifs_strfromUCS_le(symlinkinfo, (wchar_t *) ((char *) &pSMBr->@@ -1037,9 +1039,10 @@ }else { strncpy(symlinkinfo,
fs/cifs/cifssmb.c line 1047
Quoted 10 lines
fs/cifs/cifssmb.c +4
-3(char *) &pSMBr->hdr.Protocol + - pSMBr->DataOffset,min (buflen, (int ) - pSMBr-> - DataCount)); + pSMBr->DataOffset, min_t(const int, + buflen, + pSMBr-> + DataCount)); } symlinkinfo[buflen] =0 ;/* just in case so the
calling code does not go off the end of the buffer */
Quoted 5 lines
fs/cifs/cifssmb.c +0
-0}Signature · 2 lines
Bob Miller Email: [email protected] Open Source Development Lab Phone: 503.626.2455 Ext. 17
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.