From 64ba2b18349b56c5d7ade944ea713bade84bc02e Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Thu, 9 Dec 2021 11:18:13 -0800 Subject: [PATCH] LU-15220 utils: fix gcc-11 -Werror=mismatched-dealloc error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- lustre/utils/lustre_rsync.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; } -- 1.8.3.1