aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-10 20:27:18 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-10 20:40:37 +0300
commit3bf61e7ab82244cdeb00c6ba6d602d3cad9b64d4 (patch)
tree65bcc3fc7425af543a9f3a393abe5cdc3e11112c
parent212825a21d8fa8ec90d7c5b9a1460f845958d445 (diff)
downloadwydawca-3bf61e7ab82244cdeb00c6ba6d602d3cad9b64d4.tar.gz
wydawca-3bf61e7ab82244cdeb00c6ba6d602d3cad9b64d4.tar.bz2
Remove vasprintf module.
-rw-r--r--gnulib.modules3
-rw-r--r--src/lock.c12
-rw-r--r--src/report.c5
-rw-r--r--src/timer.c18
-rw-r--r--src/triplet.c24
5 files changed, 40 insertions, 22 deletions
diff --git a/gnulib.modules b/gnulib.modules
index f274913..9446f4b 100644
--- a/gnulib.modules
+++ b/gnulib.modules
@@ -1,6 +1,5 @@
xalloc
c-ctype
-fnmatch
obstack
progname
getline
@@ -9,7 +8,5 @@ save-cwd
backupfile
strerror
sysexits
-vasprintf
inttostr
-strftime
xgethostname
diff --git a/src/lock.c b/src/lock.c
index 1c3a657..bc8505c 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -178,6 +178,7 @@ int
wydawca_lock (const char *lockname)
{
char *tempname = NULL;
+ size_t size = 0;
int rc;
if (!enable_locking)
@@ -185,10 +186,10 @@ wydawca_lock (const char *lockname)
expire_stale_lock (lockname);
/* build the NFS hitching-post to the lock file */
- asprintf (&tempname, "%s.%lu.%lu.%s",
- lockname,
- (unsigned long) getpid (),
- (unsigned long) time (NULL), xgethostname ());
+ grecs_asprintf (&tempname, &size, "%s.%lu.%lu.%s",
+ lockname,
+ (unsigned long) getpid (),
+ (unsigned long) time (NULL), xgethostname ());
if (!tempname)
return LOCK_FAILURE;
if (lock_timeout)
@@ -235,8 +236,9 @@ char *
wydawca_lockname (const char *tag)
{
char *lockname = NULL;
+ size_t size = 0;
char *tagname = fix_tagname (tag);
- asprintf (&lockname, "%s/LCK.%s", lockdir, tagname);
+ grecs_asprintf (&lockname, &size, "%s/LCK.%s", lockdir, tagname);
if (!lockname)
xalloc_die ();
free (tagname);
diff --git a/src/report.c b/src/report.c
index 84a9592..b09c7c7 100644
--- a/src/report.c
+++ b/src/report.c
@@ -34,14 +34,17 @@ report_add (const char *fmt, ...)
{
va_list ap;
char *str = NULL;
+ size_t size = 0;
+
va_start (ap, fmt);
- vasprintf (&str, fmt, ap);
+ grecs_vasprintf (&str, &size, fmt, ap);
va_end (ap);
if (str)
{
obstack_grow (&report_stk, str, strlen (str));
obstack_1grow (&report_stk, '\n');
}
+ free (str);
}
void
diff --git a/src/timer.c b/src/timer.c
index 71f63f9..1634462 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -159,8 +159,9 @@ char *
timer_format_time (double t)
{
char *str = NULL;
+ size_t size = 0;
if (t < 600)
- asprintf (&str, "%0.3f", t);
+ grecs_asprintf (&str, &size, "%0.3f", t);
else
{
long int s, m, h, d;
@@ -174,12 +175,14 @@ timer_format_time (double t)
s -= m * 60;
if (d)
- asprintf (&str, "%ld+%02ld:%02ld:%02ld", d, h, m, s);
+ grecs_asprintf (&str, &size, "%ld+%02ld:%02ld:%02ld", d, h, m, s);
else if (h)
- asprintf (&str, "%02ld:%02ld:%02ld", h, m, s);
+ grecs_asprintf (&str, &size, "%02ld:%02ld:%02ld", h, m, s);
else
- asprintf (&str, "%02ld:%02ld", m, s);
+ grecs_asprintf (&str, &size, "%02ld:%02ld", m, s);
}
+ if (!str)
+ xalloc_die ();
return str;
}
@@ -203,7 +206,12 @@ _fill_meta (void *sym, void *data)
#define CREATE_DEF(arg) \
if (tp->num) \
{ \
- asprintf (&tp->def->kw, "timer:%s:%s", slot->name, #arg); \
+ char *buf = NULL; \
+ size_t size = 0; \
+ grecs_asprintf (&buf, &size, "timer:%s:%s", slot->name, #arg); \
+ if (!buf) \
+ xalloc_die (); \
+ tp->def->kw = buf; \
tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \
tp->def->value = tp->def->storage; \
tp->def->expand = NULL; \
diff --git a/src/triplet.c b/src/triplet.c
index 6bd9e6a..9f051db 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -350,7 +350,8 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
char *user_name;
char *group_name;
struct tm *tm;
- char *buf;
+ char *buf = NULL;
+ size_t size = 0;
if (!info->name)
return 1;
@@ -385,10 +386,12 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
if (pad > ugswidth)
ugswidth = pad;
- asprintf (&buf,
- "%s %s %s %*s %s %s",
- modes, user_name, group_name, ugswidth - pad + slen, sptr,
- timebuf, info->name);
+ if (grecs_asprintf (&buf, &size,
+ "%s %s %s %*s %s %s",
+ modes, user_name, group_name, ugswidth - pad + slen,
+ sptr,
+ timebuf, info->name))
+ xalloc_die ();
*pret = buf;
return 0;
}
@@ -545,8 +548,10 @@ expand_email_user (struct metadef *def, void *data)
struct file_triplet *trp = data;
if (trp->uploader)
{
- asprintf (&def->storage, "\"%s\" <%s>",
- trp->uploader->realname, trp->uploader->email);
+ size_t size = 0;
+ if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>",
+ trp->uploader->realname, trp->uploader->email))
+ xalloc_die ();
def->value = def->storage;
}
return def->value;
@@ -591,7 +596,10 @@ expand_check_result (struct metadef *def, void *data)
else if (WIFSIGNALED (status))
{
char *p = umaxtostr (WTERMSIG (status), sbuf);
- asprintf (&def->storage, "SIG+%s", p);
+ size_t size = 0;
+ def->storage = NULL;
+ if (grecs_asprintf (&def->storage, &size, "SIG+%s", p))
+ xalloc_die ();
}
else
def->storage = "[unrecognized return code]";

Return to:

Send suggestions and report system problems to the System administrator.