From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2336 invoked by alias); 11 Feb 2009 10:45:44 -0000 Received: (qmail 2327 invoked by alias); 11 Feb 2009 10:45:43 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: master - qdisk: uses sizeof() when memsetting stack-defined variables To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: fa8609d8630744939426200a1840cfb6573cf587 X-Git-Newrev: e4ccc8b70c1c1d518b6a15d1cef9dd63d91db28c From: "Fabio M. Di Nitto" Message-Id: <20090211104522.145DD120198@lists.fedorahosted.org> Date: Wed, 11 Feb 2009 10:45:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00425.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=e4ccc8b70c1c1d518b6a15d1cef9dd63d91db28c Commit: e4ccc8b70c1c1d518b6a15d1cef9dd63d91db28c Parent: fa8609d8630744939426200a1840cfb6573cf587 Author: Fabio M. Di Nitto AuthorDate: Wed Feb 11 11:27:00 2009 +0100 Committer: Fabio M. Di Nitto 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 Signed-off-by: Fabio M. Di Nitto --- 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)) {