Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: minor coverity issues with sizeof parameters
- X-seq: zsh-workers 33818
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: minor coverity issues with sizeof parameters
- Date: Fri, 28 Nov 2014 20:01:33 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1417201295; bh=y2wVxtmrjZ3Z0i9xYEjT+1JOPdtd4R5qikRe0ldRka4=; h=From:To:Subject:Date:From:Subject; b=o6k/nNS8lGjhpnNkVhBJ1914N27iI6na8F6iZr97uO8uAaOXsNhR1PM98Gl+JDXECPJ2WWSP5aNolysgwvUNMmqdj63bSUqtWCrxNICBqJOCzAwFcZeA74JKQpwoqXTOK50ZjmQAz22ELcbM/rKxSNyQmwjLcnTG7ZFXOBW62HX3r9QToPzD7550Bx1gJ2CS+/0SdhnKi9sT6nSkLSBxXERID/9/MYmqBnPlMfdDjQCl34+hJ2uyXw7ZSiWZHVCs4+SGGClDPj5cmF1KQKb4dtnGebbD5QtB6U5ZGv8D4g+uGAgJHLRckDH0kqFOww3EJXOsRpeOW4b9gU8L4yUP+A==
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=IsyNanOh79Tt9Tyd9XghKHWCRI0PaJLlyYUzgRVX/tVXUrHpaWTec8XuFN2jjmJmvhJpjnrqzK7mD+I3DUXGEOotIFfmST3YFITx13LfUl1lZY4yy21s3uKlQ6xDcbB151I3NT/0d2D7VEHHdqQZf/61ikBJPUZ17/cALhzWBxBuXEpGl/CeaDtAkg/5bQWIIddiOKvtq8GKwh+wjsyYyA7U2IJn+ctRrFeLv0PaOedpHFqmH9qKVhBmpHrjHGv5uyEM5sh8D0NeXXLVIK42PBwp5WobMBr+Gr32Y16fK5brEoD3AwgN1iZPzjZDtMlZTFagiZ5Zz/83bINnBVEu7w==;
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Coverity complains in a few cases where we do something like:
char **arr = malloc(x * sizeof(char **));
It should really be sizeof(char *). It doesn't really matter because a
char * is the same size as a char ** on any existing system I've ever
encountered. This patch fixes them.
If anyone is interested in helping to go through the coverity results,
sign up at scan.coverity.com, search for the zsh project and request
access.
Oliver
diff --git a/Src/Builtins/sched.c b/Src/Builtins/sched.c
index c1cc983..bcf7661 100644
--- a/Src/Builtins/sched.c
+++ b/Src/Builtins/sched.c
@@ -346,7 +346,7 @@ schedgetfn(UNUSED(Param pm))
for (i = 0, sch = schedcmds; sch; sch = sch->next, i++)
;
- aptr = ret = zhalloc(sizeof(char **) * (i+1));
+ aptr = ret = zhalloc(sizeof(char *) * (i+1));
for (sch = schedcmds; sch; sch = sch->next, aptr++) {
char tbuf[40], *flagstr;
time_t t;
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 2e1a527..c129940 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2059,8 +2059,8 @@ complistmatches(UNUSED(Hookdef dummy), Chdata dat)
i = zterm_columns * listdat.nlines;
free(mtab);
- mtab = (Cmatch **) zalloc(i * sizeof(Cmatch **));
- memset(mtab, 0, i * sizeof(Cmatch **));
+ mtab = (Cmatch **) zalloc(i * sizeof(Cmatch *));
+ memset(mtab, 0, i * sizeof(Cmatch *));
free(mgtab);
mgtab = (Cmgroup *) zalloc(i * sizeof(Cmgroup));
#ifdef DEBUG
diff --git a/Src/exec.c b/Src/exec.c
index 02a8fe3..79fffa0 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2291,13 +2291,13 @@ addvars(Estate state, Wordcode pc, int addflags)
continue;
}
if (vl) {
- ptr = arr = (char **) zalloc(sizeof(char **) *
+ ptr = arr = (char **) zalloc(sizeof(char *) *
(countlinknodes(vl) + 1));
while (nonempty(vl))
*ptr++ = ztrdup((char *) ugetnode(vl));
} else
- ptr = arr = (char **) zalloc(sizeof(char **));
+ ptr = arr = (char **) zalloc(sizeof(char *));
*ptr = NULL;
if (xtr) {
diff --git a/Src/sort.c b/Src/sort.c
index 3d00bb5..92ee1c0 100644
--- a/Src/sort.c
+++ b/Src/sort.c
@@ -368,7 +368,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp)
sortdir = (sortwhat & SORTIT_BACKWARDS) ? -1 : 1;
sortnumeric = (sortwhat & SORTIT_NUMERICALLY) ? 1 : 0;
- qsort(sortptrarr, nsort, sizeof(SortElt *), eltpcmp);
+ qsort(sortptrarr, nsort, sizeof(SortElt), eltpcmp);
sortnumeric = oldsortnumeric;
sortdir = oldsortdir;
diff --git a/Src/utils.c b/Src/utils.c
index c6e7aed..34fc91a 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -693,12 +693,12 @@ slashsplit(char *s)
int t0;
if (!*s)
- return (char **) zshcalloc(sizeof(char **));
+ return (char **) zshcalloc(sizeof(char *));
for (t = s, t0 = 0; *t; t++)
if (*t == '/')
t0++;
- q = r = (char **) zalloc(sizeof(char **) * (t0 + 2));
+ q = r = (char **) zalloc(sizeof(char *) * (t0 + 2));
while ((t = strchr(s, '/'))) {
*q++ = ztrduppfx(s, t - s);
@@ -2953,7 +2953,7 @@ colonsplit(char *s, int uniq)
for (t = s, ct = 0; *t; t++) /* count number of colons */
if (*t == ':')
ct++;
- ptr = ret = (char **) zalloc(sizeof(char **) * (ct + 2));
+ ptr = ret = (char **) zalloc(sizeof(char *) * (ct + 2));
t = s;
do {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author