From owner-svn-src-stable-11@freebsd.org Sat May 6 02:39:12 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E1B23D5FC1E; Sat, 6 May 2017 02:39:12 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B9A90A62; Sat, 6 May 2017 02:39:12 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v462dBqX093961; Sat, 6 May 2017 02:39:11 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v462dB1A093957; Sat, 6 May 2017 02:39:11 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201705060239.v462dB1A093957@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 6 May 2017 02:39:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317860 - stable/11/sbin/fsck_ffs X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 May 2017 02:39:13 -0000 Author: pfg Date: Sat May 6 02:39:11 2017 New Revision: 317860 URL: https://svnweb.freebsd.org/changeset/base/317860 Log: 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 Modified: stable/11/sbin/fsck_ffs/fsck.h stable/11/sbin/fsck_ffs/globs.c stable/11/sbin/fsck_ffs/inode.c stable/11/sbin/fsck_ffs/setup.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/fsck_ffs/fsck.h ============================================================================== --- stable/11/sbin/fsck_ffs/fsck.h Sat May 6 00:51:25 2017 (r317859) +++ stable/11/sbin/fsck_ffs/fsck.h Sat May 6 02:39:11 2017 (r317860) @@ -282,7 +282,8 @@ struct inoinfo { u_int i_numblks; /* size of block array in bytes */ ufs2_daddr_t i_blks[1]; /* actually longer */ } **inphead, **inpsort; -extern long numdirs, dirhash, listmax, inplast; +extern long dirhash, inplast; +extern unsigned long numdirs, listmax; extern long countdirs; /* number of directories we actually found */ #define MIBSIZE 3 /* size of fsck sysctl MIBs */ Modified: stable/11/sbin/fsck_ffs/globs.c ============================================================================== --- stable/11/sbin/fsck_ffs/globs.c Sat May 6 00:51:25 2017 (r317859) +++ stable/11/sbin/fsck_ffs/globs.c Sat May 6 02:39:11 2017 (r317860) @@ -56,7 +56,8 @@ struct bufarea sblk; /* file system sup struct bufarea *pdirbp; /* current directory contents */ struct bufarea *pbp; /* current inode block */ ino_t cursnapshot; -long numdirs, dirhash, listmax, inplast; +long dirhash, inplast; +unsigned long numdirs, listmax; long countdirs; /* number of directories we actually found */ int adjrefcnt[MIBSIZE]; /* MIB command to adjust inode reference cnt */ int adjblkcnt[MIBSIZE]; /* MIB command to adjust inode block count */ @@ -123,7 +124,7 @@ fsckinit(void) pdirbp = NULL; pbp = NULL; cursnapshot = 0; - numdirs = dirhash = listmax = inplast = 0; + listmax = numdirs = dirhash = inplast = 0; countdirs = 0; bzero(adjrefcnt, sizeof(int) * MIBSIZE); bzero(adjblkcnt, sizeof(int) * MIBSIZE); Modified: stable/11/sbin/fsck_ffs/inode.c ============================================================================== --- stable/11/sbin/fsck_ffs/inode.c Sat May 6 00:51:25 2017 (r317859) +++ stable/11/sbin/fsck_ffs/inode.c Sat May 6 02:39:11 2017 (r317860) @@ -472,8 +472,8 @@ cacheino(union dinode *dp, ino_t inumber inp->i_blks[NDADDR + i] = DIP(dp, di_ib[i]); if (inplast == listmax) { listmax += 100; - inpsort = (struct inoinfo **)realloc((char *)inpsort, - (unsigned)listmax * sizeof(struct inoinfo *)); + inpsort = (struct inoinfo **)reallocarray((char *)inpsort, + listmax, sizeof(struct inoinfo *)); if (inpsort == NULL) errx(EEXIT, "cannot increase directory list"); } Modified: stable/11/sbin/fsck_ffs/setup.c ============================================================================== --- stable/11/sbin/fsck_ffs/setup.c Sat May 6 00:51:25 2017 (r317859) +++ stable/11/sbin/fsck_ffs/setup.c Sat May 6 02:39:11 2017 (r317860) @@ -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 *));