summaryrefslogtreecommitdiffabout
path: root/src/triplet.c
Side-by-side diff
Diffstat (limited to 'src/triplet.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/triplet.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/triplet.c b/src/triplet.c
index 9f051db..bfd58e5 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -343,9 +343,8 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
char timebuf[sizeof "YYYY-MM-DD HH:MM:SS +0000"];
struct passwd *pw;
struct group *grp;
- char sbuf[INT_BUFSIZE_BOUND (uintmax_t)];
- char *sptr;
- size_t slen;
+ char *sptr = NULL;
+ size_t slen = 0;
int pad;
char *user_name;
char *group_name;
@@ -378,7 +377,8 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
group_name = grp->gr_name;
/* Size */
- sptr = umaxtostr (info->sb.st_size, sbuf);
+ if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size))
+ xalloc_die ();
/* Figure out padding and format the buffer */
slen = strlen (sptr);
@@ -392,6 +392,7 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
sptr,
timebuf, info->name))
xalloc_die ();
+ free (sptr);
*pret = buf;
return 0;
}
@@ -584,25 +585,27 @@ expand_check_result (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
int status = trp->check_result;
- char sbuf[INT_BUFSIZE_BOUND (uintmax_t)];
if (status == 0)
return def->value = "0";
else if (WIFEXITED (status))
{
- char *p = umaxtostr (WEXITSTATUS (status), sbuf);
- def->storage = xstrdup (p);
+ size_t size = 0;
+ def->storage = NULL;
+ if (grecs_asprintf (&def->storage, &size,
+ "%d", WEXITSTATUS (status)))
+ xalloc_die ();
}
else if (WIFSIGNALED (status))
{
- char *p = umaxtostr (WTERMSIG (status), sbuf);
size_t size = 0;
def->storage = NULL;
- if (grecs_asprintf (&def->storage, &size, "SIG+%s", p))
+ if (grecs_asprintf (&def->storage, &size, "SIG+%d",
+ WTERMSIG (status)))
xalloc_die ();
}
else
- def->storage = "[unrecognized return code]";
+ return def->value = "[unrecognized return code]";
return def->value = def->storage;
}

Return to:

Send suggestions and report system problems to the System administrator.