]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
vol-salvage: calloc volume summary structs
authorAndrew Deason <adeason@sinenomine.net>
Wed, 2 Mar 2011 20:10:33 +0000 (14:10 -0600)
committerDerrick Brashear <shadow@dementia.org>
Tue, 8 Mar 2011 12:15:13 +0000 (04:15 -0800)
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 <sxw@inf.ed.ac.uk>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit bb25fc6418bac937b31476754a09199636c24211)

Change-Id: I9533d4f841ebc64bdf49c145512471ebbb51136e
Reviewed-on: http://gerrit.openafs.org/4164
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/vol/vol-salvage.c

index 824af59d1b964822f9b7b9dbce3893a5e1840134..595bd8aec3e076e11bdade634e96212edb1e5b49 100644 (file)
@@ -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;