From 9cb10be35b6942111a1110f569c8c77191ddbd23 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 2 Mar 2011 14:10:33 -0600 Subject: [PATCH] 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. Reviewed-on: http://gerrit.openafs.org/4117 Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear Tested-by: BuildBot (cherry picked from commit bb25fc6418bac937b31476754a09199636c24211) Change-Id: I9533d4f841ebc64bdf49c145512471ebbb51136e Reviewed-on: http://gerrit.openafs.org/4164 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- 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 824af59d1..595bd8aec 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -1397,7 +1397,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; @@ -1713,7 +1713,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; @@ -2283,8 +2283,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; -- 2.39.5