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
This commit is contained in:
Pedro F. Giffuni 2018-01-24 17:58:48 +00:00
parent 2128fefb75
commit a94a2945be
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328346
4 changed files with 6 additions and 4 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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) {

View file

@ -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)