public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - qdisk: uses sizeof() when memsetting stack-defined variables
@ 2009-02-11 10:31 Fabio M. Di Nitto
  0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-02-11 10:31 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=eadf95f2a6e0ee01af107921ab7c3b306df32fb9
Commit:        eadf95f2a6e0ee01af107921ab7c3b306df32fb9
Parent:        02bdf16609905e52a2ba6f52b202f764cd42d650
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:27:00 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)) {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-11 10:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 10:31 cluster: STABLE3 - qdisk: uses sizeof() when memsetting stack-defined variables Fabio M. Di Nitto

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).