> -----Original Message-----
> From: Stephen Hemminger <[email protected]>
> Sent: Saturday 17 January 2026 21:57
> To: [email protected]
> Cc: Stephen Hemminger <[email protected]>
> Subject: [PATCH v4 05/11] net/pcap: use bool for flags
>
> Save some space by using bool for flag values.
>
> Signed-off-by: Stephen Hemminger <[email protected]>
> ---
> drivers/net/pcap/pcap_ethdev.c | 67 +++++++++++++++-------------------
> 1 file changed, 29 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
> index 0c65a2dffc..62f073e214 100644
> --- a/drivers/net/pcap/pcap_ethdev.c
> +++ b/drivers/net/pcap/pcap_ethdev.c
> @@ -5,6 +5,7 @@
> */
>
> #include <stdlib.h>
> +#include <stdbool.h>
> #include <time.h>
>
> #include <pcap.h>
> @@ -91,9 +92,9 @@ struct pmd_internals {
> char devargs[ETH_PCAP_ARG_MAXLEN];
> struct rte_ether_addr eth_addr;
> int if_index;
> - int single_iface;
> - int phy_mac;
> - unsigned int infinite_rx;
> + bool single_iface;
> + bool phy_mac;
> + bool infinite_rx;
> };
>
> struct pmd_process_private {
> @@ -103,25 +104,25 @@ struct pmd_process_private {
> };
>
> struct pmd_devargs {
> - unsigned int num_of_queue;
> + uint16_t num_of_queue;
> + bool phy_mac;
> struct devargs_queue {
> pcap_dumper_t *dumper;
> pcap_t *pcap;
> const char *name;
> const char *type;
> } queue[RTE_PMD_PCAP_MAX_QUEUES];
> - int phy_mac;
> };
>
> struct pmd_devargs_all {
> struct pmd_devargs rx_queues;
> struct pmd_devargs tx_queues;
> - int single_iface;
> - unsigned int is_tx_pcap;
> - unsigned int is_tx_iface;
> - unsigned int is_rx_pcap;
> - unsigned int is_rx_iface;
> - unsigned int infinite_rx;
> + bool single_iface;
> + bool is_tx_pcap;
> + bool is_tx_iface;
> + bool is_rx_pcap;
> + bool is_rx_iface;
> + bool infinite_rx;
> };
>
> static const char *valid_arguments[] = {
> @@ -871,7 +872,7 @@ eth_dev_close(struct rte_eth_dev *dev)
> }
> }
>
> - if (internals->phy_mac == 0)
> + if (!internals->phy_mac)
> /* not dynamically allocated, must not be freed */
> dev->data->mac_addrs = NULL;
>
> @@ -1192,29 +1193,19 @@ open_tx_iface(const char *key, const char *value,
> void *extra_args)
> }
>
> static int
> -select_phy_mac(const char *key __rte_unused, const char *value,
> - void *extra_args)
> +process_bool_flag(const char *key, const char *value, void *extra_args)
> {
> - if (extra_args) {
> - const int phy_mac = atoi(value);
> - int *enable_phy_mac = extra_args;
> -
> - if (phy_mac)
> - *enable_phy_mac = 1;
> - }
> - return 0;
> -}
> -
> -static int
> -get_infinite_rx_arg(const char *key __rte_unused,
> - const char *value, void *extra_args)
> -{
> - if (extra_args) {
> - const int infinite_rx = atoi(value);
> - int *enable_infinite_rx = extra_args;
> -
> - if (infinite_rx > 0)
> - *enable_infinite_rx = 1;
> + bool *flag = extra_args;
> +
> + if (value == NULL || *value == '\0') {
> + *flag = true; /* default with no additional argument */
> + } else if (strcmp(value, "0") == 0) {
> + *flag = false;
> + } else if (strcmp(value, "1") == 0) {
> + *flag = true;
> + } else {
> + PMD_LOG(ERR, "Invalid '%s' value '%s'", key, value);
> + return -1;
> }
> return 0;
> }
> @@ -1491,7 +1482,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
> dumpers.queue[0] = pcaps.queue[0];
>
> ret = rte_kvargs_process(kvlist, ETH_PCAP_PHY_MAC_ARG,
> - &select_phy_mac, &pcaps.phy_mac);
> + &process_bool_flag, &pcaps.phy_mac);
Nit: there seems to be one unnecessary space and unnecessary
indentation change in the above and some other lines.
> if (ret < 0)
> goto free_kvlist;
>
> @@ -1530,9 +1521,9 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
>
> if (infinite_rx_arg_cnt == 1) {
> ret = rte_kvargs_process(kvlist,
> - ETH_PCAP_INFINITE_RX_ARG,
> - &get_infinite_rx_arg,
> - &devargs_all.infinite_rx);
> + ETH_PCAP_INFINITE_RX_ARG,
> + &process_bool_flag,
> + &devargs_all.infinite_rx);
> if (ret < 0)
> goto free_kvlist;
> PMD_LOG(INFO, "infinite_rx has been %s for %s",
> --
> 2.51.0
Regardless of spacing issues,
Acked-by: Marat Khalili <[email protected]>