Skip to content

Commit ba9b9e1

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3918057 commit ba9b9e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

imap-send.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,
526526
if (Verbose) {
527527
if (imap->num_in_progress)
528528
printf("(%d in progress) ", imap->num_in_progress);
529-
if (memcmp(cmd->cmd, "LOGIN", 5))
529+
if (!starts_with(cmd->cmd, "LOGIN"))
530530
printf(">>> %s", buf);
531531
else
532532
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)
829829
} else /*if (!strcmp("BAD", arg))*/
830830
resp = RESP_BAD;
831831
fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n",
832-
memcmp(cmdp->cmd, "LOGIN", 5) ?
832+
!starts_with(cmdp->cmd, "LOGIN") ?
833833
cmdp->cmd : "LOGIN <user> <pass>",
834834
arg, cmd ? cmd : "");
835835
}

0 commit comments

Comments
 (0)