Skip to content

Commit d8800f6

Browse files
committed
Merge branch 'rs/imap-send-use-xsnprintf'
Code clean-up and duplicate reduction. * rs/imap-send-use-xsnprintf: imap-send: use xsnprintf to format command
2 parents d842e22 + 39bb692 commit d8800f6

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

imap-send.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ static void imap_warn(const char *, ...);
6868

6969
static char *next_arg(char **);
7070

71-
__attribute__((format (printf, 3, 4)))
72-
static int nfsnprintf(char *buf, int blen, const char *fmt, ...);
73-
7471
static int nfvasprintf(char **strp, const char *fmt, va_list ap)
7572
{
7673
int len;
@@ -500,19 +497,6 @@ static char *next_arg(char **s)
500497
return ret;
501498
}
502499

503-
__attribute__((format (printf, 3, 4)))
504-
static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
505-
{
506-
int ret;
507-
va_list va;
508-
509-
va_start(va, fmt);
510-
if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)
511-
BUG("buffer too small. Please report a bug.");
512-
va_end(va);
513-
return ret;
514-
}
515-
516500
static struct imap_cmd *issue_imap_cmd(struct imap_store *ctx,
517501
struct imap_cmd_cb *cb,
518502
const char *fmt, va_list ap)
@@ -535,11 +519,11 @@ static struct imap_cmd *issue_imap_cmd(struct imap_store *ctx,
535519
get_cmd_result(ctx, NULL);
536520

537521
if (!cmd->cb.data)
538-
bufl = nfsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag, cmd->cmd);
522+
bufl = xsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag, cmd->cmd);
539523
else
540-
bufl = nfsnprintf(buf, sizeof(buf), "%d %s{%d%s}\r\n",
541-
cmd->tag, cmd->cmd, cmd->cb.dlen,
542-
CAP(LITERALPLUS) ? "+" : "");
524+
bufl = xsnprintf(buf, sizeof(buf), "%d %s{%d%s}\r\n",
525+
cmd->tag, cmd->cmd, cmd->cb.dlen,
526+
CAP(LITERALPLUS) ? "+" : "");
543527

544528
if (0 < verbosity) {
545529
if (imap->num_in_progress)

0 commit comments

Comments
 (0)