From: Ralph Corderoy Date: Wed, 13 Sep 2017 10:09:42 +0000 (+0100) Subject: Remove casts of NULL to a data pointer. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b42bad5fdb20cefbafdcc2b3c90e191b4a231787?ds=inline;hp=96a2a03a1473522669e8848959c3aa380cf3d4eb Remove casts of NULL to a data pointer. 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. --- diff --git a/mts/smtp/smtp.c b/mts/smtp/smtp.c index f8478427..f9500bc6 100644 --- a/mts/smtp/smtp.c +++ b/mts/smtp/smtp.c @@ -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, ".")) { diff --git a/sbr/crawl_folders.c b/sbr/crawl_folders.c index e7ab5e37..ab90a4ca 100644 --- a/sbr/crawl_folders.c +++ b/sbr/crawl_folders.c @@ -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) { diff --git a/sbr/dtimep.l b/sbr/dtimep.l index 09a579f9..bd36c64a 100644 --- a/sbr/dtimep.l +++ b/sbr/dtimep.l @@ -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; \ diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index d25c3bbb..d8d64323 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -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; diff --git a/sbr/oauth.c b/sbr/oauth.c index 8a9893eb..aac6b43a 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -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; } diff --git a/sbr/read_switch_multiword_via_readline.c b/sbr/read_switch_multiword_via_readline.c index 3d6e8818..94a17df9 100644 --- a/sbr/read_switch_multiword_via_readline.c +++ b/sbr/read_switch_multiword_via_readline.c @@ -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); diff --git a/uip/new.c b/uip/new.c index c1c7999a..88d66ba1 100644 --- 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");