From ba9b9e124276e5d27ecf0e7701df1dedab6375c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 30 Aug 2014 18:14:24 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- imap-send.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imap-send.c b/imap-send.c index 05a02b51ca..44fd5249e2 100644 --- a/imap-send.c +++ b/imap-send.c @@ -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 \n", cmd->tag); @@ -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 ", arg, cmd ? cmd : ""); } -- cgit v1.2.1