mirror of
https://github.com/git/git.git
synced 2024-06-07 01:26:13 +02:00
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
This commit is contained in:
commit
d8800f630a
24
imap-send.c
24
imap-send.c
|
@ -68,9 +68,6 @@ static void imap_warn(const char *, ...);
|
||||||
|
|
||||||
static char *next_arg(char **);
|
static char *next_arg(char **);
|
||||||
|
|
||||||
__attribute__((format (printf, 3, 4)))
|
|
||||||
static int nfsnprintf(char *buf, int blen, const char *fmt, ...);
|
|
||||||
|
|
||||||
static int nfvasprintf(char **strp, const char *fmt, va_list ap)
|
static int nfvasprintf(char **strp, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -500,19 +497,6 @@ static char *next_arg(char **s)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((format (printf, 3, 4)))
|
|
||||||
static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
va_list va;
|
|
||||||
|
|
||||||
va_start(va, fmt);
|
|
||||||
if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >= (unsigned)blen)
|
|
||||||
BUG("buffer too small. Please report a bug.");
|
|
||||||
va_end(va);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct imap_cmd *issue_imap_cmd(struct imap_store *ctx,
|
static struct imap_cmd *issue_imap_cmd(struct imap_store *ctx,
|
||||||
struct imap_cmd_cb *cb,
|
struct imap_cmd_cb *cb,
|
||||||
const char *fmt, va_list ap)
|
const char *fmt, va_list ap)
|
||||||
|
@ -535,11 +519,11 @@ static struct imap_cmd *issue_imap_cmd(struct imap_store *ctx,
|
||||||
get_cmd_result(ctx, NULL);
|
get_cmd_result(ctx, NULL);
|
||||||
|
|
||||||
if (!cmd->cb.data)
|
if (!cmd->cb.data)
|
||||||
bufl = nfsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag, cmd->cmd);
|
bufl = xsnprintf(buf, sizeof(buf), "%d %s\r\n", cmd->tag, cmd->cmd);
|
||||||
else
|
else
|
||||||
bufl = nfsnprintf(buf, sizeof(buf), "%d %s{%d%s}\r\n",
|
bufl = xsnprintf(buf, sizeof(buf), "%d %s{%d%s}\r\n",
|
||||||
cmd->tag, cmd->cmd, cmd->cb.dlen,
|
cmd->tag, cmd->cmd, cmd->cb.dlen,
|
||||||
CAP(LITERALPLUS) ? "+" : "");
|
CAP(LITERALPLUS) ? "+" : "");
|
||||||
|
|
||||||
if (0 < verbosity) {
|
if (0 < verbosity) {
|
||||||
if (imap->num_in_progress)
|
if (imap->num_in_progress)
|
||||||
|
|
Loading…
Reference in New Issue