public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: "Fabio M. Di Nitto" <fabbione@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: master - qdisk: uses sizeof() when memsetting stack-defined variables Date: Wed, 11 Feb 2009 10:45:00 -0000 [thread overview] Message-ID: <20090211104522.145DD120198@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=e4ccc8b70c1c1d518b6a15d1cef9dd63d91db28c Commit: e4ccc8b70c1c1d518b6a15d1cef9dd63d91db28c Parent: fa8609d8630744939426200a1840cfb6573cf587 Author: Fabio M. Di Nitto <fdinitto@redhat.com> AuthorDate: Wed Feb 11 11:27:00 2009 +0100 Committer: Fabio M. Di Nitto <fdinitto@redhat.com> CommitterDate: Wed Feb 11 11:44:34 2009 +0100 qdisk: uses sizeof() when memsetting stack-defined variables so that if the size changes in the future ("I need a bigger buffer"), we don't have to change the value twice (Original patch by Lon, fixed a couple of wrong sizeof( on the way) Signed-off-by: Lon Hohberger <lhh@redhat.com> Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com> --- cman/qdisk/scandisk.c | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cman/qdisk/scandisk.c b/cman/qdisk/scandisk.c index 52fe7a3..8851fe3 100644 --- a/cman/qdisk/scandisk.c +++ b/cman/qdisk/scandisk.c @@ -317,14 +317,14 @@ static int scanmdstat(struct devlisthead *devlisthead) while (fgets(line, sizeof(line), fp) != NULL) { /* i like things to be absolutely clean */ - memset(device, 0, 16); - memset(separator, 0, 4); - memset(status, 0, 16); - memset(personality, 0, 16); - memset(firstdevice, 0, 16); - memset(devices, 0, 4096); - - if (strlen(line) > 4096) + memset(device, 0, sizeof(device)); + memset(separator, 0, sizeof(separator)); + memset(status, 0, sizeof(status)); + memset(personality, 0, sizeof(personality)); + memset(firstdevice, 0, sizeof(firstdevice)); + memset(devices, 0, sizeof(devices)); + + if (strlen(line) > sizeof(line)) continue; /* we only parse stuff that starts with ^md @@ -399,10 +399,10 @@ static int scanmapper(struct devlisthead *devlisthead) return 0; while (fgets(line, sizeof(line), fp) != NULL) { - memset(major, 0, 4); - memset(device, 0, 64); + memset(major, 0, sizeof(major)); + memset(device, 0, sizeof(device)); - if (strlen(line) > 4096) + if (strlen(line) > sizeof(line)) continue; if (!strncmp(line, "Block devices:", 13)) {
reply other threads:[~2009-02-11 10:45 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=20090211104522.145DD120198@lists.fedorahosted.org \ --to=fabbione@fedoraproject.org \ --cc=cluster-cvs-relay@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: linkBe 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).