]> diplodocus.org Git - nmh/commitdiff
Remove casts of NULL to a data pointer.
authorRalph Corderoy <ralph@inputplus.co.uk>
Wed, 13 Sep 2017 10:09:42 +0000 (11:09 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Wed, 13 Sep 2017 10:09:42 +0000 (11:09 +0100)
With a function prototype in place stating a parameter is a foo pointer,
where foo is data, not a function, then `NULL' suffices so the cast to
foo pointer is redundant.  If the function parameter is retrieved with
va_arg(3) then the pointer passed must be the retrieved type, e.g.
concat()'s arguments are fetched as char pointer and so it should be
called as `concat("foo", (char *)0)'.  Using NULL is incorrect, though
NULL could be used instead of 0 but still needs casting.  However, the
source doesn't bother getting this right and just passes NULL in most
cases so make the few match.  Most of those changed were passing NULL
cast to a void pointer.

mts/smtp/smtp.c
sbr/crawl_folders.c
sbr/dtimep.l
sbr/fmt_compile.c
sbr/oauth.c
sbr/read_switch_multiword_via_readline.c
uip/new.c

index f8478427a35a2f8c745971446c3ccaa5af90f549..f9500bc625230caf3eca92bba645301b671fc694 100644 (file)
@@ -540,7 +540,7 @@ sm_wtxt (char *buffer, int len)
 int
 sm_wtend (void)
 {
-    if (sm_wstream ((char *) NULL, 0) == NOTOK)
+    if (sm_wstream(NULL, 0) == NOTOK)
        return RP_BHST;
 
     switch (smtalk (SM_DOT + 3 * sm_addrs, ".")) {
index e7ab5e372424bf609b95df11511fbf53244c1a8e..ab90a4caa1477b5a289a38d9941c983ed101d9e5 100644 (file)
@@ -64,7 +64,7 @@ add_children (char *name, struct crawl_context *crawl)
     if (strcmp (name, ".") == 0) {
        prefix = mh_xstrdup("");
     } else {
-       prefix = concat (name, "/", (void *)NULL);
+       prefix = concat(name, "/", NULL);
     }
 
     while ((dp = readdir (dd))) {
@@ -81,7 +81,7 @@ add_children (char *name, struct crawl_context *crawl)
        if (!strcmp (dp->d_name, ".") || !strcmp (dp->d_name, "..")) {
            continue;
        }
-       child = concat (prefix, dp->d_name, (void *)NULL);
+       child = concat(prefix, dp->d_name, NULL);
        /* If we have no d_type or d_type is DT_LNK or DT_UNKNOWN, stat the
         * child to see what it is. */
        if (child_is_folder == -1) {
index 09a579f9991afcd393e56b45913719c07bd74f28..bd36c64aaf7b459d373f579811a0090cbf67d5cf 100644 (file)
@@ -45,7 +45,7 @@
 
 #define yyterminate() (void)yy_delete_buffer(lexhandle); \
   if(!(tw.tw_flags & TW_SUCC)) { \
-    return (struct tws *)NULL; \
+    return NULL; \
   } \
   if(tw.tw_year < 1970) \
     tw.tw_year += 1900; \
index d25c3bbb35fcb1301f649586f678eb9b10393fe2..d8d64323fdf77f75bd92ccf12289579859ff10ab 100644 (file)
@@ -856,7 +856,7 @@ do_if(char *sp)
 {
     char *cp = sp;
     struct format *fexpr,
-                          *fif = (struct format *)NULL;
+        *fif = NULL;
     int c = '<';
 
     for (;;) {
@@ -897,7 +897,7 @@ do_if(char *sp)
            fif = fp;                   /* loc of GOTO */
            fexpr->f_skip = next_fp - fexpr;
 
-           fexpr = (struct format *)NULL;/* no extra ENDIF */
+           fexpr = NULL;               /* no extra ENDIF */
 
            cp = compile (cp);          /* compile ELSE stmts */
            fif->f_skip = next_fp - fif;
index 8a9893ebb1e12846781cb537c1cd327a238ee3f7..aac6b43a693a6e53d4cfc40e0db431c511a79ef4 100755 (executable)
@@ -226,7 +226,7 @@ set_err_http(mh_oauth_ctx *ctx, const struct curl_ctx *curl_ctx)
     if (curl_ctx->res_len > 0
         && is_json(curl_ctx->content_type)
         && get_json_strings(curl_ctx->res_body, curl_ctx->res_len, ctx->log,
-                            "error", &error, (void *)NULL)
+                            "error", &error, NULL)
         && error != NULL) {
         if (strcmp(error, "invalid_grant") == 0) {
             code = MH_OAUTH_BAD_GRANT;
@@ -386,7 +386,7 @@ mh_oauth_get_authorize_url(mh_oauth_ctx *ctx)
                         "client_id", ctx->svc.client_id,
                         "redirect_uri", ctx->svc.redirect_uri,
                         "scope", ctx->svc.scope,
-                        (void *)NULL)) {
+                        NULL)) {
         set_err(ctx, MH_OAUTH_REQUEST_INIT);
         return NULL;
     }
@@ -410,7 +410,7 @@ cred_from_response(mh_oauth_cred *cred, const char *content_type,
                           "access_token", &access_token,
                           "expires_in", &expires_in,
                           "refresh_token", &refresh_token,
-                          (void *)NULL)) {
+                          NULL)) {
         goto out;
     }
 
@@ -498,7 +498,7 @@ mh_oauth_authorize(const char *code, mh_oauth_ctx *ctx)
                         "redirect_uri", ctx->svc.redirect_uri,
                         "client_id", ctx->svc.client_id,
                         "client_secret", ctx->svc.client_secret,
-                        (void *)NULL)) {
+                        NULL)) {
         set_err(ctx, MH_OAUTH_REQUEST_INIT);
         return NULL;
     }
