OSDN Git Service

smb: client: fix warning in CIFSFindFirst()
authorPaulo Alcantara <pc@manguebit.com>
Mon, 19 Jun 2023 20:58:52 +0000 (17:58 -0300)
committerSteve French <stfrench@microsoft.com>
Wed, 21 Jun 2023 04:03:03 +0000 (23:03 -0500)
This fixes the following warning reported by kernel test robot

  fs/smb/client/cifssmb.c:4089 CIFSFindFirst() warn: missing error
  code? 'rc'

Link: https://lore.kernel.org/all/202306170124.CtQqzf0I-lkp@intel.com/
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifssmb.c

index 9d963ca..25d2509 100644 (file)
@@ -3958,11 +3958,12 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
        TRANSACTION2_FFIRST_REQ *pSMB = NULL;
        TRANSACTION2_FFIRST_RSP *pSMBr = NULL;
        T2_FFIRST_RSP_PARMS *parms;
-       int rc = 0;
+       struct nls_table *nls_codepage;
+       unsigned int lnoff;
+       __u16 params, byte_count;
        int bytes_returned = 0;
        int name_len, remap;
-       __u16 params, byte_count;
-       struct nls_table *nls_codepage;
+       int rc = 0;
 
        cifs_dbg(FYI, "In FindFirst for %s\n", searchName);
 
@@ -4043,63 +4044,52 @@ findFirstRetry:
                         (struct smb_hdr *) pSMBr, &bytes_returned, 0);
        cifs_stats_inc(&tcon->stats.cifs_stats.num_ffirst);
 
-       if (rc) {/* BB add logic to retry regular search if Unix search
-                       rejected unexpectedly by server */
-               /* BB Add code to handle unsupported level rc */
+       if (rc) {
+               /*
+                * BB: add logic to retry regular search if Unix search rejected
+                * unexpectedly by server.
+                */
+               /* BB: add code to handle unsupported level rc */
                cifs_dbg(FYI, "Error in FindFirst = %d\n", rc);
-
                cifs_buf_release(pSMB);
-
-               /* BB eventually could optimize out free and realloc of buf */
-               /*    for this case */
+               /*
+                * BB: eventually could optimize out free and realloc of buf for
+                * this case.
+                */
                if (rc == -EAGAIN)
                        goto findFirstRetry;
-       } else { /* decode response */
-               /* BB remember to free buffer if error BB */
-               rc = validate_t2((struct smb_t2_rsp *)pSMBr);
-               if (rc == 0) {
-                       unsigned int lnoff;
-
-                       if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
-                               psrch_inf->unicode = true;
-                       else
-                               psrch_inf->unicode = false;
-
-                       psrch_inf->ntwrk_buf_start = (char *)pSMBr;
-                       psrch_inf->smallBuf = false;
-                       psrch_inf->srch_entries_start =
-                               (char *) &pSMBr->hdr.Protocol +
-                                       le16_to_cpu(pSMBr->t2.DataOffset);
-                       parms = (T2_FFIRST_RSP_PARMS *)((char *) &pSMBr->hdr.Protocol +
-                              le16_to_cpu(pSMBr->t2.ParameterOffset));
-
-                       if (parms->EndofSearch)
-                               psrch_inf->endOfSearch = true;
-                       else
-                               psrch_inf->endOfSearch = false;
-
-                       psrch_inf->entries_in_buffer =
-                                       le16_to_cpu(parms->SearchCount);
-                       psrch_inf->index_of_last_entry = 2 /* skip . and .. */ +
-                               psrch_inf->entries_in_buffer;
-                       lnoff = le16_to_cpu(parms->LastNameOffset);
-                       if (CIFSMaxBufSize < lnoff) {
-                               cifs_dbg(VFS, "ignoring corrupt resume name\n");
-                               psrch_inf->last_entry = NULL;
-                               return rc;
-                       }
-
-                       psrch_inf->last_entry = psrch_inf->srch_entries_start +
-                                                       lnoff;
-
-                       if (pnetfid)
-                               *pnetfid = parms->SearchHandle;
-               } else {
-                       cifs_buf_release(pSMB);
-               }
+               return rc;
+       }
+       /* decode response */
+       rc = validate_t2((struct smb_t2_rsp *)pSMBr);
+       if (rc) {
+               cifs_buf_release(pSMB);
+               return rc;
        }
 
-       return rc;
+       psrch_inf->unicode = !!(pSMBr->hdr.Flags2 & SMBFLG2_UNICODE);
+       psrch_inf->ntwrk_buf_start = (char *)pSMBr;
+       psrch_inf->smallBuf = false;
+       psrch_inf->srch_entries_start = (char *)&pSMBr->hdr.Protocol +
+               le16_to_cpu(pSMBr->t2.DataOffset);
+
+       parms = (T2_FFIRST_RSP_PARMS *)((char *)&pSMBr->hdr.Protocol +
+                                       le16_to_cpu(pSMBr->t2.ParameterOffset));
+       psrch_inf->endOfSearch = !!parms->EndofSearch;
+
+       psrch_inf->entries_in_buffer = le16_to_cpu(parms->SearchCount);
+       psrch_inf->index_of_last_entry = 2 /* skip . and .. */ +
+               psrch_inf->entries_in_buffer;
+       lnoff = le16_to_cpu(parms->LastNameOffset);
+       if (CIFSMaxBufSize < lnoff) {
+               cifs_dbg(VFS, "ignoring corrupt resume name\n");
+               psrch_inf->last_entry = NULL;
+       } else {
+               psrch_inf->last_entry = psrch_inf->srch_entries_start + lnoff;
+               if (pnetfid)
+                       *pnetfid = parms->SearchHandle;
+       }
+       return 0;
 }
 
 int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,