From bb25fc6418bac937b31476754a09199636c24211 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 2 Mar 2011 14:10:33 -0600 Subject: [PATCH 1/1] vol-salvage: calloc volume summary structs Calloc volume summary structs instead of malloc'ing them, in vol-salvage.c. This way, new fields added to struct VolumeSummary will be known to be zeroed by default, without needing to update all of the allocating callers. Change-Id: I8c647cd9dec7aaf14183452126049323859ac7a3 Reviewed-on: http://gerrit.openafs.org/4117 Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: BuildBot --- src/vol/vol-salvage.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index c217222..d78a6ba 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -1399,7 +1399,7 @@ AskVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber) Exit(SALSRV_EXIT_VOLGROUP_LINK); } - salvinfo->volumeSummaryp = malloc(VOL_VG_MAX_VOLS * sizeof(struct VolumeSummary)); + salvinfo->volumeSummaryp = calloc(VOL_VG_MAX_VOLS, sizeof(struct VolumeSummary)); osi_Assert(salvinfo->volumeSummaryp != NULL); salvinfo->nVolumes = 0; @@ -1715,7 +1715,7 @@ GetVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber) nvols = VOL_VG_MAX_VOLS; } - salvinfo->volumeSummaryp = malloc(nvols * sizeof(struct VolumeSummary)); + salvinfo->volumeSummaryp = calloc(nvols, sizeof(struct VolumeSummary)); osi_Assert(salvinfo->volumeSummaryp != NULL); params.singleVolumeNumber = singleVolumeNumber; @@ -2289,8 +2289,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp, Log("No header file for volume %u; %screating %s\n", isp->volumeId, (Testing ? "it would have been " : ""), path); - isp->volSummary = (struct VolumeSummary *) - malloc(sizeof(struct VolumeSummary)); + isp->volSummary = calloc(1, sizeof(struct VolumeSummary)); isp->volSummary->fileName = ToString(headerName); writefunc = VCreateVolumeDiskHeader; -- 1.9.4