From 0b0a2315aab77a3369ee2368bdd50e30d8e6339e Mon Sep 17 00:00:00 2001 From: Damien Riegel Date: Wed, 8 Nov 2017 10:44:19 -0500 Subject: [PATCH] conn: replace mutt_socket_write_d by mutt_socket_send_d Every occurrence of mutt_socket_write_d used -1 as buffer size. Wrap these calls in a new macro mutt_socket_send_d. Keep "write" for functions where the size is passed as parameter. --- imap/command.c | 4 ++-- mutt_socket.h | 1 + nntp.c | 12 ++++++------ pop_lib.c | 2 +- smtp.c | 6 +++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/imap/command.c b/imap/command.c index 41b5b1f63..9faf12bff 100644 --- a/imap/command.c +++ b/imap/command.c @@ -197,8 +197,8 @@ static int cmd_start(struct ImapData *idata, const char *cmdstr, int flags) if (idata->cmdbuf->dptr == idata->cmdbuf->data) return IMAP_CMD_BAD; - rc = mutt_socket_write_d(idata->conn, idata->cmdbuf->data, -1, - (flags & IMAP_CMD_PASS) ? IMAP_LOG_PASS : IMAP_LOG_CMD); + rc = mutt_socket_send_d(idata->conn, idata->cmdbuf->data, + (flags & IMAP_CMD_PASS) ? IMAP_LOG_PASS : IMAP_LOG_CMD); idata->cmdbuf->dptr = idata->cmdbuf->data; /* unidle when command queue is flushed */ diff --git a/mutt_socket.h b/mutt_socket.h index 6db07fb86..c55bf5708 100644 --- a/mutt_socket.h +++ b/mutt_socket.h @@ -46,6 +46,7 @@ struct Connection *mutt_conn_find(const struct Connection *start, const struct A #define mutt_socket_readln(A, B, C) mutt_socket_readln_d(A, B, C, MUTT_SOCK_LOG_CMD) #define mutt_socket_write(A, B) mutt_socket_write_d(A, B, -1, MUTT_SOCK_LOG_CMD) +#define mutt_socket_send_d(conn, buffer, level) mutt_socket_write_d(conn, buffer, -1, level) #define mutt_socket_write_n(A, B, C) mutt_socket_write_d(A, B, C, MUTT_SOCK_LOG_CMD) #endif /* _MUTT_SOCKET_H */ diff --git a/nntp.c b/nntp.c index 219ddb718..73238b22f 100644 --- a/nntp.c +++ b/nntp.c @@ -410,7 +410,7 @@ static int nntp_auth(struct NntpServer *nserv) if (DebugLevel < MUTT_SOCK_LOG_FULL) mutt_debug(MUTT_SOCK_LOG_CMD, "%d> AUTHINFO PASS *\n", conn->fd); snprintf(buf, sizeof(buf), "AUTHINFO PASS %s\r\n", conn->account.pass); - if (mutt_socket_write_d(conn, buf, -1, MUTT_SOCK_LOG_FULL) < 0 || + if (mutt_socket_send_d(conn, buf, MUTT_SOCK_LOG_FULL) < 0 || mutt_socket_readln(buf, sizeof(buf), conn) < 0) { break; @@ -501,7 +501,7 @@ static int nntp_auth(struct NntpServer *nserv) mutt_debug(MUTT_SOCK_LOG_CMD, "%d> sasl_data\n", conn->fd); } client_len = 0; - if (mutt_socket_write_d(conn, buf, -1, MUTT_SOCK_LOG_FULL) < 0 || + if (mutt_socket_send_d(conn, buf, MUTT_SOCK_LOG_FULL) < 0 || mutt_socket_readln_d(inbuf, sizeof(inbuf), conn, MUTT_SOCK_LOG_FULL) < 0) { break; @@ -1752,8 +1752,8 @@ int nntp_post(const char *msg) len++; buf[len] = '\0'; } - if (mutt_socket_write_d(nntp_data->nserv->conn, buf[1] == '.' ? buf : buf + 1, - -1, MUTT_SOCK_LOG_HDR) < 0) + if (mutt_socket_send_d(nntp_data->nserv->conn, + buf[1] == '.' ? buf : buf + 1, MUTT_SOCK_LOG_HDR) < 0) { mutt_file_fclose(&fp); return nntp_connect_error(nntp_data->nserv); @@ -1762,8 +1762,8 @@ int nntp_post(const char *msg) mutt_file_fclose(&fp); if ((buf[strlen(buf) - 1] != '\n' && - mutt_socket_write_d(nntp_data->nserv->conn, "\r\n", -1, MUTT_SOCK_LOG_HDR) < 0) || - mutt_socket_write_d(nntp_data->nserv->conn, ".\r\n", -1, MUTT_SOCK_LOG_HDR) < 0 || + mutt_socket_send_d(nntp_data->nserv->conn, "\r\n", MUTT_SOCK_LOG_HDR) < 0) || + mutt_socket_send_d(nntp_data->nserv->conn, ".\r\n", MUTT_SOCK_LOG_HDR) < 0 || mutt_socket_readln(buf, sizeof(buf), nntp_data->nserv->conn) < 0) return nntp_connect_error(nntp_data->nserv); if (buf[0] != '2') diff --git a/pop_lib.c b/pop_lib.c index b5ad8b105..298c28109 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -467,7 +467,7 @@ int pop_query_d(struct PopData *pop_data, char *buf, size_t buflen, char *msg) mutt_debug(MUTT_SOCK_LOG_CMD, "> %s", msg); } - mutt_socket_write_d(pop_data->conn, buf, -1, dbg); + mutt_socket_send_d(pop_data->conn, buf, dbg); c = strpbrk(buf, " \r\n"); if (c) diff --git a/smtp.c b/smtp.c index 8d4b2e5a4..528575639 100644 --- a/smtp.c +++ b/smtp.c @@ -210,20 +210,20 @@ static int smtp_data(struct Connection *conn, const char *msgfile) snprintf(buf + buflen - 1, sizeof(buf) - buflen + 1, "\r\n"); if (buf[0] == '.') { - if (mutt_socket_write_d(conn, ".", -1, MUTT_SOCK_LOG_FULL) == -1) + if (mutt_socket_send_d(conn, ".", MUTT_SOCK_LOG_FULL) == -1) { mutt_file_fclose(&fp); return SMTP_ERR_WRITE; } } - if (mutt_socket_write_d(conn, buf, -1, MUTT_SOCK_LOG_FULL) == -1) + if (mutt_socket_send_d(conn, buf, MUTT_SOCK_LOG_FULL) == -1) { mutt_file_fclose(&fp); return SMTP_ERR_WRITE; } mutt_progress_update(&progress, ftell(fp), -1); } - if (!term && buflen && mutt_socket_write_d(conn, "\r\n", -1, MUTT_SOCK_LOG_FULL) == -1) + if (!term && buflen && mutt_socket_send_d(conn, "\r\n", MUTT_SOCK_LOG_FULL) == -1) { mutt_file_fclose(&fp); return SMTP_ERR_WRITE; -- 2.40.0