Bug 1409 - arparse library assumes enum are 64 bit
Summary: arparse library assumes enum are 64 bit
Status: UNCONFIRMED
Alias: None
Product: DPDK
Classification: Unclassified
Component: core (show other bugs)
Version: 24.03
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: dev
URL:
Depends on:
Blocks:
 
Reported: 2024-03-30 03:58 CET by Stephen Hemminger
Modified: 2024-03-30 03:58 CET (History)
0 users



Attachments

Description Stephen Hemminger 2024-03-30 03:58:41 CET
MSVC correctly flags that this line in rte_argparse.h is incorrect:
	RTE_ARGPARSE_ARG_RESERVED_FIELD = RTE_GENMASK64(63, 48),

The problem is that enum values are just an alias for int, and it can be 32 bits.

Taken from the current C Standard (C99):
 http://www.open std.org/JTC1/SC22/WG14/www/docs/n1256.pdf

6.7.2.2 Enumeration specifiers
[...]
Constraints
The expression that defines the value of an enumeration constant shall be an integer constant expression that has a value representable as an int.
[...]
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.

Since rte_argparse only uses 10 bits now. The suggested fix here is to:
   1. Assume 32 bits
   2. Get rid of the reserved field - reserved fields are bad idea

Note You need to log in before you can comment on or make changes to this bug.