Re: [PATCH] imap-send: simplify v_issue_imap_cmd() and get_cmd_result() using starts_with()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 02.09.2014 um 21:23 schrieb Junio C Hamano:
René Scharfe <l.s.r@xxxxxx> writes:

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@xxxxxx>
---
  imap-send.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 524fbab..b079a0d 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -802,7 +802,10 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
  				resp = DRV_OK;
  			else {
  				if (!strcmp("NO", arg)) {
-					if (cmdp->cb.create && cmd && (cmdp->cb.trycreate || !memcmp(cmd, "[TRYCREATE]", 11))) { /* SELECT, APPEND or UID COPY */
+					if (cmdp->cb.create && cmd &&
+					    (cmdp->cb.trycreate ||
+					     starts_with(cmd, "[TRYCREATE]"))) {
+						/* SELECT, APPEND or UID COPY */
  						p = strchr(cmdp->cmd, '"');
  						if (!issue_imap_cmd(ctx, NULL, "CREATE \"%.*s\"", (int)(strchr(p + 1, '"') - p + 1), p)) {
  							resp = RESP_BAD;

Do we want this hunk, given that it will disappear with the
tf/imap-send-create topic at e0d8e308 (imap-send: create target
mailbox if it is missing, 2014-08-01)?

In that case it's unnecessary; apparently I overlooked the conflicting hunk while preparing the patch for sending.

René
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]