From db28a17d552a0f73cb2cb34f46389a691522265c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 5 Dec 2015 18:36:45 +0000 Subject: [PATCH] Replace x[v]asprintf with m[v]asprintf; libinn2 has one now --- cli.c | 4 ++-- conn.c | 2 +- defer.c | 2 +- duct.c | 24 ++++++++++++------------ help.c | 8 ++++---- infile.c | 4 ++-- innduct.h | 4 ++-- statemc.c | 8 ++++---- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cli.c b/cli.c index 531abdb..b4938f4 100644 --- a/cli.c +++ b/cli.c @@ -425,8 +425,8 @@ static void dumpinfo(const CliCommand *c, FILE *f) { const XmitDetails *xd= &conn->xmitd[i]; char *dinfo; switch (xd->kind) { - case xk_Const: dinfo= xasprintf("Const"); break; - case xk_Artdata: dinfo= xasprintf("A%p", xd->info.sm_art); break; + case xk_Const: dinfo= masprintf("Const"); break; + case xk_Artdata: dinfo= masprintf("A%p", xd->info.sm_art); break; default: abort(); } diff --git a/conn.c b/conn.c index fa8316d..d20b342 100644 --- a/conn.c +++ b/conn.c @@ -100,7 +100,7 @@ void vconnfail(Conn *conn, const char *fmt, va_list al) { LIST_REMOVE(conns,conn); - char *m= xvasprintf(fmt,al); + char *m= mvasprintf(fmt,al); warn("C%d (now %d) connection failed " "(requeueing " RCI_TRIPLE_FMT_BASE "): %s", conn->fd, conns.count, RCI_TRIPLE_VALS_BASE(requeue, /*nothing*/), m); diff --git a/defer.c b/defer.c index ba2b302..99555de 100644 --- a/defer.c +++ b/defer.c @@ -105,7 +105,7 @@ void close_defer(void) { time_t now= xtime(); - char *backlog= xasprintf("%s_backlog_%lu.%lu", feedfile, + char *backlog= masprintf("%s_backlog_%lu.%lu", feedfile, (unsigned long)now, (unsigned long)stab.st_ino); if (link(path_defer, backlog)) diff --git a/duct.c b/duct.c index 55b9877..8f7af2c 100644 --- a/duct.c +++ b/duct.c @@ -189,7 +189,7 @@ void period(void) { static void vbadusage(const char *fmt, va_list al) NORET_PRINTF(1,0); static void vbadusage(const char *fmt, va_list al) { - char *m= xvasprintf(fmt,al); + char *m= mvasprintf(fmt,al); fprintf(stderr, "bad usage: %s\n" "say --help for help, or read the manpage\n", m); @@ -282,7 +282,7 @@ static void print_options(const Option *options, FILE *f) { const Option *o; for (o=options; o->shrt || o->lng; o++) { char shrt[2] = { o->shrt, 0 }; - char *optspec= xasprintf("%s%s%s%s%s", + char *optspec= masprintf("%s%s%s%s%s", o->shrt ? "-" : "", shrt, o->shrt && o->lng ? "|" : "", DELIMPERHAPS("--", o->lng)); @@ -491,19 +491,19 @@ int main(int argc, char **argv) { if (!feedfile) feedfile= sitename; if (!feedfile[0]) badusage("feed filename, if specified, must be nonempty"); if (path_ends_slash(feedfile)) - feedfile= xasprintf("%s%s", feedfile, sitename); + feedfile= masprintf("%s%s", feedfile, sitename); if (feedfile[0] != '/') - feedfile= xasprintf("%s/%s", innconf->pathoutgoing, feedfile); + feedfile= masprintf("%s/%s", innconf->pathoutgoing, feedfile); if (!path_cli) { path_cli_dir= "innduct"; } else if (!path_cli[0] || !strcmp(path_cli,"none")) { path_cli= 0; /* ok, don't then */ } else if (path_ends_slash(path_cli)) { - path_cli_dir= xasprintf("%.*s", strlen(path_cli)-1, path_cli); + path_cli_dir= masprintf("%.*s", strlen(path_cli)-1, path_cli); } if (path_cli_dir) - path_cli= xasprintf("%s/%s", path_cli_dir, sitename); + path_cli= masprintf("%s/%s", path_cli_dir, sitename); if (max_queue_per_ipf<0) max_queue_per_ipf= max_queue_per_conn * 2; @@ -524,11 +524,11 @@ int main(int argc, char **argv) { /* set things up */ - path_lock= xasprintf("%s_lock", feedfile); - path_flushing= xasprintf("%s_flushing", feedfile); - path_defer= xasprintf("%s_defer", feedfile); - path_dump= xasprintf("%s_dump", feedfile); - globpat_backlog= xasprintf("%s_backlog*", feedfile); + path_lock= masprintf("%s_lock", feedfile); + path_flushing= masprintf("%s_flushing", feedfile); + path_defer= masprintf("%s_defer", feedfile); + path_dump= masprintf("%s_dump", feedfile); + globpat_backlog= masprintf("%s_backlog*", feedfile); oop_source_sys *sysloop= oop_sys_new(); if (!sysloop) syscrash("could not create liboop event loop"); @@ -542,7 +542,7 @@ int main(int argc, char **argv) { close(i); } - logv_prefix= xasprintf("%s| ", sitename); + logv_prefix= masprintf("%s| ", sitename); if (interactive < 2) { openlog("innduct",LOG_NDELAY|LOG_PID,LOG_NEWS); logv_use_syslog= 1; diff --git a/help.c b/help.c index 8a47c3f..46a784e 100644 --- a/help.c +++ b/help.c @@ -49,7 +49,7 @@ static void logcore(int sysloglevel, const char *fmt, ...) { void logv(int sysloglevel, const char *pfx, int errnoval, const char *fmt, va_list al) { - char msgbuf[1024]; /* NB do not call xvasprintf here or you'll recurse */ + char msgbuf[1024]; /* NB do not call mvasprintf here or you'll recurse */ vsnprintf(msgbuf,sizeof(msgbuf), fmt,al); msgbuf[sizeof(msgbuf)-1]= 0; @@ -97,16 +97,16 @@ DEFLOG(dbg, "debug", LOG_DEBUG, -1) /*========== utility functions etc. ==========*/ -char *xvasprintf(const char *fmt, va_list al) { +char *mvasprintf(const char *fmt, va_list al) { char *str; int rc= vasprintf(&str,fmt,al); if (rc<0) sysdie("vasprintf(\"%s\",...) failed", fmt); return str; } -char *xasprintf(const char *fmt, ...) { +char *masprintf(const char *fmt, ...) { VA; - char *str= xvasprintf(fmt,al); + char *str= mvasprintf(fmt,al); va_end(al); return str; } diff --git a/infile.c b/infile.c index 73e291b..b8e01bc 100644 --- a/infile.c +++ b/infile.c @@ -327,12 +327,12 @@ void filepoll(void) { } char *dbg_report_ipf(InputFile *ipf) { - if (!ipf) return xasprintf("none"); + if (!ipf) return masprintf("none"); const char *slash= strrchr(ipf->path,'/'); const char *path= slash ? slash+1 : ipf->path; - return xasprintf("%p/%s:queue=%d,ip=%ld,autodef=%ld,off=%ld,fd=%d%s%s%s", + return masprintf("%p/%s:queue=%d,ip=%ld,autodef=%ld,off=%ld,fd=%d%s%s%s", ipf, path, ipf->queue.count, ipf->inprogress, ipf->autodefer, (long)ipf->offset, ipf->fd, diff --git a/innduct.h b/innduct.h index 5a337cd..08ab9bc 100644 --- a/innduct.h +++ b/innduct.h @@ -323,8 +323,8 @@ void dbg(const char *fmt, ...) PRINTF(1,2); void logv(int sysloglevel, const char *pfx, int errnoval, const char *fmt, va_list al) PRINTF(5,0); -char *xvasprintf(const char *fmt, va_list al) PRINTF(1,0); -char *xasprintf(const char *fmt, ...) PRINTF(1,2); +char *mvasprintf(const char *fmt, va_list al) PRINTF(1,0); +char *masprintf(const char *fmt, ...) PRINTF(1,2); int close_perhaps(int *fd); void xclose(int fd, const char *what, const char *what2); diff --git a/statemc.c b/statemc.c index 3ce00f4..04f0a1d 100644 --- a/statemc.c +++ b/statemc.c @@ -232,11 +232,11 @@ static void notice_processed_counts(Counts *counts, int completed, #define CNT(art,rc) (counts->results[art_##art][RC_##rc]) char *inprog= ipf_xtra && !completed - ? xasprintf(" inprogress=%ld", ipf_xtra->inprogress) - : xasprintf("%s",""); /* GCC produces a stupid warning for printf("") ! */ + ? masprintf(" inprogress=%ld", ipf_xtra->inprogress) + : masprintf("%s",""); /* GCC produces a stupid warning for printf("") ! */ char *autodefer= ipf_xtra && ipf_xtra->autodefer >= 0 - ? xasprintf(" autodeferred=%ld", ipf_xtra->autodefer) - : xasprintf("%s",""); + ? masprintf(" autodeferred=%ld", ipf_xtra->autodefer) + : masprintf("%s",""); notice("%s %s read=%d (+bl=%d,+err=%d)%s%s" " missing=%d offered=%d (ch=%d,nc=%d) accepted=%d (ch=%d,nc=%d)" -- 2.30.2