From: Jian Yu Date: Thu, 9 Dec 2021 19:18:13 +0000 (-0800) Subject: LU-15220 utils: fix gcc-11 -Werror=mismatched-dealloc error X-Git-Tag: 2.14.57~37 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=64ba2b18349b56c5d7ade944ea713bade84bc02e LU-15220 utils: fix gcc-11 -Werror=mismatched-dealloc error 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 Reviewed-on: https://review.whamcloud.com/45814 Tested-by: jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c index 3cac543..e36aabe 100644 --- a/lustre/utils/lustre_rsync.c +++ b/lustre/utils/lustre_rsync.c @@ -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; }