This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=3d4ecf6f9ce5093a31fb1958ea09718d05505186

commit 3d4ecf6f9ce5093a31fb1958ea09718d05505186
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Feb 4 04:34:29 2020 +0100

    libdpkg: Move printing of errno into dpkg_error_set()
    
    This simplifies the code, and squashes a warning.
    
    Warned-by: clang-10 -Wformat-nonliteral (from -Wformat=2)
---
 debian/changelog |  1 +
 lib/dpkg/error.c | 11 ++++-------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2f0772549..059914ed0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -199,6 +199,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium
     - libdpkg: Add new ATOMIC_FILE_NORMAL enum value to avoid a cast in C++.
     - libdpkg: Use a new DPKG_NULL macro that works in C and C++.
     - libdpkg: Use a new DPKG_STATIC_CAST macro that works in C and C++.
+    - libdpkg: Move printing of errno into dpkg_error_set().
   * Build system:
     - Bump minimal Perl version to 5.24.1.
     - Add a serial versioning to the m4 files.
diff --git a/lib/dpkg/error.c b/lib/dpkg/error.c
index 025c558ac..42bdb43d4 100644
--- a/lib/dpkg/error.c
+++ b/lib/dpkg/error.c
@@ -42,6 +42,9 @@ dpkg_error_set(struct dpkg_error *err, enum dpkg_msg_type 
type, int syserrno,
        err->syserrno = syserrno;
 
        varbuf_vprintf(&str, fmt, args);
+       if (syserrno)
+               varbuf_printf(&str, " (%s)", strerror(syserrno));
+
        err->str = str.buf;
 }
 
@@ -79,17 +82,11 @@ int
 dpkg_put_errno(struct dpkg_error *err, const char *fmt, ...)
 {
        va_list args;
-       char *new_fmt;
-       int syserrno = errno;
-
-       new_fmt = str_fmt("%s (%s)", fmt, strerror(errno));
 
        va_start(args, fmt);
-       dpkg_error_set(err, DPKG_MSG_ERROR, syserrno, new_fmt, args);
+       dpkg_error_set(err, DPKG_MSG_ERROR, errno, fmt, args);
        va_end(args);
 
-       free(new_fmt);
-
        return -1;
 }
 

-- 
Dpkg.Org's dpkg

Reply via email to