Merge branch 'rk/commit-tree-make-F-verbatim' into maint
[gitweb.git] / imap-send.c
index 5c7e27a89459a9a63018cc469262c82891c6f7b7..b2d0b849bb20c88532dd2952a4a5ae94204ccad8 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "cache.h"
+#include "config.h"
 #include "credential.h"
 #include "exec_cmd.h"
 #include "run-command.h"
@@ -776,8 +777,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
                               offsetof(struct imap_cmd, next));
                        if (cmdp->cb.data) {
                                n = socket_write(&imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen);
-                               free(cmdp->cb.data);
-                               cmdp->cb.data = NULL;
+                               FREE_AND_NULL(cmdp->cb.data);
                                if (n != (int)cmdp->cb.dlen)
                                        return RESP_BAD;
                        } else if (cmdp->cb.cont) {
@@ -861,7 +861,7 @@ static char hexchar(unsigned int b)
        return b < 10 ? '0' + b : 'a' + (b - 10);
 }
 
-#define ENCODED_SIZE(n) (4*((n+2)/3))
+#define ENCODED_SIZE(n) (4 * DIV_ROUND_UP((n), 3))
 static char *cram(const char *challenge_64, const char *user, const char *pass)
 {
        int i, resp_len, encoded_len, decoded_len;
@@ -964,7 +964,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc, char *f
                int gai;
                char portstr[6];
 
-               snprintf(portstr, sizeof(portstr), "%d", srvc->port);
+               xsnprintf(portstr, sizeof(portstr), "%d", srvc->port);
 
                memset(&hints, 0, sizeof(hints));
                hints.ai_socktype = SOCK_STREAM;