Whamcloud - gitweb
LU-15220 utils: fix gcc-11 -Werror=mismatched-dealloc error 14/45814/3
authorJian Yu <yujian@whamcloud.com>
Thu, 9 Dec 2021 19:18:13 +0000 (11:18 -0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 11 Jan 2022 06:19:11 +0000 (06:19 +0000)
This patch fixes the following -Werror=mismatched-dealloc error in
lustre_rsync.c:

lustre_rsync.c: In function ‘lr_locate_rsync’:
lustre_rsync.c:1472:17: error: ‘fclose’ called on pointer returned
from a mismatched allocation function [-Werror=mismatched-dealloc]
 1472 |                 fclose(fp);
      |                 ^~~~~~~~~~
lustre_rsync.c:1467:14: note: returned from ‘popen’
 1467 |         fp = popen(rsync, "r");
      |              ^~~~~~~~~~~~~~~~~

Test-Parameters: trivial testlist=lustre-rsync-test

Change-Id: I518db394a282c8e6123d878f63312bfb27c59235
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45814
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lustre_rsync.c

index 3cac543..e36aabe 100644 (file)
@@ -1469,14 +1469,14 @@ int lr_locate_rsync(void)
                return -1;
 
        if (fgets(rsync, sizeof(rsync), fp) == NULL) {
-               fclose(fp);
+               pclose(fp);
                return -1;
        }
 
        len = strlen(rsync);
        if (len > 0 && rsync[len - 1] == '\n')
                rsync[len - 1] = '\0';
-       fclose(fp);
+       pclose(fp);
 
        /* Determine the version of rsync */
        snprintf(rsync_ver, sizeof(rsync_ver), "%s --version", rsync);
@@ -1485,13 +1485,13 @@ int lr_locate_rsync(void)
                return -1;
 
        if (fgets(rsync_ver, sizeof(rsync_ver), fp) == NULL) {
-               fclose(fp);
+               pclose(fp);
                return -1;
        }
        len = strlen(rsync_ver);
        if (len > 0 && rsync_ver[len - 1] == '\n')
                rsync_ver[len - 1] = '\0';
-       fclose(fp);
+       pclose(fp);
 
        return 0;
 }