Skip to content

Commit b2a3ad9

Browse files
jtlaytonSteve French
authored andcommitted
cifs: silence compiler warnings showing up with gcc-4.7.0
gcc-4.7.0 has started throwing these warnings when building cifs.ko. CC [M] fs/cifs/cifssmb.o fs/cifs/cifssmb.c: In function ‘CIFSSMBSetCIFSACL’: fs/cifs/cifssmb.c:3905:9: warning: array subscript is above array bounds [-Warray-bounds] fs/cifs/cifssmb.c: In function ‘CIFSSMBSetFileInfo’: fs/cifs/cifssmb.c:5711:8: warning: array subscript is above array bounds [-Warray-bounds] fs/cifs/cifssmb.c: In function ‘CIFSSMBUnixSetFileInfo’: fs/cifs/cifssmb.c:6001:25: warning: array subscript is above array bounds [-Warray-bounds] This patch cleans up the code a bit by using the offsetof macro instead of the funky "&pSMB->hdr.Protocol" construct. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent b5efb97 commit b2a3ad9

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎fs/cifs/cifssmb.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3892,13 +3892,12 @@ CIFSSMBSetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid,
38923892
int rc = 0;
38933893
int bytes_returned = 0;
38943894
SET_SEC_DESC_REQ *pSMB = NULL;
3895-
NTRANSACT_RSP *pSMBr = NULL;
3895+
void *pSMBr;
38963896

38973897
setCifsAclRetry:
3898-
rc = smb_init(SMB_COM_NT_TRANSACT, 19, tcon, (void **) &pSMB,
3899-
(void **) &pSMBr);
3898+
rc = smb_init(SMB_COM_NT_TRANSACT, 19, tcon, (void **) &pSMB, &pSMBr);
39003899
if (rc)
3901-
return (rc);
3900+
return rc;
39023901

39033902
pSMB->MaxSetupCount = 0;
39043903
pSMB->Reserved = 0;
@@ -3926,9 +3925,8 @@ CIFSSMBSetCIFSACL(const int xid, struct cifs_tcon *tcon, __u16 fid,
39263925
pSMB->AclFlags = cpu_to_le32(aclflag);
39273926

39283927
if (pntsd && acllen) {
3929-
memcpy((char *) &pSMBr->hdr.Protocol + data_offset,
3930-
(char *) pntsd,
3931-
acllen);
3928+
memcpy((char *)pSMBr + offsetof(struct smb_hdr, Protocol) +
3929+
data_offset, pntsd, acllen);
39323930
inc_rfc1001_len(pSMB, byte_count + data_count);
39333931
} else
39343932
inc_rfc1001_len(pSMB, byte_count);
@@ -5708,7 +5706,8 @@ CIFSSMBSetFileInfo(const int xid, struct cifs_tcon *tcon,
57085706
param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
57095707
offset = param_offset + params;
57105708

5711-
data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
5709+
data_offset = (char *)pSMB +
5710+
offsetof(struct smb_hdr, Protocol) + offset;
57125711

57135712
count = sizeof(FILE_BASIC_INFO);
57145713
pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -5977,7 +5976,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
59775976
u16 fid, u32 pid_of_opener)
59785977
{
59795978
struct smb_com_transaction2_sfi_req *pSMB = NULL;
5980-
FILE_UNIX_BASIC_INFO *data_offset;
5979+
char *data_offset;
59815980
int rc = 0;
59825981
u16 params, param_offset, offset, byte_count, count;
59835982

@@ -5999,8 +5998,9 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
59995998
param_offset = offsetof(struct smb_com_transaction2_sfi_req, Fid) - 4;
60005999
offset = param_offset + params;
60016000

6002-
data_offset = (FILE_UNIX_BASIC_INFO *)
6003-
((char *)(&pSMB->hdr.Protocol) + offset);
6001+
data_offset = (char *)pSMB +
6002+
offsetof(struct smb_hdr, Protocol) + offset;
6003+
60046004
count = sizeof(FILE_UNIX_BASIC_INFO);
60056005

60066006
pSMB->MaxParameterCount = cpu_to_le16(2);
@@ -6022,7 +6022,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifs_tcon *tcon,
60226022
inc_rfc1001_len(pSMB, byte_count);
60236023
pSMB->ByteCount = cpu_to_le16(byte_count);
60246024

6025-
cifs_fill_unix_set_info(data_offset, args);
6025+
cifs_fill_unix_set_info((FILE_UNIX_BASIC_INFO *)data_offset, args);
60266026

60276027
rc = SendReceiveNoRsp(xid, tcon->ses, (char *) pSMB, 0);
60286028
if (rc)

0 commit comments

Comments
 (0)