Re: [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing

2023-11-30 Thread Bruce Richardson
On Wed, Nov 29, 2023 at 02:14:13PM -0800, Stephen Hemminger wrote: > On Tue, 28 Nov 2023 14:07:41 + > Euan Bourke wrote: > > > +int > > +rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t > > cores_len) > > +{ > > + int32_t min = -1; > > + char *end = NULL; > > + > > +

Re: [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing

2023-11-29 Thread Stephen Hemminger
On Tue, 28 Nov 2023 14:07:41 + Euan Bourke wrote: > +int > +rte_parse_corelist(const char *corelist, uint16_t *cores, uint32_t cores_len) > +{ > + int32_t min = -1; > + char *end = NULL; > + > + struct core_bits *mask = malloc(sizeof(struct core_bits)); > + if (mask == NULL) >

Re: [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing

2023-11-29 Thread Stephen Hemminger
On Tue, 28 Nov 2023 14:07:41 + Euan Bourke wrote: > +static inline bool > +get_core_bit(struct core_bits *mask, uint16_t idx) > +{ > + return !!(mask->bits[idx / 8] & (1 << (idx % 8))); > +} > + You used CHAR_BIT above, why not here?

Re: [PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing

2023-11-29 Thread Stephen Hemminger
On Tue, 28 Nov 2023 14:07:41 + Euan Bourke wrote: > +struct core_bits { > + uint8_t bits[(UINT16_MAX + 1)/CHAR_BIT]; > + uint16_t max_bit_set; > + uint16_t min_bit_set; > + uint32_t total_bits_set; > +}; Looks like a good candidate for flex array

[PATCH 24.03 v2 1/5] arg_parser: new library for command line parsing

2023-11-29 Thread Euan Bourke
Add a new library to make it easier for eal and other libraries to parse command line arguments. The first function in this library is one to parse a corelist string into an array of individual core ids. The function will then return the total number of cores described in the corelist. Signed-off