[PATCH v2] common/mlx5: fix the sysfs port name translation

Bing Zhao bingz at nvidia.com
Thu Mar 23 09:20:21 CET 2023


Hi Stephen,

> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Wednesday, March 22, 2023 10:59 PM
> To: Bing Zhao <bingz at nvidia.com>
> Cc: Slava Ovsiienko <viacheslavo at nvidia.com>; Matan Azrad
> <matan at nvidia.com>; dev at dpdk.org; Raslan Darawsheh
> <rasland at nvidia.com>; stable at dpdk.org
> Subject: Re: [PATCH v2] common/mlx5: fix the sysfs port name translation
> 
> External email: Use caution opening links or attachments
> 
> 
> On Wed, 22 Mar 2023 13:34:12 +0200
> Bing Zhao <bingz at nvidia.com> wrote:
> 
> > +
> > +             port_name = (char *)malloc(IF_NAMESIZE);
> > +             if (port_name == NULL) {
> > +                     fclose(file);
> > +                     rte_errno = ENOMEM;
> > +                     return -rte_errno;
> > +             }
> > +             line_size = getline(&port_name, &port_name_size, file);
> 
> This code is doing unnecessary extra work here.
> From getline() man page:

Yes, I also checked the description of this interface before. The original purpose was to allocate / free the memory explicitly.
This will be removed.

> 
>      If *lineptr is set to NULL before the call, then getline() will
>        allocate a buffer for storing the line.  This buffer should be
>        freed by the user program even if getline() failed.


More information about the stable mailing list