@@ -531,7 +531,7 @@ mh_oauth_refresh(mh_oauth_cred *cred)
                         "refresh_token", cred->refresh_token,
                         "client_id", ctx->svc.client_id,
                         "client_secret", ctx->svc.client_secret,
-                        (void *)NULL)) {
+                        NULL)) {
         set_err(ctx, MH_OAUTH_REQUEST_INIT);
         return false;
     }
index 3d6e88184368d2ae79d9b0244122d870c3e6a197..94a17df96f1f7dbabe3fe53c79ffd651ff138b2d 100644 (file)
@@ -79,7 +79,7 @@ nmh_completion(const char *text, int start, int end)
 
     NMH_UNUSED (end);
 
-    matches = (char **) NULL;
+    matches = NULL;
 
     if (start == 0)
        matches = rl_completion_matches(text, nmh_command_generator);
index c1c7999a2b3b285f4339aed231d9827be87fdb3d..88d66ba1bd06a69ac0252cabd7de7c1fb6c2c629 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -114,7 +114,7 @@ get_msgnums(char *folder, char *sequences[])
        return NULL;
 
     /* get filename of sequence file */
-    seqfile = concat(m_maildir(folder), "/", mh_seq, (void *)NULL);
+    seqfile = concat(m_maildir(folder), "/", mh_seq, NULL);
 
     if (seqfile == NULL)
        return NULL;
@@ -150,7 +150,7 @@ get_msgnums(char *folder, char *sequences[])
                        } else {
                            old_msgnums = msgnums;
                            msgnums = concat(old_msgnums, " ",
-                                            this_msgnums, (void *)NULL);
+                                            this_msgnums, NULL);
                            free(old_msgnums);
                            free(this_msgnums);
                        }
@@ -165,7 +165,7 @@ get_msgnums(char *folder, char *sequences[])
                        } else {
                            old_msgnums = msgnums;
                            msgnums = concat(old_msgnums, " ",
-                                            this_msgnums, (void *)NULL);
+                                            this_msgnums, NULL);
                            free(old_msgnums);
                            free(this_msgnums);
                        }
@@ -395,7 +395,7 @@ doit(char *cur, char *folders, char *sequences[])
 
            /* TODO: Split enough of scan.c out so that we can call it here. */
            command = concat("scan +", node->n_name, " ", sequences_s,
-                            (void *)NULL);
+                            NULL);
            status = system(command);
            if (! WIFEXITED (status)) {
                adios (command, "system");