chiark / gitweb /
Replace x[v]asprintf with m[v]asprintf; libinn2 has one now
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 5 Dec 2015 18:36:45 +0000 (18:36 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 5 Dec 2015 18:36:45 +0000 (18:36 +0000)
cli.c
conn.c
defer.c
duct.c
help.c
infile.c
innduct.h
statemc.c

diff --git a/cli.c b/cli.c
index 531abdb1bd33a52be8350439a65c996fb1532864..b4938f42f7360a02aa8aebc71fe3d1dd211a4777 100644 (file)
--- 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 fa8316da46b47ae3e5f4a11cddfc533422382cd7..d20b342d4d22f79df61f9916337af9140e127eff 100644 (file)
--- 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 ba2b302abd46e14737c148c0cffecb5edbb14a94..99555deafcd574b6debf651466f77a9e612bec72 100644 (file)
--- 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 55b98772da9d9f533ead5e1a4754add0ad9ef7b9..8f7af2cc5e5f7248754c610e20c8702ebf09dbc7 100644 (file)
--- 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 8a47c3f4c16e2d0bacc8206ada933ae91d3e7c3b..46a784eb04d6817a469cdd9507536bfdadebb6cf 100644 (file)
--- 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;
 }
index 73e291b839dcc6b1c82e809d00e602ed956a8465..b8e01bcfc6f6ad200a19741f70bcfa14a2f7dd1a 100644 (file)
--- 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,
index 5a337cde6b5b55b8f3010c32dba444de1a8c35e6..08ab9bcde45a93f8b1fd18d2c486bcd35bb4fa3f 100644 (file)
--- 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);
index 3ce00f483a6d35e6e825ec538b832a1571778120..04f0a1d82628a2ab291d8cfe498a54eb1ad40e2d 100644 (file)
--- 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)"