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=72c2b44655be986fa0422725a005f69d41a77841

commit 72c2b44655be986fa0422725a005f69d41a77841
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Tue Aug 14 06:08:56 2018 +0200

    libdpkg: Use a pointer to pointer to track previous entry in 
pkg_files_blank()
    
    We reduce the nesting level, and avoid a conditional inside the loop.
---
 debian/changelog         |  2 ++
 lib/dpkg/db-fsys-files.c | 10 ++++------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 9b36cf7f8..9ed4a732c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -184,6 +184,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - dpkg: Move ensure_package_clientdata() into its own file.
     - libdpkg: Move db-fsys code from src to lib/dpkg.
     - libdpkg: Rename pkg-db module to pkg-hash.
+    - libdpkg: Simplify pkg_files_blank() by using a pointer to pointer to
+      track the previous entry.
   * 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/db-fsys-files.c b/lib/dpkg/db-fsys-files.c
index 6290ed283..085cb143d 100644
--- a/lib/dpkg/db-fsys-files.c
+++ b/lib/dpkg/db-fsys-files.c
@@ -81,7 +81,7 @@ pkg_files_blank(struct pkginfo *pkg)
   for (current = pkg->files;
        current;
        current= current->next) {
-    struct pkg_list *pkg_node, *pkg_prev = NULL;
+    struct pkg_list *pkg_node, **pkg_prev = &current->namenode->packages;
 
     /* For each file that used to be in the package,
      * go through looking for this package's entry in the list
@@ -90,16 +90,14 @@ pkg_files_blank(struct pkginfo *pkg)
          pkg_node;
          pkg_node = pkg_node->next) {
       if (pkg_node->pkg == pkg) {
-        if (pkg_prev)
-          pkg_prev->next = pkg_node->next;
-        else
-          current->namenode->packages = pkg_node->next;
+        *pkg_prev = pkg_node->next;
 
         /* The actual filelist links were allocated using nfmalloc, so
          * we shouldn't free them. */
         break;
       }
-      pkg_prev = pkg_node;
+
+      pkg_prev = &pkg_node->next;
     }
   }
   pkg->files = NULL;

-- 
Dpkg.Org's dpkg

Reply via email to