33818: fix types passed to sizeof detected by coverity as being wrong

This commit is contained in:
Oliver Kiddle 2014-11-30 23:19:55 +01:00
parent 49d6aace41
commit 0d4b548d1e
6 changed files with 15 additions and 9 deletions

View file

@ -1,3 +1,9 @@
2014-11-30 Oliver Kiddle <opk@zsh.org>
* 33818: Src/Builtins/sched.c, Src/Zle/complist.c,
Src/exec.c, Src/sort.c, Src/utils.c: fix types passed to sizeof
detected by coverity as being wrong
2014-11-28 Barton E. Schaefer <schaefer@brasslantern.com>
* 33819: Test/A06assign.ztst: regression tests for 33816

View file

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

View file

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

View file

@ -2299,13 +2299,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) {

View file

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

View file

@ -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);
@ -2955,7 +2955,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 {