summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruqs <uqs@FreeBSD.org>2015-12-29 11:24:41 +0000
committeruqs <uqs@FreeBSD.org>2015-12-29 11:24:41 +0000
commit11e0dd6c90098a31b4ee84a2af39114001952d67 (patch)
treeb886de70650826ff015bc0343d808ffba0f524fd
parentd4f2c120c09150a7012ceea91a74ea068aa5a9c6 (diff)
downloadFreeBSD-src-11e0dd6c90098a31b4ee84a2af39114001952d67.zip
FreeBSD-src-11e0dd6c90098a31b4ee84a2af39114001952d67.tar.gz
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
-rw-r--r--usr.bin/column/column.c2
-rw-r--r--usr.bin/locate/locate/util.c4
-rw-r--r--usr.bin/xargs/xargs.c4
-rw-r--r--usr.sbin/mountd/mountd.c2
-rw-r--r--usr.sbin/mpsutil/mps_cmd.c2
-rw-r--r--usr.sbin/rpc.lockd/lockd.c2
-rw-r--r--usr.sbin/rpc.statd/statd.c2
-rw-r--r--usr.sbin/rtsold/rtsold.c4
8 files changed, 11 insertions, 11 deletions
diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c
index b092deb..eb8ca66 100644
--- a/usr.bin/column/column.c
+++ b/usr.bin/column/column.c
@@ -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);
diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c
index 3ac69b5..9130e37 100644
--- a/usr.bin/locate/locate/util.c
+++ b/usr.bin/locate/locate/util.c
@@ -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;
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index c56ab60..955711c 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -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);
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 649c7d5f..535a3f7 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -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] = "*";
diff --git a/usr.sbin/mpsutil/mps_cmd.c b/usr.sbin/mpsutil/mps_cmd.c
index 876243f..24ed74e 100644
--- a/usr.sbin/mpsutil/mps_cmd.c
+++ b/usr.sbin/mpsutil/mps_cmd.c
@@ -486,7 +486,7 @@ mps_firmware_get(int fd, unsigned char **firmware, bool bios)
}
size = reply.ActualImageSize;
- *firmware = calloc(1, sizeof(char) * size);
+ *firmware = calloc(1, sizeof(unsigned char) * size);
if (*firmware == NULL) {
warn("calloc");
return (-1);
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index 4f1347e..88b19b7 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -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();
diff --git a/usr.sbin/rpc.statd/statd.c b/usr.sbin/rpc.statd/statd.c
index faa8513..256f58d 100644
--- a/usr.sbin/rpc.statd/statd.c
+++ b/usr.sbin/rpc.statd/statd.c
@@ -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();
diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c
index b251482..1482798 100644
--- a/usr.sbin/rtsold/rtsold.c
+++ b/usr.sbin/rtsold/rtsold.c
@@ -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);
OpenPOWER on IntegriCloud