From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH gfs2-utils 2/2] glocktop: allocate fsdlm dynamically
Date: Thu, 11 Mar 2021 14:20:36 -0500 [thread overview]
Message-ID: <20210311192036.17218-3-aahringo@redhat.com> (raw)
In-Reply-To: <20210311192036.17218-1-aahringo@redhat.com>
This patch allocates the fsdlm string dynamically with respect of
dlmwaiters. The fsdlm has at least the dlmwaiters length, the 105 bytes
are for some other predicted max length strings.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
gfs2/glocktop/glocktop.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 9df87d18..0096a2a5 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -1605,7 +1605,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,
int dlmgrants, int trace_dir_path,
int show_held, int help, int summary)
{
- char fstitle[96], fsdlm[105];
+ char fstitle[96], *fsdlm;
char ctimestr[64];
time_t t;
int i;
@@ -1615,7 +1615,12 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,
strftime(ctimestr, 64, "%a %b %d %T %Y", localtime(&t));
ctimestr[63] = '\0';
memset(fstitle, 0, sizeof(fstitle));
- memset(fsdlm, 0, sizeof(fsdlm));
+ fsdlm = calloc(1, 105 + dlmwaiters);
+ if (!fsdlm) {
+ printf("Failed to allocate fsdlm\n");
+ exit(-1);
+ }
+
sprintf(fstitle, "@ %.22s %s ", fsname, ctimestr);
if (dlmwaiters) {
sprintf(fsdlm, "dlm: %s/%s/%s [", dlm_dirtbl_size,
@@ -1628,6 +1633,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,
}
attron(A_BOLD);
print_it(NULL, "%s @%s %s", NULL, fstitle, hostname, fsdlm);
+ free(fsdlm);
eol(0);
attroff(A_BOLD);
glock_details(fd, fsname, dlmwaiters, dlmgrants, trace_dir_path,
--
2.26.2
next prev parent reply other threads:[~2021-03-11 19:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 19:20 [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Alexander Aring
2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 1/2] glocktop: use MAX_LINES for dlmwlines Alexander Aring
2021-03-11 19:20 ` Alexander Aring [this message]
2021-03-13 15:09 ` [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Andrew Price
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=20210311192036.17218-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.