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=23f575c23e9d141dd4b1b34bb41060b4f99ea611

commit 23f575c23e9d141dd4b1b34bb41060b4f99ea611
Author: Guillem Jover <[email protected]>
AuthorDate: Thu Aug 9 03:05:46 2018 +0200

    libdpkg: Add new m_dup() function
---
 debian/changelog     |  1 +
 lib/dpkg/dpkg.h      |  1 +
 lib/dpkg/libdpkg.map |  1 +
 lib/dpkg/mlib.c      | 13 +++++++++++++
 4 files changed, 16 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 881439d4d..3d949507b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -198,6 +198,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - libdpkg: Add new file_slurp() function.
     - libdpkg: Switch db-fsys to use the new file_slurp() function.
     - libdpkg: Add new pkg_infodb_reset_dir().
+    - libdpkg: Add new m_dup() function.
   * Build system:
     - Set distribution tarball format to ustar, instead of default v7 format.
     - Mark PO4A and POD2MAN as precious variables.
diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index 7bc348039..2bb067af3 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -146,6 +146,7 @@ char *m_strndup(const char *str, size_t n);
 int m_asprintf(char **strp, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
 int m_vasprintf(char **strp, const char *fmt, va_list args)
        DPKG_ATTR_VPRINTF(2);
+int m_dup(int oldfd);
 void m_dup2(int oldfd, int newfd);
 void m_pipe(int fds[2]);
 void m_output(FILE *f, const char *name);
diff --git a/lib/dpkg/libdpkg.map b/lib/dpkg/libdpkg.map
index 20eccb72a..2bcbc99ff 100644
--- a/lib/dpkg/libdpkg.map
+++ b/lib/dpkg/libdpkg.map
@@ -80,6 +80,7 @@ LIBDPKG_PRIVATE {
        m_strdup;
        m_vasprintf;
        m_asprintf;
+       m_dup;
        m_dup2;
        m_pipe;
        m_output;
diff --git a/lib/dpkg/mlib.c b/lib/dpkg/mlib.c
index 1470a7f61..8de77b7ea 100644
--- a/lib/dpkg/mlib.c
+++ b/lib/dpkg/mlib.c
@@ -110,6 +110,19 @@ m_asprintf(char **strp, const char *fmt, ...)
   return n;
 }
 
+int
+m_dup(int oldfd)
+{
+  int newfd;
+
+  newfd = dup(oldfd);
+  if (newfd >= 0)
+    return newfd;
+
+  onerr_abort++;
+  ohshite(_("failed to dup for fd %d"), oldfd);
+}
+
 void m_dup2(int oldfd, int newfd) {
   const char *const stdstrings[]= { "in", "out", "err" };
 

-- 
Dpkg.Org's dpkg

Reply via email to