From 5d76adac38d9c07945c337413ccb2d812df59b4a Mon Sep 17 00:00:00 2001 From: pfg Date: Sat, 6 May 2017 02:39:11 +0000 Subject: MFC r317283: fsck_ffs: Unsign some variables and make use of reallocarray(3). Instead of casting listmax and numdirs to unsigned values just define them as unsigned and avoid the casts. Use reallocarray(3). While here, fs_ncg is already unsigned so the cast is unnecessary. Reviewed by: mckusick --- sbin/fsck_ffs/setup.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sbin/fsck_ffs/setup.c') diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 0bcf06c..5c2b49f 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -268,8 +268,7 @@ setup(char *dev) (unsigned)bmapsize); goto badsb; } - inostathead = Calloc((unsigned)(sblock.fs_ncg), - sizeof(struct inostatlist)); + inostathead = Calloc(sblock.fs_ncg, sizeof(struct inostatlist)); if (inostathead == NULL) { printf("cannot alloc %u bytes for inostathead\n", (unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg))); @@ -279,10 +278,8 @@ setup(char *dev) dirhash = numdirs; inplast = 0; listmax = numdirs + 10; - inpsort = (struct inoinfo **)Calloc((unsigned)listmax, - sizeof(struct inoinfo *)); - inphead = (struct inoinfo **)Calloc((unsigned)numdirs, - sizeof(struct inoinfo *)); + inpsort = (struct inoinfo **)Calloc(listmax, sizeof(struct inoinfo *)); + inphead = (struct inoinfo **)Calloc(numdirs, sizeof(struct inoinfo *)); if (inpsort == NULL || inphead == NULL) { printf("cannot alloc %ju bytes for inphead\n", (uintmax_t)numdirs * sizeof(struct inoinfo *)); -- cgit v1.1