imap-send: simplify v_issue_imap_cmd() and get_cmd_result() using starts_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>
René Scharfe committed
Aug 30, 2014 at 18:14 UTC
ba9b9e124276e5d27ecf0e7701df1dedab6375c8
1 file changed
+2
-2
imap-send.c
+2
-2
@@ -526,7 +526,7 @@ static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,
526
if (Verbose) {
527
if (imap->num_in_progress)
528
printf("(%d in progress) ", imap->num_in_progress);
529
- if (memcmp(cmd->cmd, "LOGIN", 5))
529
+ if (!starts_with(cmd->cmd, "LOGIN"))
530
printf(">>> %s", buf);
531
else
532
printf(">>> %d LOGIN <user> <pass>\n", cmd->tag);
@@ -829,7 +829,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
829
} else /*if (!strcmp("BAD", arg))*/
830
resp = RESP_BAD;
831
fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n",
832
- memcmp(cmdp->cmd, "LOGIN", 5) ?
832
+ !starts_with(cmdp->cmd, "LOGIN") ?
833
cmdp->cmd : "LOGIN <user> <pass>",
834
arg, cmd ? cmd : "");
835
}