From: Ralph Corderoy Date: Sun, 24 Sep 2017 11:20:26 +0000 (+0100) Subject: Don't cast void pointer return value of malloc() et al. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b3bcb44d340fd017efac8bb31c3859dd91b24af3?ds=sidebyside Don't cast void pointer return value of malloc() et al. --- diff --git a/sbr/arglist.c b/sbr/arglist.c index 59d311b2..9425439a 100644 --- a/sbr/arglist.c +++ b/sbr/arglist.c @@ -50,7 +50,7 @@ argsplit(char *command, char **file, int *argp) } } - argvarray = (char **)mh_xmalloc(sizeof *argvarray * (MAXARGS + 5)); + argvarray = mh_xmalloc(sizeof *argvarray * (MAXARGS + 5)); /* * The simple case - no spaces or shell metacharacters diff --git a/sbr/brkstring.c b/sbr/brkstring.c index f0f43693..0f7c17fc 100644 --- a/sbr/brkstring.c +++ b/sbr/brkstring.c @@ -30,7 +30,7 @@ brkstring (char *str, char *brksep, char *brkterm) /* allocate initial space for pointers on first call */ if (!broken) { len = NUMBROKEN; - broken = (char **) mh_xmalloc ((size_t) (len * sizeof(*broken))); + broken = mh_xmalloc ((size_t) (len * sizeof(*broken))); } /* diff --git a/sbr/fmt_rfc2047.c b/sbr/fmt_rfc2047.c index db8bf785..8c799e14 100644 --- a/sbr/fmt_rfc2047.c +++ b/sbr/fmt_rfc2047.c @@ -229,7 +229,7 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen) if (use_iconv) { saveq = q; savedstlen = dstlen; - q = convbuf = (char *) mh_xmalloc(endofmime - startofmime); + q = convbuf = mh_xmalloc(endofmime - startofmime); } /* ADDCHR2 is for adding characters when q is or might be convbuf: * in this case on buffer-full we want to run iconv before returning. diff --git a/sbr/folder_read.c b/sbr/folder_read.c index 4edd8db6..1129bab0 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -59,7 +59,7 @@ folder_read (char *name, int lockflag) * name of the messages in this folder. */ len = NUMMSGS; - mi = (int *) mh_xmalloc ((size_t) (len * sizeof(*mi))); + mi = mh_xmalloc ((size_t) (len * sizeof(*mi))); while ((dp = readdir (dd))) { if ((msgnum = m_atoi (dp->d_name)) && msgnum > 0) { @@ -69,7 +69,7 @@ folder_read (char *name, int lockflag) */ if (mp->nummsg >= len) { len += NUMMSGS; - mi = (int *) mh_xrealloc (mi, (size_t) (len * sizeof(*mi))); + mi = mh_xrealloc (mi, (size_t) (len * sizeof(*mi))); } /* Check if this is the first message we've seen */ diff --git a/sbr/getarguments.c b/sbr/getarguments.c index 92a668e6..28cbe465 100644 --- a/sbr/getarguments.c +++ b/sbr/getarguments.c @@ -27,7 +27,7 @@ getarguments (char *invo_name, int argc, char **argv, int check_context) n++; } - arguments = (char **) mh_xmalloc ((argc + n) * sizeof(*arguments)); + arguments = mh_xmalloc ((argc + n) * sizeof(*arguments)); bp = arguments; /* Copy any arguments from profile/context */ diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index f5fa9a4e..a8377bf7 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -926,7 +926,7 @@ m_unknown(m_getfld_state_t *gstate, FILE *iob) * separator) or the last char (since the matchc would have found it * if it was a real delim). */ - s->pat_map = (char **) mh_xcalloc (256, sizeof(char *)); + s->pat_map = mh_xcalloc (256, sizeof(char *)); for (cp = s->fdelim + 1; cp < s->delimend; cp++ ) s->pat_map[(unsigned char)*cp] = cp; diff --git a/sbr/netsec.c b/sbr/netsec.c index 25b1f888..eb92dfcd 100644 --- a/sbr/netsec.c +++ b/sbr/netsec.c @@ -1085,7 +1085,7 @@ netsec_get_password(sasl_conn_t *conn, void *context, int id, * us room for a terminating NUL */ - *psecret = (sasl_secret_t *) malloc(sizeof(sasl_secret_t) + len); + *psecret = malloc(sizeof(sasl_secret_t) + len); if (! *psecret) return SASL_NOMEM; diff --git a/uip/annosbr.c b/uip/annosbr.c index d91ebf29..b9b725c2 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -96,7 +96,7 @@ annolist(char *file, char *comp, char *text, int number) * This buffer might need to be quite large, so we grow it as needed. */ - field = (char *)mh_xmalloc(field_size = 256); + field = mh_xmalloc(field_size = 256); /* * Get the length of the field name since we use it often. @@ -121,7 +121,7 @@ annolist(char *file, char *comp, char *text, int number) } if (++n >= field_size - 1) { - field = (char *) mh_xrealloc((void *)field, field_size += 256); + field = mh_xrealloc((void *)field, field_size += 256); cp = field + n - 1; } @@ -203,7 +203,7 @@ annosbr (int fd, char *file, char *comp, char *text, bool inplace, bool datesw, if ((fp = fdopen(fd, "r")) == NULL) adios(NULL, "unable to fdopen file."); - field = (char *)mh_xmalloc(field_size = 256); + field = mh_xmalloc(field_size = 256); } /* @@ -257,7 +257,7 @@ annosbr (int fd, char *file, char *comp, char *text, bool inplace, bool datesw, } if (++n >= field_size - 1) { - field = (char *) mh_xrealloc((void *)field, field_size *= 2); + field = mh_xrealloc((void *)field, field_size *= 2); cp = field + n - 1; } diff --git a/uip/flist.c b/uip/flist.c index 057192c3..e3c84a43 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -127,7 +127,7 @@ main(int argc, char **argv) /* allocate the initial space to record the folder names */ numfolders = 0; maxfolders = MAXFOLDERS; - foldersToDo = (char **) mh_xmalloc ((size_t) (maxfolders * sizeof(*foldersToDo))); + foldersToDo = mh_xmalloc ((size_t) (maxfolders * sizeof(*foldersToDo))); /* no sequences yet */ sequencesToDo = svector_create (0); @@ -203,7 +203,7 @@ main(int argc, char **argv) */ if (numfolders >= maxfolders) { maxfolders += MAXFOLDERS; - foldersToDo = (char **) mh_xrealloc (foldersToDo, + foldersToDo = mh_xrealloc (foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo))); } if (*cp == '+' || *cp == '@') { @@ -275,7 +275,7 @@ GetFolderOrder(void) AllocFolders(&orders, &nOrdersAlloced, nOrders + 1); o = &orders[nOrders++]; o->priority = priority++; - o->name = (char *) mh_xmalloc(p - s + 1); + o->name = mh_xmalloc(p - s + 1); strncpy(o->name, s, p - s); o->name[p - s] = 0; } else @@ -615,10 +615,10 @@ AllocFolders(struct Folder **f, int *nfa, int n) return; if (*f == NULL) { *nfa = 10; - *f = (struct Folder *) mh_xmalloc (*nfa * (sizeof(struct Folder))); + *f = mh_xmalloc (*nfa * (sizeof(struct Folder))); } else { *nfa *= 2; - *f = (struct Folder *) mh_xrealloc (*f, *nfa * (sizeof(struct Folder))); + *f = mh_xrealloc (*f, *nfa * (sizeof(struct Folder))); } } diff --git a/uip/sortm.c b/uip/sortm.c index 0b951bfe..249122d8 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -215,7 +215,7 @@ main (int argc, char **argv) /* * sort a list of pointers to our "messages to be sorted". */ - dlist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*dlist)); + dlist = mh_xmalloc ((nmsgs+1) * sizeof(*dlist)); for (i = 0; i < nmsgs; i++) dlist[i] = &smsgs[i]; dlist[nmsgs] = 0; @@ -243,7 +243,7 @@ main (int argc, char **argv) struct smsg **slist, **flist; struct smsg ***il, **fp, **dp; - slist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*slist)); + slist = mh_xmalloc ((nmsgs+1) * sizeof(*slist)); memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist)); qsort((char *)slist, nmsgs, sizeof(*slist), (qsort_comp) subsort); @@ -259,7 +259,7 @@ main (int argc, char **argv) * make up the final list, chronological but with * all the same subjects grouped together. */ - flist = (struct smsg **) mh_xmalloc ((nmsgs+1) * sizeof(*flist)); + flist = mh_xmalloc ((nmsgs+1) * sizeof(*flist)); fp = flist; for (dp = dlist; *dp;) { struct smsg **s = il[(*dp++)->s_msg]; diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 888160c4..10291617 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -865,7 +865,7 @@ buildfile (char **argp, char *file) while (argp[i]) i++; } - args = (char **) mh_xmalloc((i + 2) * sizeof(char *)); + args = mh_xmalloc((i + 2) * sizeof(char *)); /* * For backward compatibility, we need to add -build