Skip to content

Commit

Permalink
imap-send: simplify v_issue_imap_cmd() and get_cmd_result() using sta…
Browse files Browse the repository at this point in the history
…rts_with()

Use starts_with() instead of memcmp() to check if NUL-terminated
strings match prefixes.  This gets rid of some magic string length
constants.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Sep 2, 2014
1 parent 3918057 commit ba9b9e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions imap-send.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,
if (Verbose) {
if (imap->num_in_progress)
printf("(%d in progress) ", imap->num_in_progress);
if (memcmp(cmd->cmd, "LOGIN", 5))
if (!starts_with(cmd->cmd, "LOGIN"))
printf(">>> %s", buf);
else
printf(">>> %d LOGIN <user> <pass>\n", cmd->tag);
Expand Down Expand Up @@ -829,7 +829,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
} else /*if (!strcmp("BAD", arg))*/
resp = RESP_BAD;
fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n",
memcmp(cmdp->cmd, "LOGIN", 5) ?
!starts_with(cmdp->cmd, "LOGIN") ?
cmdp->cmd : "LOGIN <user> <pass>",
arg, cmd ? cmd : "");
}
Expand Down

0 comments on commit ba9b9e1

Please sign in to comment.