[Rpm-maint] [rpm-software-management/rpm] Replace rpmTagType_e with a list of defines and an rpmTagType typedef (PR #2417)
David Cantrell
notifications at github.com
Tue Mar 7 16:09:37 UTC 2023
I ran in to a problem with some versions of clang building rpm where the value of RPM_MASK_TYPE (0x0000ffff) triggered an overflow error. Per the C standard, the underlying type of the enum is implementation defined. It should be an int unless the values of the enum cannot fit in an int or unsigned int. I think that gcc is more forward thinking here than clang because with clang this particular enum becomes an int and when RPM_MASK_TYPE is used, you get an overflow error. RPM_MASK_TYPE is not part of the enum.
I generally find enums in header files to lead to confusion and problems anyway. And especially in cases like this where developers may be expecting to use the preprocessor to determine if values are defined or not. Changing this enum to be a list of defined macros resolves the issue for me. I retained the rpmTagType variable type as well, but made it be a uint32_t. I originally wanted to make it a uint16_t because RPM_MASK_TYPE is 0x0000ffff, but that causes overflow warnings as well because rpmTagType sometimes gets RPMTAG_NOT_FOUND, which is a uint32_t. So just use uint32_t consistently.
If this looks reasonable to people, I do not mind fixing up the other enums in header files. I just wanted to start with this one.
You can view, comment on, or merge this pull request online at:
https://github.com/rpm-software-management/rpm/pull/2417
-- Commit Summary --
* Replace rpmTagType_e with a list of defines and an rpmTagType typedef
-- File Changes --
M include/rpm/rpmtag.h (34)
-- Patch Links --
https://github.com/rpm-software-management/rpm/pull/2417.patch
https://github.com/rpm-software-management/rpm/pull/2417.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/2417
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/pull/2417 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20230307/98d89cd7/attachment.html>
More information about the Rpm-maint
mailing list