From: Richard Russon Date: Wed, 25 Jul 2018 13:23:50 +0000 (+0100) Subject: cppcheck X-Git-Tag: 2019-10-25~732^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=976a8d010db82e5e3961d3a0e8d7d68f4a7416af;p=neomutt cppcheck --- diff --git a/handler.c b/handler.c index b1435bd81..599d3d616 100644 --- a/handler.c +++ b/handler.c @@ -775,12 +775,10 @@ static int external_body_handler(struct Body *b, struct State *s) if (s->flags & (MUTT_DISPLAY | MUTT_PRINTING)) { char pretty_size[10]; - long size = 0; - char *length = mutt_param_get(&b->parameter, "length"); if (length) { - size = strtol(length, NULL, 10); + long size = strtol(length, NULL, 10); mutt_str_pretty_size(pretty_size, sizeof(pretty_size), size); if (expire != -1) { diff --git a/mutt_history.c b/mutt_history.c index a2fbad335..4db61ba71 100644 --- a/mutt_history.c +++ b/mutt_history.c @@ -102,14 +102,13 @@ static void history_entry(char *buf, size_t buflen, struct Menu *menu, int num) */ static void history_menu(char *buf, size_t buflen, char **matches, int match_count) { - struct Menu *menu = NULL; int done = 0; char helpstr[LONG_STRING]; char title[STRING]; snprintf(title, sizeof(title), _("History '%s'"), buf); - menu = mutt_menu_new(MENU_GENERIC); + struct Menu *menu = mutt_menu_new(MENU_GENERIC); menu->make_entry = history_entry; menu->title = title; menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_GENERIC, HistoryHelp); diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 1cb10be73..319019358 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -689,11 +689,10 @@ static char *data_object_to_tempfile(gpgme_data_t data, FILE **ret_fp) { int err; char tempf[PATH_MAX]; - FILE *fp = NULL; ssize_t nread = 0; mutt_mktemp(tempf, sizeof(tempf)); - fp = mutt_file_fopen(tempf, "w+"); + FILE *fp = mutt_file_fopen(tempf, "w+"); if (!fp) { mutt_perror(_("Can't create temporary file")); diff --git a/send.c b/send.c index e291373fe..0969ee078 100644 --- a/send.c +++ b/send.c @@ -773,10 +773,9 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags) */ static void add_references(struct ListHead *head, struct Envelope *e) { - struct ListHead *src = NULL; struct ListNode *np = NULL; - src = !STAILQ_EMPTY(&e->references) ? &e->references : &e->in_reply_to; + struct ListHead *src = !STAILQ_EMPTY(&e->references) ? &e->references : &e->in_reply_to; STAILQ_FOREACH(np, src, entries) { mutt_list_insert_tail(head, mutt_str_strdup(np->data)); diff --git a/test/config/address.c b/test/config/address.c index c47f5d92d..4550c9703 100644 --- a/test/config/address.c +++ b/test/config/address.c @@ -346,11 +346,10 @@ static bool test_reset(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); char *name = "Lemon"; - char *addr = NULL; mutt_buffer_reset(err); - addr = VarLemon ? VarLemon->mailbox : NULL; + char *addr = VarLemon ? VarLemon->mailbox : NULL; printf("Initial: %s = '%s'\n", name, NONULL(addr)); int rc = cs_str_string_set(cs, name, "hello@example.com", err); if (CSR_RESULT(rc) != CSR_SUCCESS) diff --git a/test/config/bool.c b/test/config/bool.c index 4bbeb8f60..085b247a6 100644 --- a/test/config/bool.c +++ b/test/config/bool.c @@ -583,7 +583,7 @@ static bool test_toggle(struct ConfigSet *cs, struct Buffer *err) { bool before = tests[i].before; bool after = tests[i].after; - printf("test %zd\n", i); + printf("test %zu\n", i); VarNectarine = before; mutt_buffer_reset(err); @@ -619,7 +619,7 @@ static bool test_toggle(struct ConfigSet *cs, struct Buffer *err) { bool before = tests[i].before; bool after = tests[i].after; - printf("test %zd\n", i); + printf("test %zu\n", i); VarNectarine = before; mutt_buffer_reset(err); diff --git a/test/config/mbtable.c b/test/config/mbtable.c index 89d8ee3a8..5c7d3fd81 100644 --- a/test/config/mbtable.c +++ b/test/config/mbtable.c @@ -362,11 +362,10 @@ static bool test_reset(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); char *name = "Lemon"; - char *mb = NULL; mutt_buffer_reset(err); - mb = VarLemon ? VarLemon->orig_str : NULL; + char *mb = VarLemon ? VarLemon->orig_str : NULL; printf("Initial: %s = '%s'\n", name, NONULL(mb)); int rc = cs_str_string_set(cs, name, "hello", err); if (CSR_RESULT(rc) != CSR_SUCCESS) diff --git a/test/config/quad.c b/test/config/quad.c index 732b00a02..68ad63b72 100644 --- a/test/config/quad.c +++ b/test/config/quad.c @@ -582,7 +582,7 @@ static bool test_toggle(struct ConfigSet *cs, struct Buffer *err) { char before = tests[i].before; char after = tests[i].after; - printf("test %zd\n", i); + printf("test %zu\n", i); VarNectarine = before; mutt_buffer_reset(err); diff --git a/test/config/regex.c b/test/config/regex.c index 9727c9057..660a79a82 100644 --- a/test/config/regex.c +++ b/test/config/regex.c @@ -402,11 +402,10 @@ static bool test_reset(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); char *name = "Mango"; - char *regex = NULL; mutt_buffer_reset(err); - regex = VarMango ? VarMango->pattern : NULL; + char *regex = VarMango ? VarMango->pattern : NULL; printf("Initial: %s = '%s'\n", name, NONULL(regex)); int rc = cs_str_string_set(cs, name, "hello.*", err); if (CSR_RESULT(rc) != CSR_SUCCESS)