From owner-svn-src-all@freebsd.org Tue Dec 29 11:24:43 2015 Return-Path: Delivered-To: svn-src-all@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 9DA85A55514; Tue, 29 Dec 2015 11:24:43 +0000 (UTC) (envelope-from uqs@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 62B001954; Tue, 29 Dec 2015 11:24:43 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBTBOg8F000773; Tue, 29 Dec 2015 11:24:42 GMT (envelope-from uqs@FreeBSD.org) Received: (from uqs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBTBOfOO000765; Tue, 29 Dec 2015 11:24:41 GMT (envelope-from uqs@FreeBSD.org) Message-Id: <201512291124.tBTBOfOO000765@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: uqs set sender to uqs@FreeBSD.org using -f From: Ulrich Spoerlein Date: Tue, 29 Dec 2015 11:24:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292864 - in head: usr.bin/column usr.bin/locate/locate usr.bin/xargs usr.sbin/mountd usr.sbin/mpsutil usr.sbin/rpc.lockd usr.sbin/rpc.statd usr.sbin/rtsold X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2015 11:24:43 -0000 Author: uqs Date: Tue Dec 29 11:24:41 2015 New Revision: 292864 URL: https://svnweb.freebsd.org/changeset/base/292864 Log: Fix type mismatches for malloc(3) and Co. This is rather pedantic, as for most architectures it holds that sizeof(type *) == sizeof(type **) Found by: clang static analyzer Reviewed by: ed Differential Revision: https://reviews.freebsd.org/D4722 Modified: head/usr.bin/column/column.c head/usr.bin/locate/locate/util.c head/usr.bin/xargs/xargs.c head/usr.sbin/mountd/mountd.c head/usr.sbin/mpsutil/mps_cmd.c head/usr.sbin/rpc.lockd/lockd.c head/usr.sbin/rpc.statd/statd.c head/usr.sbin/rtsold/rtsold.c Modified: head/usr.bin/column/column.c ============================================================================== --- head/usr.bin/column/column.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.bin/column/column.c Tue Dec 29 11:24:41 2015 (r292864) @@ -244,7 +244,7 @@ maketbl(void) p = NULL) if (++coloff == maxcols) { if (!(cols = realloc(cols, ((u_int)maxcols + - DEFCOLS) * sizeof(char *))) || + DEFCOLS) * sizeof(wchar_t *))) || !(lens = realloc(lens, ((u_int)maxcols + DEFCOLS) * sizeof(int)))) err(1, NULL); Modified: head/usr.bin/locate/locate/util.c ============================================================================== --- head/usr.bin/locate/locate/util.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.bin/locate/locate/util.c Tue Dec 29 11:24:41 2015 (r292864) @@ -93,7 +93,7 @@ colon(dbv, path, dot) char **pv; if (dbv == NULL) { - if ((dbv = malloc(sizeof(char **))) == NULL) + if ((dbv = malloc(sizeof(char *))) == NULL) err(1, "malloc"); *dbv = NULL; } @@ -123,7 +123,7 @@ colon(dbv, path, dot) *(p + slen) = '\0'; } /* increase dbv with element p */ - if ((dbv = realloc(dbv, sizeof(char **) * (vlen + 2))) + if ((dbv = realloc(dbv, sizeof(char *) * (vlen + 2))) == NULL) err(1, "realloc"); *(dbv + vlen) = p; Modified: head/usr.bin/xargs/xargs.c ============================================================================== --- head/usr.bin/xargs/xargs.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.bin/xargs/xargs.c Tue Dec 29 11:24:41 2015 (r292864) @@ -234,7 +234,7 @@ main(int argc, char *argv[]) * NULL. */ linelen = 1 + argc + nargs + 1; - if ((av = bxp = malloc(linelen * sizeof(char **))) == NULL) + if ((av = bxp = malloc(linelen * sizeof(char *))) == NULL) errx(1, "malloc failed"); /* @@ -471,7 +471,7 @@ prerun(int argc, char *argv[]) * Allocate memory to hold the argument list, and * a NULL at the tail. */ - tmp = malloc((argc + 1) * sizeof(char**)); + tmp = malloc((argc + 1) * sizeof(char *)); if (tmp == NULL) { warnx("malloc failed"); xexit(*argv, 1); Modified: head/usr.sbin/mountd/mountd.c ============================================================================== --- head/usr.sbin/mountd/mountd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/mountd/mountd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -422,7 +422,7 @@ main(int argc, char **argv) * list. */ if (nhosts == 0) { - hosts = malloc(sizeof(char**)); + hosts = malloc(sizeof(char *)); if (hosts == NULL) out_of_mem(); hosts[0] = "*"; Modified: head/usr.sbin/mpsutil/mps_cmd.c ============================================================================== --- head/usr.sbin/mpsutil/mps_cmd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/mpsutil/mps_cmd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char * } size = reply.ActualImageSize; - *firmware = calloc(1, sizeof(char) * size); + *firmware = calloc(1, sizeof(unsigned char) * size); if (*firmware == NULL) { warn("calloc"); return (-1); Modified: head/usr.sbin/rpc.lockd/lockd.c ============================================================================== --- head/usr.sbin/rpc.lockd/lockd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/rpc.lockd/lockd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -220,7 +220,7 @@ main(int argc, char **argv) * list. */ if (nhosts == 0) { - hosts = malloc(sizeof(char**)); + hosts = malloc(sizeof(char *)); if (hosts == NULL) out_of_mem(); Modified: head/usr.sbin/rpc.statd/statd.c ============================================================================== --- head/usr.sbin/rpc.statd/statd.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/rpc.statd/statd.c Tue Dec 29 11:24:41 2015 (r292864) @@ -150,7 +150,7 @@ main(int argc, char **argv) * list. */ if (nhosts == 0) { - hosts = malloc(sizeof(char**)); + hosts = malloc(sizeof(char *)); if (hosts == NULL) out_of_mem(); Modified: head/usr.sbin/rtsold/rtsold.c ============================================================================== --- head/usr.sbin/rtsold/rtsold.c Tue Dec 29 11:24:35 2015 (r292863) +++ head/usr.sbin/rtsold/rtsold.c Tue Dec 29 11:24:41 2015 (r292864) @@ -888,7 +888,7 @@ autoifprobe(void) warnmsg(LOG_WARNING, __func__, "multiple interfaces found"); - a = (char **)realloc(argv, (n + 1) * sizeof(char **)); + a = realloc(argv, (n + 1) * sizeof(char *)); if (a == NULL) { warnmsg(LOG_ERR, __func__, "realloc"); exit(1); @@ -903,7 +903,7 @@ autoifprobe(void) } if (n) { - a = (char **)realloc(argv, (n + 1) * sizeof(char **)); + a = realloc(argv, (n + 1) * sizeof(char *)); if (a == NULL) { warnmsg(LOG_ERR, __func__, "realloc"); exit(1);