Hi Stephen, > -----Original Message----- > From: Stephen Hemminger <step...@networkplumber.org> > Sent: Wednesday, March 22, 2023 10:59 PM > To: Bing Zhao <bi...@nvidia.com> > Cc: Slava Ovsiienko <viachesl...@nvidia.com>; Matan Azrad > <ma...@nvidia.com>; dev@dpdk.org; Raslan Darawsheh > <rasl...@nvidia.com>; sta...@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 <bi...@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.