Re: [PATCH v20 05/25] net/pcap: remove unnecessary casts

Bruce Richardson
2026-03-16T11:27:45Z

On Tue, Mar 10, 2026 at 09:09:43AM -0700, Stephen Hemminger wrote:
> The function rte_zmalloc returns void * so cast is unnecessary.
>
> Correct the indentation in that code. Not really worth backporting.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Though one comment (and mini-rant, sorry!) inline below. Ok with this
change as-is if you aren't respinning the set.

> drivers/net/pcap/pcap_ethdev.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
> index 4513d46d61..fbd1021c39 100644
> --- a/drivers/net/pcap/pcap_ethdev.c
> +++ b/drivers/net/pcap/pcap_ethdev.c
> @@ -1220,9 +1220,8 @@ pmd_init_internals(struct rte_vdev_device *vdev,
> PMD_LOG(INFO, "Creating pcap-backed ethdev on numa socket %d",
> numa_node);
>
> - pp = (struct pmd_process_private *)
> - rte_zmalloc(NULL, sizeof(struct pmd_process_private),
> - RTE_CACHE_LINE_SIZE);
> + pp = rte_zmalloc(NULL, sizeof(struct pmd_process_private),
> + RTE_CACHE_LINE_SIZE);
>

Not a major issue, but scanning through the existing file it uses more
double-tab indent than aligning with braces. Personally for a refactor like
this I'd just avoid unnecessarily changing the second line. [This is one
reason why I hate this aligning with brackets, if you change the first
line, you have to change the following ones too! Makes refactoring or
renaming have either broken indentation or far larger diffs. Given the
capabilities of AI, I would very much tend towards making our code more
"refactor safe", as changes are less likely to made manually.]

> if (pp == NULL) {
> PMD_LOG(ERR,
> @@ -1590,10 +1589,8 @@ pmd_pcap_probe(struct rte_vdev_device *dev)
> unsigned int i;
>
> internal = eth_dev->data->dev_private;
> - pp = (struct pmd_process_private *)
> - rte_zmalloc(NULL,
> - sizeof(struct pmd_process_private),
> - RTE_CACHE_LINE_SIZE);
> + pp = rte_zmalloc(NULL, sizeof(struct pmd_process_private),
> + RTE_CACHE_LINE_SIZE);
>
> if (pp == NULL) {
> PMD_LOG(ERR,
> --
> 2.51.0
>