if (opt_verbose) {
char *str;
- asprintf(&str, "%s -> %s", path, outbuffer);
+ xasprintf(&str, "%s -> %s", path, outbuffer);
print_node('l', i, str);
if (opt_verbose > 1)
printf(_(" uncompressing block at %ld to %ld (%ld)\n"),
#include "c.h"
#include "pathnames.h"
+#include "xalloc.h"
/* Create open temporary file in safe way. Please notice that the
* file permissions are -rw------- by default. */
tmpenv = getenv("TMPDIR");
if (tmpenv)
- asprintf(&localtmp, "%s/%s.XXXXXX", tmpenv,
+ xasprintf(&localtmp, "%s/%s.XXXXXX", tmpenv,
program_invocation_short_name);
else
- asprintf(&localtmp, "%s/%s.XXXXXX", _PATH_TMP,
+ xasprintf(&localtmp, "%s/%s.XXXXXX", _PATH_TMP,
program_invocation_short_name);
old_mode = umask(077);
fd = mkstemp(localtmp);
#include "c.h"
#include "tt.h"
#include "strutils.h"
+#include "xalloc.h"
/* flags */
enum {
if (root && str && !(flags & FL_NOFSROOT) && strcmp(root, "/")) {
char *tmp;
- if (asprintf(&tmp, "%s[%s]", str, root) > 0)
+ if (xasprintf(&tmp, "%s[%s]", str, root) > 0)
str = tmp;
}
break;
char *tmp;
int rc = 0;
if ((tt_flags & TT_FL_RAW) || (tt_flags & TT_FL_EXPORT))
- rc = asprintf(&tmp, "%u:%u",
+ rc = xasprintf(&tmp, "%u:%u",
major(devno), minor(devno));
else
- rc = asprintf(&tmp, "%3u:%-3u",
+ rc = xasprintf(&tmp, "%3u:%-3u",
major(devno), minor(devno));
if (rc)
str = tmp;
case COL_SIZE:
if (cxt->size) {
if (lsblk->bytes) {
- if (asprintf(&p, "%jd", cxt->size) < 0)
+ if (xasprintf(&p, "%jd", cxt->size) < 0)
p = NULL;
} else
p = size_to_human_string(SIZE_SUFFIX_1LETTER, cxt->size);
/* note, we ignore names with non-printable widechars */
if (w > 0)
nc->name = xstrdup(name);
- else if (asprintf(&nc->name, "%lu", id) == -1)
+ else if (xasprintf(&nc->name, "%lu", id) == -1)
nc->name = NULL;
for (x = *ic; x && x->next; x = x->next);
switch (get_column_id(i)) {
case COL_PARTNO:
- rc = asprintf(&str, "%d",
+ rc = xasprintf(&str, "%d",
blkid_partition_get_partno(par));
break;
case COL_START:
- rc = asprintf(&str, "%ju",
+ rc = xasprintf(&str, "%ju",
blkid_partition_get_start(par));
break;
case COL_END:
- rc = asprintf(&str, "%ju",
+ rc = xasprintf(&str, "%ju",
blkid_partition_get_start(par) +
blkid_partition_get_size(par) - 1);
break;
case COL_SECTORS:
- rc = asprintf(&str, "%ju",
+ rc = xasprintf(&str, "%ju",
blkid_partition_get_size(par));
break;
case COL_SIZE:
if (partx_flags & FL_BYTES)
- rc = asprintf(&str, "%ju", (uintmax_t)
+ rc = xasprintf(&str, "%ju", (uintmax_t)
blkid_partition_get_size(par) << 9);
else
str = size_to_human_string(SIZE_SUFFIX_1LETTER,
if (str)
str = xstrdup(str);
else
- rc = asprintf(&str, "0x%x",
+ rc = xasprintf(&str, "0x%x",
blkid_partition_get_type(par));
break;
case COL_FLAGS:
- rc = asprintf(&str, "0x%llx", blkid_partition_get_flags(par));
+ rc = xasprintf(&str, "0x%llx", blkid_partition_get_flags(par));
break;
case COL_SCHEME:
{
str = strchr(buf, ':');
if (!str)
continue;
- if (asprintf(&str, "%s", str + 1) == -1)
+ if (xasprintf(&str, "%s", str + 1) == -1)
errx(EXIT_FAILURE, _("failed to allocate memory"));
/* remove leading, trailing and repeating whitespace */
while (*str == ' ')
case 'U':
if (source)
errx(MOUNT_EX_USAGE, _("only one <source> may be specified"));
- if (asprintf(&srcbuf, "%s=\"%s\"",
+ if (xasprintf(&srcbuf, "%s=\"%s\"",
c == 'L' ? "LABEL" : "UUID", optarg) <= 0)
err(MOUNT_EX_SYSERR, _("failed to allocate source buffer"));
source = srcbuf;
switch (get_column_id(i)) {
case COL_RES:
- rc = asprintf(&str, "%s", l->desc->name);
+ rc = xasprintf(&str, "%s", l->desc->name);
break;
case COL_HELP:
- rc = asprintf(&str, "%s", l->desc->help);
+ rc = xasprintf(&str, "%s", l->desc->help);
break;
case COL_SOFT:
rc = l->rlim.rlim_cur == RLIM_INFINITY ?
- asprintf(&str, "%s", "unlimited") :
- asprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_cur);
+ xasprintf(&str, "%s", "unlimited") :
+ xasprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_cur);
break;
case COL_HARD:
rc = l->rlim.rlim_max == RLIM_INFINITY ?
- asprintf(&str, "%s", "unlimited") :
- asprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_max);
+ xasprintf(&str, "%s", "unlimited") :
+ xasprintf(&str, "%llu", (unsigned long long) l->rlim.rlim_max);
break;
case COL_UNITS:
str = l->desc->unit ? xstrdup(_(l->desc->unit)) : NULL;