This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
commit 2d7566140335d5338e5a98278d4df762936f67f4 Author: Guillem Jover <[email protected]> Date: Wed Apr 4 03:06:44 2018 +0200 libdpkg: Use a single struct filenamenode definition The struct filenamenode hash implementation is lightweight, and once split from the bulk of the on-disk database handling there's no point in reimplementing it, and then redefining the same struct in multiple places, which is rather confusing for the reader, and even for static analyzers. Closes: #746766 --- debian/changelog | 2 ++ lib/dpkg/triglib.c | 32 +------------------------------- lib/dpkg/triglib.h | 3 +++ src/trigcmd.c | 2 ++ src/trigproc.c | 8 +------- 5 files changed, 9 insertions(+), 38 deletions(-) diff --git a/debian/changelog b/debian/changelog index 123ef67..afe1d4a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -51,6 +51,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium behavior, but it will make it possible to do a default switch in 1.20.x. * Warn when using dpkg-divert --add or --remove w/o --rename or --no-rename. * Warn when using dpkg-divert --rename on a file from an Essential package. + * Use a single “struct filenamenode” definition for the entire code base. + Closes: #746766 * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo <[email protected]> diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c index a067d14..3956013 100644 --- a/lib/dpkg/triglib.c +++ b/lib/dpkg/triglib.c @@ -821,42 +821,12 @@ trig_incorporate(enum modstatdb_rw cstatus) /*---------- Default hooks. ----------*/ -struct filenamenode { - struct filenamenode *next; - const char *name; - struct trigfileint *trig_interested; -}; - -static struct filenamenode *trigger_files; - -static struct filenamenode * -th_simple_nn_find(const char *name, bool nonew) -{ - struct filenamenode *search; - - for (search = trigger_files; search; search = search->next) - if (strcmp(search->name, name) == 0) - return search; - - /* Not found. */ - if (nonew) - return NULL; - - search = nfmalloc(sizeof(*search)); - search->name = nfstrsave(name); - search->trig_interested = NULL; - search->next = trigger_files; - trigger_files = search; - - return search; -} - TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS static struct trig_hooks trigh = { .enqueue_deferred = NULL, .transitional_activate = NULL, - .namenode_find = th_simple_nn_find, + .namenode_find = th_nn_find, .namenode_interested = th_nn_interested, .namenode_name = th_nn_name, }; diff --git a/lib/dpkg/triglib.h b/lib/dpkg/triglib.h index 3e63f5c..74b33cc 100644 --- a/lib/dpkg/triglib.h +++ b/lib/dpkg/triglib.h @@ -25,6 +25,7 @@ #include <dpkg/macros.h> #include <dpkg/dpkg-db.h> +#include <dpkg/fsys.h> DPKG_BEGIN_DECLS @@ -78,6 +79,8 @@ struct trig_hooks { }; #define TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS \ + static struct filenamenode *th_nn_find(const char *name, bool nonew) \ + { return findnamenode(name, nonew ? fnn_nonew : 0); } \ static struct trigfileint **th_nn_interested(struct filenamenode *fnn) \ { return &fnn->trig_interested; } \ static const char *th_nn_name(struct filenamenode *fnn) \ diff --git a/src/trigcmd.c b/src/trigcmd.c index 312cd87..bc0d2f9 100644 --- a/src/trigcmd.c +++ b/src/trigcmd.c @@ -229,6 +229,8 @@ main(int argc, const char *const *argv) badusage(_("illegal awaited package name '%.250s': %.250s"), bypackage, badname); + filesdbinit(); + activate = argv[0]; badname = trig_name_is_illegal(activate); if (badname) diff --git a/src/trigproc.c b/src/trigproc.c index 9c73d4c..7b6537b 100644 --- a/src/trigproc.c +++ b/src/trigproc.c @@ -534,18 +534,12 @@ trig_transitional_activate(enum modstatdb_rw cstatus) /*========== Hook setup. ==========*/ -static struct filenamenode * -th_proper_nn_find(const char *name, bool nonew) -{ - return findnamenode(name, nonew ? fnn_nonew : 0); -} - TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS static const struct trig_hooks trig_our_hooks = { .enqueue_deferred = trigproc_enqueue_deferred, .transitional_activate = trig_transitional_activate, - .namenode_find = th_proper_nn_find, + .namenode_find = th_nn_find, .namenode_interested = th_nn_interested, .namenode_name = th_nn_name, }; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/dpkg/dpkg.git

