diff options
author | pfg <pfg@FreeBSD.org> | 2017-03-15 15:33:32 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2017-03-15 15:33:32 +0000 |
commit | 466bdf25f48f01fdeff163183f0be4fa531d8545 (patch) | |
tree | a0682cafacc7bec83d40c16a438196cb0b1e1dab /lib/libc/gen/setmode.c | |
parent | e3e3811f31a3bd1bc1bc938e1194516e56b666db (diff) | |
download | FreeBSD-src-466bdf25f48f01fdeff163183f0be4fa531d8545.zip FreeBSD-src-466bdf25f48f01fdeff163183f0be4fa531d8545.tar.gz |
MFC r315095, r315096, r315097, r315187:
libc: small cleanups.
Rename nitems to numitems: it shares the anme with an existing macro in
sys/params.h. Also initialize the value later which avoids asigning the
value if we exit early.
Unsign setlen: it is local and will never be negative. Having one more bit
for growth is beneficial and it avoids a cast when it's going to be used
for allocation.
Remove unused initialization: "num" is properly defined before use.
Let calloc(3) do the multiplication.
Diffstat (limited to 'lib/libc/gen/setmode.c')
-rw-r--r-- | lib/libc/gen/setmode.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 7525567..5f90d0a 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -175,7 +175,7 @@ setmode(const char *p) mode_t mask, perm, permXbits, who; long perml; int equalopdone; - int setlen; + u_int setlen; if (!*p) { errno = EINVAL; @@ -190,7 +190,7 @@ setmode(const char *p) setlen = SET_LEN + 2; - if ((set = malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL) + if ((set = malloc(setlen * sizeof(BITCMD))) == NULL) return (NULL); saveset = set; endset = set + (setlen - 2); |