This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=8b7daaecfa3738162796fc86fb845e1b86047637 commit 8b7daaecfa3738162796fc86fb845e1b86047637 Author: Guillem Jover <[email protected]> AuthorDate: Tue Feb 14 00:50:35 2023 +0100 libdpkg: Turn bitmask parse_nv_flags into an actual enum parse_nv_mode These various modes are actually exclusive, so turn them from a bitmask into an actual enumeration. Warned-by: cppcheck --- lib/dpkg/fields.c | 17 ++++++++--------- t/cppcheck/cppcheck.supp | 3 --- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c index 120ee88f1..609d4c687 100644 --- a/lib/dpkg/fields.c +++ b/lib/dpkg/fields.c @@ -43,13 +43,13 @@ /** * Flags to parse a name associated to a value. */ -enum parse_nv_flags { +enum parse_nv_mode { /** Expect no more words (default). */ PARSE_NV_LAST = 0, /** Expect another word after the parsed name. */ - PARSE_NV_NEXT = DPKG_BIT(0), + PARSE_NV_NEXT = 1, /** Do not fail if there is no name with an associated value found. */ - PARSE_NV_FALLBACK = DPKG_BIT(1), + PARSE_NV_FALLBACK = 2, }; /** @@ -57,11 +57,11 @@ enum parse_nv_flags { * * Gets a pointer to the string to parse in @a strp, and modifies the pointer * to the string to point to the end of the parsed text. If no value is found - * for the name and #PARSE_NV_FALLBACK is set in @a flags then @a strp is set + * for the name and @a flags is set to #PARSE_NV_FALLBACK then @a strp is set * to NULL and returns -1, otherwise a parse error is emitted. */ static int -parse_nv(struct parsedb_state *ps, enum parse_nv_flags flags, +parse_nv(struct parsedb_state *ps, enum parse_nv_mode parse_mode, const char **strp, const struct namevalue *nv_head) { const char *str_start = *strp, *str_end; @@ -76,7 +76,7 @@ parse_nv(struct parsedb_state *ps, enum parse_nv_flags flags, nv = namevalue_find_by_name(nv_head, str_start); if (nv == NULL) { /* We got no match, skip further string validation. */ - if (!(flags & PARSE_NV_FALLBACK)) + if (parse_mode != PARSE_NV_FALLBACK) return dpkg_put_error(&ps->err, _("has invalid value '%.50s'"), str_start); str_end = NULL; @@ -88,7 +88,7 @@ parse_nv(struct parsedb_state *ps, enum parse_nv_flags flags, value = nv->value; } - if (!(flags & PARSE_NV_NEXT) && str_is_set(str_end)) + if (parse_mode != PARSE_NV_NEXT && str_is_set(str_end)) return dpkg_put_error(&ps->err, _("has trailing junk")); *strp = str_end; @@ -231,8 +231,7 @@ f_priority(struct pkginfo *pkg, struct pkgbin *pkgbin, if (!*value) return; - priority = parse_nv(ps, PARSE_NV_LAST | PARSE_NV_FALLBACK, &str, - priorityinfos); + priority = parse_nv(ps, PARSE_NV_FALLBACK, &str, priorityinfos); if (dpkg_has_error(&ps->err)) parse_error(ps, _("word in '%s' field: %s"), fip->name, ps->err.str); diff --git a/t/cppcheck/cppcheck.supp b/t/cppcheck/cppcheck.supp index 1779f1cec..c1b61eac9 100644 --- a/t/cppcheck/cppcheck.supp +++ b/t/cppcheck/cppcheck.supp @@ -11,9 +11,6 @@ variableScope // TODO: While perhaps valid there are many to handle right away. constParameter -// TODO: Will fix in 1.22.x. -badBitmaskCheck:lib/dpkg/fields.c - // Ignore, this is an imported module. unusedStructMember:lib/compat/obstack.c nullPointerArithmetic:lib/compat/obstack.c -- Dpkg.Org's dpkg

