cluster: master - qdisk: uses sizeof() when memsetting stack-defined variables

Fabio M. Di Nitto fabbione@fedoraproject.org
Wed Feb 11 10:45:00 GMT 2009


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



More information about the Cluster-cvs mailing list