summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dpkg-deb/build.c13
-rw-r--r--dpkg-deb/extract.c2
-rw-r--r--dpkg-deb/info.c4
-rw-r--r--dpkg-split/queue.c6
-rw-r--r--dpkg-split/split.c2
-rw-r--r--lib/dpkg/atomic-file.c4
-rw-r--r--lib/dpkg/dbdir.c6
-rw-r--r--lib/dpkg/dir.c2
-rw-r--r--lib/dpkg/error.c2
-rw-r--r--lib/dpkg/options.c8
-rw-r--r--lib/dpkg/path.c5
-rw-r--r--lib/dpkg/tarfn.c8
-rw-r--r--lib/dpkg/triglib.c6
-rw-r--r--src/archives.c5
-rw-r--r--src/divertcmd.c12
-rw-r--r--src/main.c10
-rw-r--r--src/script.c2
17 files changed, 33 insertions, 64 deletions
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index b364f9abb..2ddeec620 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -344,7 +344,7 @@ check_control_file(const char *ctrldir)
struct pkginfo *pkg;
char *controlfile;
- m_asprintf(&controlfile, "%s/%s", ctrldir, CONTROLFILE);
+ controlfile = str_fmt("%s/%s", ctrldir, CONTROLFILE);
parsedb(controlfile, pdb_parse_binary, &pkg);
if (strspn(pkg->set->name, "abcdefghijklmnopqrstuvwxyz0123456789+-.") !=
@@ -431,7 +431,6 @@ static char *
gen_dest_pathname_from_pkg(const char *dir, struct pkginfo *pkg)
{
const char *arch_sep;
- char *path;
if (pkg->available.arch->type == DPKG_ARCH_NONE ||
pkg->available.arch->type == DPKG_ARCH_EMPTY)
@@ -439,11 +438,9 @@ gen_dest_pathname_from_pkg(const char *dir, struct pkginfo *pkg)
else
arch_sep = "_";
- m_asprintf(&path, "%s/%s_%s%s%s%s", dir, pkg->set->name,
- versiondescribe(&pkg->available.version, vdew_never),
- arch_sep, pkg->available.arch->name, DEBEXT);
-
- return path;
+ return str_fmt("%s/%s_%s%s%s%s", dir, pkg->set->name,
+ versiondescribe(&pkg->available.version, vdew_never),
+ arch_sep, pkg->available.arch->name, DEBEXT);
}
typedef void filenames_feed_func(const char *dir, int fd_out);
@@ -525,7 +522,7 @@ do_build(const char *const *argv)
badusage(_("--%s takes at most two arguments"), cipaction->olong);
debar = gen_dest_pathname(dir, dest);
- m_asprintf(&ctrldir, "%s/%s", dir, BUILDCONTROLDIR);
+ ctrldir = str_fmt("%s/%s", dir, BUILDCONTROLDIR);
/* Perform some sanity checks on the to-be-build package. */
if (nocheckflag) {
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 8b272342c..91445c674 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -491,7 +491,7 @@ do_raw_extract(const char *const *argv)
badusage(_("--%s takes at most two arguments (.deb and directory)"),
cipaction->olong);
- m_asprintf(&control_dir, "%s/%s", dir, EXTRACTCONTROLDIR);
+ control_dir = str_fmt("%s/%s", dir, EXTRACTCONTROLDIR);
data_options = DPKG_TAR_EXTRACT | DPKG_TAR_PERMS;
if (opt_verbose)
diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c
index 2ca63bf25..e806c3175 100644
--- a/dpkg-deb/info.c
+++ b/dpkg-deb/info.c
@@ -205,7 +205,7 @@ info_field(const char *debar, const char *dir, const char *const *fields,
struct pkginfo *pkg;
int i;
- m_asprintf(&controlfile, "%s/%s", dir, CONTROLFILE);
+ controlfile = str_fmt("%s/%s", dir, CONTROLFILE);
parsedb(controlfile, pdb_parse_binary | pdb_ignorefiles, &pkg);
free(controlfile);
@@ -250,7 +250,7 @@ do_showinfo(const char *const *argv)
info_prepare(&argv, &debar, &dir, 1);
- m_asprintf(&controlfile, "%s/%s", dir, CONTROLFILE);
+ controlfile = str_fmt("%s/%s", dir, CONTROLFILE);
parsedb(controlfile, pdb_parse_binary | pdb_ignorefiles, &pkg);
pkg_format_show(fmt, pkg, &pkg->available);
pkg_format_free(fmt);
diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c
index 2a6aff22a..daf00aa8e 100644
--- a/dpkg-split/queue.c
+++ b/dpkg-split/queue.c
@@ -184,9 +184,9 @@ do_auto(const char *const *argv)
int ap;
char *p, *q;
- m_asprintf(&p, "%s/t.%lx", opt_depotdir, (long)getpid());
- m_asprintf(&q, "%s/%s.%jx.%x.%x", opt_depotdir, refi->md5sum,
- (intmax_t)refi->maxpartlen, refi->thispartn, refi->maxpartn);
+ p = str_fmt("%s/t.%lx", opt_depotdir, (long)getpid());
+ q = str_fmt("%s/%s.%jx.%x.%x", opt_depotdir, refi->md5sum,
+ (intmax_t)refi->maxpartlen, refi->thispartn, refi->maxpartn);
fd_src = open(partfile, O_RDONLY);
if (fd_src < 0)
diff --git a/dpkg-split/split.c b/dpkg-split/split.c
index ea8896321..8137654cf 100644
--- a/dpkg-split/split.c
+++ b/dpkg-split/split.c
@@ -173,7 +173,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
char *refname;
int prefix_max;
- m_asprintf(&refname, "%dof%d", curpart, nparts);
+ refname = str_fmt("%dof%d", curpart, nparts);
prefix_max = max(8 - strlen(refname), 0);
varbuf_printf(&file_dst, "%s/%.*s%.8s.deb",
prefixdir, prefix_max, prefix, refname);
diff --git a/lib/dpkg/atomic-file.c b/lib/dpkg/atomic-file.c
index a4910f41c..b49a47b9b 100644
--- a/lib/dpkg/atomic-file.c
+++ b/lib/dpkg/atomic-file.c
@@ -44,7 +44,7 @@ atomic_file_new(const char *filename, enum atomic_file_flags flags)
file->flags = flags;
file->fp = NULL;
file->name = m_strdup(filename);
- m_asprintf(&file->name_new, "%s%s", filename, ATOMIC_FILE_NEW_EXT);
+ file->name_new = str_fmt("%s%s", filename, ATOMIC_FILE_NEW_EXT);
return file;
}
@@ -86,7 +86,7 @@ atomic_file_backup(struct atomic_file *file)
{
char *name_old;
- m_asprintf(&name_old, "%s%s", file->name, ATOMIC_FILE_OLD_EXT);
+ name_old = str_fmt("%s%s", file->name, ATOMIC_FILE_OLD_EXT);
if (unlink(name_old) && errno != ENOENT)
ohshite(_("error removing old backup file '%s'"), name_old);
diff --git a/lib/dpkg/dbdir.c b/lib/dpkg/dbdir.c
index 7a526916d..beaf073b4 100644
--- a/lib/dpkg/dbdir.c
+++ b/lib/dpkg/dbdir.c
@@ -84,9 +84,5 @@ dpkg_db_get_dir(void)
char *
dpkg_db_get_path(const char *pathpart)
{
- char *pathname;
-
- m_asprintf(&pathname, "%s/%s", db_dir, pathpart);
-
- return pathname;
+ return str_fmt("%s/%s", db_dir, pathpart);
}
diff --git a/lib/dpkg/dir.c b/lib/dpkg/dir.c
index 34bdac63f..dcffb9602 100644
--- a/lib/dpkg/dir.c
+++ b/lib/dpkg/dir.c
@@ -102,7 +102,7 @@ dir_file_sync(const char *dir, const char *filename)
char *path;
int fd;
- m_asprintf(&path, "%s/%s", dir, filename);
+ path = str_fmt("%s/%s", dir, filename);
fd = open(path, O_WRONLY);
if (fd < 0)
diff --git a/lib/dpkg/error.c b/lib/dpkg/error.c
index 9d4ac7b0c..b2b0e3f9c 100644
--- a/lib/dpkg/error.c
+++ b/lib/dpkg/error.c
@@ -73,7 +73,7 @@ dpkg_put_errno(struct dpkg_error *err, const char *fmt, ...)
va_list args;
char *new_fmt;
- m_asprintf(&new_fmt, "%s (%s)", fmt, strerror(errno));
+ new_fmt = str_fmt("%s (%s)", fmt, strerror(errno));
va_start(args, fmt);
dpkg_error_set(err, DPKG_MSG_ERROR, new_fmt, args);
diff --git a/lib/dpkg/options.c b/lib/dpkg/options.c
index 43e45da35..aefa2aee0 100644
--- a/lib/dpkg/options.c
+++ b/lib/dpkg/options.c
@@ -168,7 +168,7 @@ dpkg_options_load_dir(const char *prog, const struct cmdinfo *cmdinfos)
struct dirent **dlist;
int dlist_n, i;
- m_asprintf(&dirname, "%s/%s.cfg.d", CONFIGDIR, prog);
+ dirname = str_fmt("%s/%s.cfg.d", CONFIGDIR, prog);
dlist_n = scandir(dirname, &dlist, valid_config_filename, alphasort);
if (dlist_n < 0) {
@@ -182,7 +182,7 @@ dpkg_options_load_dir(const char *prog, const struct cmdinfo *cmdinfos)
for (i = 0; i < dlist_n; i++) {
char *filename;
- m_asprintf(&filename, "%s/%s", dirname, dlist[i]->d_name);
+ filename = str_fmt("%s/%s", dirname, dlist[i]->d_name);
dpkg_options_load_file(filename, cmdinfos);
free(dlist[i]);
@@ -200,13 +200,13 @@ dpkg_options_load(const char *prog, const struct cmdinfo *cmdinfos)
dpkg_options_load_dir(prog, cmdinfos);
- m_asprintf(&file, "%s/%s.cfg", CONFIGDIR, prog);
+ file = str_fmt("%s/%s.cfg", CONFIGDIR, prog);
dpkg_options_load_file(file, cmdinfos);
free(file);
home = getenv("HOME");
if (home != NULL) {
- m_asprintf(&file, "%s/.%s.cfg", home, prog);
+ file = str_fmt("%s/.%s.cfg", home, prog);
dpkg_options_load_file(file, cmdinfos);
free(file);
}
diff --git a/lib/dpkg/path.c b/lib/dpkg/path.c
index c3ef82733..1a4dba182 100644
--- a/lib/dpkg/path.c
+++ b/lib/dpkg/path.c
@@ -103,15 +103,12 @@ char *
path_make_temp_template(const char *suffix)
{
const char *tmpdir;
- char *template;
tmpdir = getenv("TMPDIR");
if (!tmpdir)
tmpdir = P_tmpdir;
- m_asprintf(&template, "%s/%s.XXXXXX", tmpdir, suffix);
-
- return template;
+ return str_fmt("%s/%s.XXXXXX", tmpdir, suffix);
}
/**
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 6a873d7cc..7943da2d6 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -84,12 +84,8 @@ OtoM(const char *s, int size)
static char *
get_prefix_name(struct tar_header *h)
{
- char *path;
-
- m_asprintf(&path, "%.*s/%.*s", (int)sizeof(h->prefix), h->prefix,
- (int)sizeof(h->name), h->name);
-
- return path;
+ return str_fmt("%.*s/%.*s", (int)sizeof(h->prefix), h->prefix,
+ (int)sizeof(h->name), h->name);
}
static mode_t
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 7f78cb20a..7ee5d31c8 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -49,11 +49,7 @@ static char *triggersdir, *triggersfilefile;
static char *
trig_get_filename(const char *dir, const char *filename)
{
- char *path;
-
- m_asprintf(&path, "%s/%s", dir, filename);
-
- return path;
+ return str_fmt("%s/%s", dir, filename);
}
static struct trig_hooks trigh;
diff --git a/src/archives.c b/src/archives.c
index d5271107b..0ebb77d5e 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1463,10 +1463,7 @@ archivefiles(const char *const *argv)
for (ap = argv; *ap; ap++) {
if (strchr(FIND_EXPRSTARTCHARS,(*ap)[0])) {
- char *a;
-
- m_asprintf(&a, "./%s", *ap);
- command_add_arg(&cmd, a);
+ command_add_arg(&cmd, str_fmt("./%s", *ap));
} else {
command_add_arg(&cmd, (const char *)*ap);
}
diff --git a/src/divertcmd.c b/src/divertcmd.c
index dc035c248..b2ca8ce7b 100644
--- a/src/divertcmd.c
+++ b/src/divertcmd.c
@@ -159,7 +159,7 @@ check_writable_dir(struct file *f)
char *tmpname;
int tmpfd;
- m_asprintf(&tmpname, "%s%s", f->name, ".dpkg-divert.tmp");
+ tmpname = str_fmt("%s%s", f->name, ".dpkg-divert.tmp");
tmpfd = creat(tmpname, 0600);
if (tmpfd < 0)
@@ -216,7 +216,7 @@ file_copy(const char *src, const char *dst)
if (srcfd < 0)
ohshite(_("unable to open file '%s'"), src);
- m_asprintf(&tmp, "%s%s", dst, ".dpkg-divert.tmp");
+ tmp = str_fmt("%s%s", dst, ".dpkg-divert.tmp");
dstfd = creat(tmp, 0600);
if (dstfd < 0)
ohshite(_("unable to create file '%s'"), tmp);
@@ -438,12 +438,8 @@ diversion_add(const char *const *argv)
fnn_from = findnamenode(filename, 0);
/* Handle divertto. */
- if (opt_divertto == NULL) {
- char *str;
-
- m_asprintf(&str, "%s.distrib", filename);
- opt_divertto = str;
- }
+ if (opt_divertto == NULL)
+ opt_divertto = str_fmt("%s.distrib", filename);
if (strcmp(filename, opt_divertto) == 0)
badusage(_("cannot divert file '%s' to itself"), filename);
diff --git a/src/main.c b/src/main.c
index 789e656fb..0ff04f19b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -360,11 +360,8 @@ set_instdir(const struct cmdinfo *cip, const char *value)
static void
set_root(const struct cmdinfo *cip, const char *value)
{
- char *p;
-
set_instdir(cip, value);
- m_asprintf(&p, "%s%s", instdir, ADMINDIR);
- admindir= p;
+ admindir = str_fmt("%s%s", instdir, ADMINDIR);
}
static void
@@ -751,13 +748,10 @@ int
execbackend(const char *const *argv)
{
struct command cmd;
- char *arg;
command_init(&cmd, cipaction->arg_ptr, NULL);
command_add_arg(&cmd, cipaction->arg_ptr);
-
- m_asprintf(&arg, "--%s", cipaction->olong);
- command_add_arg(&cmd, arg);
+ command_add_arg(&cmd, str_fmt("--%s", cipaction->olong));
/* Exlicitely separate arguments from options as any user-supplied
* separator got stripped by the option parser */
diff --git a/src/script.c b/src/script.c
index daa2210d4..a3d0d5861 100644
--- a/src/script.c
+++ b/src/script.c
@@ -166,7 +166,7 @@ maintscript_exec(struct pkginfo *pkg, struct pkgbin *pkgbin,
if (pid == 0) {
char *pkg_count;
- m_asprintf(&pkg_count, "%d", pkgset_installed_instances(pkg->set));
+ pkg_count = str_fmt("%d", pkgset_installed_instances(pkg->set));
if (setenv("DPKG_MAINTSCRIPT_PACKAGE", pkg->set->name, 1) ||
setenv("DPKG_MAINTSCRIPT_PACKAGE_REFCOUNT", pkg_count, 1) ||