Skip to content

Commit

Permalink
tidy pointer definitions
Browse files Browse the repository at this point in the history
Separate multiple variable definitions which differ in type, e.g.

  char buf[16], *p = NULL, **pp = NULL;

becomes

  char buf[16];
  char *p = NULL;
  char **pp = NULL;
  • Loading branch information
flatcap committed May 16, 2019
1 parent 71e1042 commit 25de335
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 31 deletions.
3 changes: 2 additions & 1 deletion address/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *spec

if (strpbrk(value, specials))
{
char tmp[256], *pc = tmp;
char tmp[256];
char *pc = tmp;
size_t tmplen = sizeof(tmp) - 3;

*pc++ = '"';
Expand Down
9 changes: 6 additions & 3 deletions address/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ void mutt_grouplist_clear(struct GroupList *head)
if (!head)
return;

struct GroupNode *np = STAILQ_FIRST(head), *next = NULL;
struct GroupNode *np = STAILQ_FIRST(head);
struct GroupNode *next = NULL;
while (np)
{
group_remove(np->group);
Expand Down Expand Up @@ -156,7 +157,8 @@ void mutt_grouplist_destroy(struct GroupList *head)
if (!head)
return;

struct GroupNode *np = STAILQ_FIRST(head), *next = NULL;
struct GroupNode *np = STAILQ_FIRST(head);
struct GroupNode *next = NULL;
while (np)
{
next = STAILQ_NEXT(np, entries);
Expand All @@ -176,7 +178,8 @@ static void group_add_addrlist(struct Group *g, struct Address *a)
if (!g || !a)
return;

struct Address **p = NULL, *q = NULL;
struct Address **p = NULL;
struct Address *q = NULL;

for (p = &g->as; *p; p = &((*p)->next))
;
Expand Down
3 changes: 2 additions & 1 deletion alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ struct Address *mutt_get_address(struct Envelope *env, const char **pfxp)
void mutt_alias_create(struct Envelope *cur, struct Address *iaddr)
{
struct Alias *new = NULL;
char buf[1024], tmp[1024], prompt[128], *pc = NULL;
char buf[1024], tmp[1024], prompt[128];
char *pc = NULL;
char *err = NULL;
char fixed[1024];
struct Address *addr = NULL;
Expand Down
3 changes: 2 additions & 1 deletion email/parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ void mutt_param_free(struct ParameterList *p)
if (!p)
return;

struct Parameter *np = TAILQ_FIRST(p), *next = NULL;
struct Parameter *np = TAILQ_FIRST(p);
struct Parameter *next = NULL;
while (np)
{
next = TAILQ_NEXT(np, entries);
Expand Down
3 changes: 2 additions & 1 deletion email/tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ void driver_tags_free(struct TagHead *head)
if (!head)
return;

struct TagNode *np = STAILQ_FIRST(head), *next = NULL;
struct TagNode *np = STAILQ_FIRST(head);
struct TagNode *next = NULL;
while (np)
{
next = STAILQ_NEXT(np, entries);
Expand Down
3 changes: 2 additions & 1 deletion email/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ void url_free(struct Url **u)
if (!u || !*u)
return;

struct UrlQueryString *np = STAILQ_FIRST(&(*u)->query_strings), *next = NULL;
struct UrlQueryString *np = STAILQ_FIRST(&(*u)->query_strings);
struct UrlQueryString *next = NULL;
while (np)
{
next = STAILQ_NEXT(np, entries);
Expand Down
3 changes: 2 additions & 1 deletion flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ void mutt_emails_set_flag(struct Mailbox *m, struct EmailList *el, int flag, boo
*/
int mutt_thread_set_flag(struct Email *e, int flag, bool bf, bool subthread)
{
struct MuttThread *start = NULL, *cur = e->thread;
struct MuttThread *start = NULL;
struct MuttThread *cur = e->thread;

if ((C_Sort & SORT_MASK) != SORT_THREADS)
{
Expand Down
3 changes: 2 additions & 1 deletion handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ static bool is_mmnoask(const char *buf)
return false;

char *p = NULL;
char tmp[1024], *q = NULL;
char tmp[1024];
char *q = NULL;

if (mutt_str_strcmp(val, "1") == 0)
return true;
Expand Down
3 changes: 2 additions & 1 deletion hdrline.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
unsigned long data, MuttFormatFlags flags)
{
struct HdrFormatInfo *hfi = (struct HdrFormatInfo *) data;
char fmt[128], tmp[1024], *p = NULL, *tags = NULL;
char fmt[128], tmp[1024];
char *p = NULL, *tags = NULL;
int optional = (flags & MUTT_FORMAT_OPTIONAL);
int threads = ((C_Sort & SORT_MASK) == SORT_THREADS);
int is_index = (flags & MUTT_FORMAT_INDEX);
Expand Down
6 changes: 4 additions & 2 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,8 @@ static enum CommandResult parse_alternates(struct Buffer *buf, struct Buffer *s,
static enum CommandResult parse_attachments(struct Buffer *buf, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
char op, *category = NULL;
char op;
char *category = NULL;
struct ListHead *head = NULL;

mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
Expand Down Expand Up @@ -2280,7 +2281,8 @@ static enum CommandResult parse_unalternates(struct Buffer *buf, struct Buffer *
static enum CommandResult parse_unattachments(struct Buffer *buf, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
char op, *p = NULL;
char op;
char *p = NULL;
struct ListHead *head = NULL;

mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
Expand Down
3 changes: 2 additions & 1 deletion keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ const char *mutt_get_func(const struct Binding *bindings, int op)
*/
static void generic_tokenize_push_string(char *s, void (*generic_push)(int, int))
{
char *pp = NULL, *p = s + mutt_str_strlen(s) - 1;
char *pp = NULL;
char *p = s + mutt_str_strlen(s) - 1;
size_t l;
int i, op = OP_NULL;

Expand Down
3 changes: 2 additions & 1 deletion maildir/maildir.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ int maildir_mbox_check(struct Mailbox *m, int *index_hint)
int num_new = 0; /* number of new messages added to the mailbox */
bool flags_changed = false; /* message flags were changed in the mailbox */
struct Maildir *md = NULL; /* list of messages in the mailbox */
struct Maildir **last = NULL, *p = NULL;
struct Maildir **last = NULL;
struct Maildir *p = NULL;
int count = 0;
struct Hash *fnames = NULL; /* hash table for quickly looking up the base filename
for a maildir message */
Expand Down
9 changes: 6 additions & 3 deletions mutt/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void mutt_list_free(struct ListHead *h)
if (!h)
return;

struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
struct ListNode *np = STAILQ_FIRST(h);
struct ListNode *next = NULL;
while (np)
{
next = STAILQ_NEXT(np, entries);
Expand All @@ -140,7 +141,8 @@ void mutt_list_free_type(struct ListHead *h, list_free_t fn)
if (!h || !fn)
return;

struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
struct ListNode *np = STAILQ_FIRST(h);
struct ListNode *next = NULL;
while (np)
{
next = STAILQ_NEXT(np, entries);
Expand All @@ -162,7 +164,8 @@ void mutt_list_clear(struct ListHead *h)
if (!h)
return;

struct ListNode *np = STAILQ_FIRST(h), *next = NULL;
struct ListNode *np = STAILQ_FIRST(h);
struct ListNode *next = NULL;
while (np)
{
next = STAILQ_NEXT(np, entries);
Expand Down
12 changes: 8 additions & 4 deletions mutt_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ static bool is_visible(struct Email *e, struct Context *ctx)
*/
static bool need_display_subject(struct Context *ctx, struct Email *e)
{
struct MuttThread *tmp = NULL, *tree = e->thread;
struct MuttThread *tmp = NULL;
struct MuttThread *tree = e->thread;

/* if the user disabled subject hiding, display it */
if (!C_HideThreadSubject)
Expand Down Expand Up @@ -172,7 +173,8 @@ static void linearize_tree(struct Context *ctx)
*/
static void calculate_visibility(struct Context *ctx, int *max_depth)
{
struct MuttThread *tmp = NULL, *tree = ctx->tree;
struct MuttThread *tmp = NULL;
struct MuttThread *tree = ctx->tree;
int hide_top_missing = C_HideTopMissing && !C_HideMissing;
int hide_top_limited = C_HideTopLimited && !C_HideLimited;
int depth = 0;
Expand Down Expand Up @@ -290,7 +292,8 @@ void mutt_draw_tree(struct Context *ctx)
enum TreeChar corner = (C_Sort & SORT_REVERSE) ? MUTT_TREE_ULCORNER : MUTT_TREE_LLCORNER;
enum TreeChar vtee = (C_Sort & SORT_REVERSE) ? MUTT_TREE_BTEE : MUTT_TREE_TTEE;
int depth = 0, start_depth = 0, max_depth = 0, width = C_NarrowTree ? 1 : 2;
struct MuttThread *nextdisp = NULL, *pseudo = NULL, *parent = NULL, *tree = ctx->tree;
struct MuttThread *nextdisp = NULL, *pseudo = NULL, *parent = NULL;
struct MuttThread *tree = ctx->tree;

/* Do the visibility calculations and free the old thread chars.
* From now on we can simply ignore invisible subtrees */
Expand Down Expand Up @@ -533,7 +536,8 @@ static void pseudo_threads(struct Context *ctx)

struct Mailbox *m = ctx->mailbox;

struct MuttThread *tree = ctx->tree, *top = tree;
struct MuttThread *tree = ctx->tree;
struct MuttThread *top = tree;
struct MuttThread *tmp = NULL, *cur = NULL, *parent = NULL, *curchild = NULL,
*nextchild = NULL;

Expand Down
4 changes: 3 additions & 1 deletion muttlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,9 @@ void mutt_safe_path(char *buf, size_t buflen, struct Address *a)
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src,
format_t *callback, unsigned long data, MuttFormatFlags flags)
{
char prefix[128], tmp[1024], *cp = NULL, *wptr = buf, ch;
char prefix[128], tmp[1024];
char *cp = NULL, *wptr = buf;
char ch;
char if_str[128], else_str[128];
size_t wlen, count, len, wid;
FILE *fp_filter = NULL;
Expand Down
6 changes: 4 additions & 2 deletions ncrypt/smime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,8 @@ static char *smime_extract_signer_certificate(char *infile)
*/
void smime_class_invoke_import(char *infile, char *mailbox)
{
char *certfile = NULL, buf[256];
char *certfile = NULL;
char buf[256];
FILE *fp_smime_in = NULL;

FILE *fp_err = mutt_file_mkstemp();
Expand Down Expand Up @@ -1419,7 +1420,8 @@ void smime_class_invoke_import(char *infile, char *mailbox)
*/
int smime_class_verify_sender(struct Email *e)
{
char *mbox = NULL, *certfile = NULL, tempfname[PATH_MAX];
char *mbox = NULL, *certfile = NULL;
char tempfname[PATH_MAX];
int rc = 1;

mutt_mktemp(tempfname, sizeof(tempfname));
Expand Down
3 changes: 2 additions & 1 deletion nntp/nntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,8 @@ static int nntp_mbox_close(struct Mailbox *m)
if (!m)
return -1;

struct NntpMboxData *mdata = m->mdata, *tmp_mdata = NULL;
struct NntpMboxData *mdata = m->mdata;
struct NntpMboxData *tmp_mdata = NULL;
if (!mdata)
return 0;

Expand Down
3 changes: 2 additions & 1 deletion pgpewrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ static void print_usage(const char *progname)

int main(int argc, char **argv)
{
char **opts = NULL, **opt = NULL, *pfx = NULL;
char **opts = NULL, **opt = NULL;
char *pfx = NULL;

if (argc < 2)
{
Expand Down
3 changes: 2 additions & 1 deletion remailer.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ static struct Remailer **mix_type2_list(size_t *l)
char line[8192];
char *t = NULL;

struct Remailer **type2_list = NULL, *p = NULL;
struct Remailer **type2_list = NULL;
struct Remailer *p = NULL;
size_t slots = 0, used = 0;

int fd_null = open("/dev/null", O_RDWR);
Expand Down
3 changes: 2 additions & 1 deletion send.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ static int include_forward(struct Mailbox *m, struct Email *e, FILE *fp_out)
static int inline_forward_attachments(struct Mailbox *m, struct Email *cur,
struct Body ***plast, int *forwardq)
{
struct Body **last = *plast, *body = NULL;
struct Body **last = *plast;
struct Body *body = NULL;
struct Message *msg = NULL;
struct AttachCtx *actx = NULL;
int rc = 0, i;
Expand Down
6 changes: 4 additions & 2 deletions sendlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,8 @@ static int fold_one_header(FILE *fp, const char *tag, const char *value,
*/
static char *unfold_header(char *s)
{
char *p = s, *q = s;
char *p = s;
char *q = s;

while (p && (p[0] != '\0'))
{
Expand Down Expand Up @@ -2126,7 +2127,8 @@ static int write_one_header(FILE *fp, int pfxw, int max, int wraplen, const char
int mutt_write_one_header(FILE *fp, const char *tag, const char *value,
const char *pfx, int wraplen, CopyHeaderFlags chflags)
{
char *p = (char *) value, *last = NULL, *line = NULL;
char *p = (char *) value;
char *last = NULL, *line = NULL;
int max = 0, w, rc = -1;
int pfxw = mutt_strwidth(pfx);
char *v = mutt_str_strdup(value);
Expand Down

0 comments on commit 25de335

Please sign in to comment.