From owner-svn-src-head@freebsd.org Wed Jan 24 17:58:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9568CEB8CB8; Wed, 24 Jan 2018 17:58:49 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 477806C96A; Wed, 24 Jan 2018 17:58:49 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 299C820F0C; Wed, 24 Jan 2018 17:58:49 +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 w0OHwnPZ063528; Wed, 24 Jan 2018 17:58:49 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0OHwm26063524; Wed, 24 Jan 2018 17:58:48 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801241758.w0OHwm26063524@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 24 Jan 2018 17:58:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328346 - in head/sys: fs/ext2fs ufs/ffs ufs/ufs X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: in head/sys: fs/ext2fs ufs/ffs ufs/ufs X-SVN-Commit-Revision: 328346 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 17:58:49 -0000 Author: pfg Date: Wed Jan 24 17:58:48 2018 New Revision: 328346 URL: https://svnweb.freebsd.org/changeset/base/328346 Log: ext2fs|ufs:Unsign some values related to allocation. When allocating memory through malloc(9), we always expect the amount of memory requested to be unsigned as a negative value would either stand for an error or an overflow. Unsign some values, found when considering the use of mallocarray(9), to avoid unnecessary casting. Also consider that indexes should be of at least the same size/type as the upper limit they pretend to index. MFC after: 2 weeks Modified: head/sys/fs/ext2fs/ext2_lookup.c head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ufs/ufs_dirhash.c head/sys/ufs/ufs/ufs_vnops.c Modified: head/sys/fs/ext2fs/ext2_lookup.c ============================================================================== --- head/sys/fs/ext2fs/ext2_lookup.c Wed Jan 24 17:52:06 2018 (r328345) +++ head/sys/fs/ext2fs/ext2_lookup.c Wed Jan 24 17:58:48 2018 (r328346) @@ -145,9 +145,9 @@ ext2_readdir(struct vop_readdir_args *ap) off_t offset, startoffset; size_t readcnt, skipcnt; ssize_t startresid; - int ncookies; int DIRBLKSIZ = VTOI(ap->a_vp)->i_e2fs->e2fs_bsize; int error; + u_int ncookies; if (uio->uio_offset < 0) return (EINVAL); Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Wed Jan 24 17:52:06 2018 (r328345) +++ head/sys/ufs/ffs/ffs_softdep.c Wed Jan 24 17:58:48 2018 (r328346) @@ -2466,7 +2466,8 @@ softdep_mount(devvp, mp, fs, cred) struct ufsmount *ump; struct cg *cgp; struct buf *bp; - int i, error, cyl; + u_int cyl, i; + int error; sdp = malloc(sizeof(struct mount_softdeps), M_MOUNTDATA, M_WAITOK | M_ZERO); Modified: head/sys/ufs/ufs/ufs_dirhash.c ============================================================================== --- head/sys/ufs/ufs/ufs_dirhash.c Wed Jan 24 17:52:06 2018 (r328345) +++ head/sys/ufs/ufs/ufs_dirhash.c Wed Jan 24 17:58:48 2018 (r328346) @@ -349,7 +349,8 @@ ufsdirhash_build(struct inode *ip) struct direct *ep; struct vnode *vp; doff_t bmask, pos; - int dirblocks, i, j, memreqd, nblocks, narrays, nslots, slot; + u_int dirblocks, i, narrays, nblocks, nslots; + int j, memreqd, slot; /* Take care of a decreased sysctl value. */ while (ufs_dirhashmem > ufs_dirhashmaxmem) { Modified: head/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- head/sys/ufs/ufs/ufs_vnops.c Wed Jan 24 17:52:06 2018 (r328345) +++ head/sys/ufs/ufs/ufs_vnops.c Wed Jan 24 17:58:48 2018 (r328346) @@ -2170,7 +2170,7 @@ ufs_readdir(ap) off_t offset, startoffset; size_t readcnt, skipcnt; ssize_t startresid; - int ncookies; + u_int ncookies; int error; if (uio->uio_offset < 0)