From 42994ada0773853c4430e50192cd3d830305386e Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 6 Feb 2016 09:13:38 +0100 Subject: [PATCH] Fix xbps_dbg_printf arguments by using __attribute__((format, printf)). Patch provided by Michael Ghering in #148. Close #148 --- include/xbps.h.in | 8 ++++---- lib/package_config_files.c | 3 ++- lib/package_unpack.c | 6 +++--- lib/repo_pkgdeps.c | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/xbps.h.in b/include/xbps.h.in index 6400a8f8..3c4af9d8 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -634,10 +634,10 @@ struct xbps_handle { int flags; }; -void xbps_dbg_printf(struct xbps_handle *, const char *, ...); -void xbps_dbg_printf_append(struct xbps_handle *, const char *, ...); -void xbps_error_printf(const char *, ...); -void xbps_warn_printf(const char *, ...); +void xbps_dbg_printf(struct xbps_handle *, const char *, ...) __attribute__ ((format (printf, 2, 3))); +void xbps_dbg_printf_append(struct xbps_handle *, const char *, ...)__attribute__ ((format (printf, 2, 3))); +void xbps_error_printf(const char *, ...)__attribute__ ((format (printf, 1, 2))); +void xbps_warn_printf(const char *, ...)__attribute__ ((format (printf, 1, 2))); /** * Initialize the XBPS library with the following steps: diff --git a/lib/package_config_files.c b/lib/package_config_files.c index b9e577bd..a6e30656 100644 --- a/lib/package_config_files.c +++ b/lib/package_config_files.c @@ -95,7 +95,8 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, version = xbps_pkg_version(pkgver); assert(version); xbps_dbg_printf(xhp, "%s: conf_file %s not currently " - "installed, renaming to %s.new-%s\n", pkgver, entry_pname, version); + "installed, renaming to %s.new-%s\n", pkgver, + entry_pname, entry_pname, version); snprintf(buf, sizeof(buf), "%s.new-%s", entry_pname, version); xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE, 0, pkgver, "File `%s' exists, installing configuration file to `%s'.", entry_pname, buf); diff --git a/lib/package_unpack.c b/lib/package_unpack.c index 0fb96d7b..e99bfec4 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -279,7 +279,7 @@ unpack_archive(struct xbps_handle *xhp, if (file_exists && match_preserved_file(xhp, entry_pname)) { archive_read_data_skip(ar); xbps_dbg_printf(xhp, "[unpack] `%s' exists on disk " - "and must be preserved, skipping.\n", xhp, entry_pname); + "and must be preserved, skipping.\n", entry_pname); xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FILE_PRESERVED, 0, pkgver, "%s: file `%s' won't be extracted, " "it's preserved.\n", pkgver, entry_pname); @@ -359,13 +359,13 @@ unpack_archive(struct xbps_handle *xhp, archive_entry_gid(entry)) != 0) { xbps_dbg_printf(xhp, "%s: failed " - "to set uid/gid to %u:%u (%s)\n", + "to set uid/gid to %zu:%zu (%s)\n", pkgver, archive_entry_uid(entry), archive_entry_gid(entry), strerror(errno)); } else { xbps_dbg_printf(xhp, "%s: entry %s changed " - "uid/gid to %u:%u.\n", pkgver, entry_pname, + "uid/gid to %zu:%zu.\n", pkgver, entry_pname, archive_entry_uid(entry), archive_entry_gid(entry)); } diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index ba9c537f..0008e923 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -147,7 +147,7 @@ find_repo_deps(struct xbps_handle *xhp, foundvpkg = false; reqpkg = xbps_string_cstring_nocopy(obj); if (xhp->flags & XBPS_FLAG_DEBUG) { - xbps_dbg_printf(xhp, ""); + xbps_dbg_printf(xhp, "%s", ""); for (unsigned short x = 0; x < *depth; x++) { xbps_dbg_printf_append(xhp, " "); } @@ -299,7 +299,7 @@ find_repo_deps(struct xbps_handle *xhp, } rv = add_missing_reqdep(xhp, reqpkg); if (rv != 0 && rv != EEXIST) { - xbps_dbg_printf(xhp, "`%s': add_missing_reqdep failed %s\n", reqpkg); + xbps_dbg_printf(xhp, "`%s': add_missing_reqdep failed\n", reqpkg); break; } else if (rv == EEXIST) { xbps_dbg_printf(xhp, "`%s' missing dep already added.\n", reqpkg); @@ -345,7 +345,7 @@ find_repo_deps(struct xbps_handle *xhp, } if (xhp->flags & XBPS_FLAG_DEBUG) { - xbps_dbg_printf(xhp, ""); + xbps_dbg_printf(xhp, "%s", ""); for (unsigned short x = 0; x < *depth; x++) { xbps_dbg_printf_append(xhp, " "); }