From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm-tool] dlm_tool: fix missing fclose calls
Date: Thu, 30 Mar 2023 15:30:27 -0400 [thread overview]
Message-ID: <20230330193027.153456-1-aahringo@redhat.com> (raw)
This patch will fix missing fclose() calls when fgets() of do_lockdump()
fails.
---
dlm_tool/main.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlm_tool/main.c b/dlm_tool/main.c
index 52fd5b89..2e6810d6 100644
--- a/dlm_tool/main.c
+++ b/dlm_tool/main.c
@@ -1177,8 +1177,9 @@ static void do_lockdump(char *name)
}
/* skip the header on the first line */
- if (!fgets(line, LOCK_LINE_MAX, file))
- return;
+ if (!fgets(line, LOCK_LINE_MAX, file)) {
+ goto out;
+ }
while (fgets(line, LOCK_LINE_MAX, file)) {
rv = sscanf(line, "%x %d %x %u %llu %x %x %hhd %hhd %hhd %u %d %d",
@@ -1199,7 +1200,7 @@ static void do_lockdump(char *name)
if (rv != 13) {
fprintf(stderr, "invalid debugfs line %d: %s\n",
rv, line);
- return;
+ goto out;
}
memset(r_name, 0, sizeof(r_name));
@@ -1229,6 +1230,7 @@ static void do_lockdump(char *name)
ownpid, nodeid, r_name);
}
+ out:
fclose(file);
}
--
2.31.1
reply other threads:[~2023-03-30 19:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230330193027.153456-1-aahringo@redhat.com \
--to=aahringo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).