]> diplodocus.org Git - nmh/commitdiff
Don't cast void pointer return value of malloc() et al.
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 24 Sep 2017 11:20:26 +0000 (12:20 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 24 Sep 2017 11:37:37 +0000 (12:37 +0100)
sbr/arglist.c
sbr/brkstring.c
sbr/fmt_rfc2047.c
sbr/folder_read.c
sbr/getarguments.c
sbr/m_getfld.c
sbr/netsec.c
uip/annosbr.c
uip/flist.c
uip/sortm.c
uip/whatnowsbr.c

index 59d311b..9425439 100644 (file)
@@ -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
 
     /*
      * The simple case - no spaces or shell metacharacters
index f0f4369..0f7c17f 100644 (file)
@@ -30,7 +30,7 @@ brkstring (char *str, char *brksep, char *brkterm)
     /* allocate initial space for pointers on first call */
     if (!broken) {
        len = NUMBROKEN;
     /* 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)));
     }
 
     /*
     }
 
     /*
index db8bf78..8c799e1 100644 (file)
@@ -229,7 +229,7 @@ decode_rfc2047 (char *str, char *dst, size_t dstlen)
            if (use_iconv) {
                saveq = q;
                savedstlen = 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.
             }
 /* 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.
index 4edd8db..1129bab 100644 (file)
@@ -59,7 +59,7 @@ folder_read (char *name, int lockflag)
      * name of the messages in this folder.
      */
     len = NUMMSGS;
      * 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) {
 
     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;
             */
            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 */
            }
 
            /* Check if this is the first message we've seen */
index 92a668e..28cbe46 100644 (file)
@@ -27,7 +27,7 @@ getarguments (char *invo_name, int argc, char **argv, int check_context)
            n++;
     }
 
            n++;
     }
 
-    arguments = (char **) mh_xmalloc ((argc + n) * sizeof(*arguments));
+    arguments = mh_xmalloc ((argc + n) * sizeof(*arguments));
     bp = arguments;
 
     /* Copy any arguments from profile/context */
     bp = arguments;
 
     /* Copy any arguments from profile/context */
index f5fa9a4..a8377bf 100644 (file)
@@ -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).
      */
      * 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;
 
     for (cp = s->fdelim + 1; cp < s->delimend; cp++ )
        s->pat_map[(unsigned char)*cp] = cp;
index 25b1f88..eb92dfc 100644 (file)
@@ -1085,7 +1085,7 @@ netsec_get_password(sasl_conn_t *conn, void *context, int id,
      * us room for a terminating NUL
      */
 
      * 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;
 
     if (! *psecret)
        return SASL_NOMEM;
index d91ebf2..b9b725c 100644 (file)
@@ -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.
      */
 
      *  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.
 
     /*
      *  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) {
            }
 
            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;
            }
                
                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.");
 
        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) {
                }
 
                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;
                }
                
                    cp = field + n - 1;
                }
index 057192c..e3c84a4 100644 (file)
@@ -127,7 +127,7 @@ main(int argc, char **argv)
     /* allocate the initial space to record the folder names */
     numfolders = 0;
     maxfolders = MAXFOLDERS;
     /* 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);
 
     /* no sequences yet */
     sequencesToDo = svector_create (0);
@@ -203,7 +203,7 @@ main(int argc, char **argv)
             */
            if (numfolders >= maxfolders) {
                maxfolders += MAXFOLDERS;
             */
            if (numfolders >= maxfolders) {
                maxfolders += MAXFOLDERS;
-               foldersToDo = (char **) mh_xrealloc (foldersToDo,
+               foldersToDo = mh_xrealloc (foldersToDo,
                    (size_t) (maxfolders * sizeof(*foldersToDo)));
            }
            if (*cp == '+' || *cp == '@') {
                    (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++;
            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
            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;
        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;
     } else {
        *nfa *= 2;
-       *f = (struct Folder *) mh_xrealloc (*f, *nfa * (sizeof(struct Folder)));
+       *f = mh_xrealloc (*f, *nfa * (sizeof(struct Folder)));
     }
 }
 
     }
 }
 
index 0b951bf..249122d 100644 (file)
@@ -215,7 +215,7 @@ main (int argc, char **argv)
     /*
      * sort a list of pointers to our "messages to be sorted".
      */
     /*
      * 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;
     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;
 
        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);
 
        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.
         */
         * 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];
        fp = flist;
        for (dp = dlist; *dp;) {
            struct smsg **s = il[(*dp++)->s_msg];
index 888160c..1029161 100644 (file)
@@ -865,7 +865,7 @@ buildfile (char **argp, char *file)
        while (argp[i])
            i++;
     }
        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
 
     /*
      * For backward compatibility, we need to add -build