summaryrefslogtreecommitdiff
path: root/dpkg-deb
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-10-18 15:34:45 +0200
committerGuillem Jover <guillem@debian.org>2015-12-12 21:49:37 +0100
commit0db77512a15877ca25384b775406323a2302c125 (patch)
tree68167f8660ac41510c90a497664ab0eb16ef6702 /dpkg-deb
parent302829039a4dba8a37fa31dfc0e06ca4a8e5a04b (diff)
downloaddpkg-0db77512a15877ca25384b775406323a2302c125.tar.gz
Use new str_fmt() instead of m_asprintf()
It should make the code more clear, and in many cases it avoids having to use a temporary variable.
Diffstat (limited to 'dpkg-deb')
-rw-r--r--dpkg-deb/build.c13
-rw-r--r--dpkg-deb/extract.c2
-rw-r--r--dpkg-deb/info.c4
3 files changed, 8 insertions, 11 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);