Hi Stephen, > -----Original Message----- > From: Stephen Hemminger <step...@networkplumber.org> > Sent: Tuesday, June 1, 2021 1:38 PM > To: Xia, Chenbo <chenbo....@intel.com> > Cc: dev@dpdk.org; tho...@monjalon.net; Liang, Cunming > <cunming.li...@intel.com>; Wu, Jingjing <jingjing...@intel.com>; Burakov, > Anatoly <anatoly.bura...@intel.com>; Yigit, Ferruh <ferruh.yi...@intel.com>; > m...@ashroe.eu; nhor...@tuxdriver.com; Richardson, Bruce > <bruce.richard...@intel.com>; david.march...@redhat.com; Ananyev, Konstantin > <konstantin.anan...@intel.com>; Tiwei Bie <tiwei....@intel.com> > Subject: Re: [RFC v3 4/6] eal: add a helper for reading string from sysfs > > On Tue, 1 Jun 2021 11:06:42 +0800 > Chenbo Xia <chenbo....@intel.com> wrote: > > > +int > > +rte_eal_parse_sysfs_str(const char *filename, char *buf, unsigned long sz) > > +{ > > + FILE *f; > > + > > + f = fopen(filename, "r"); > > + if (f == NULL) { > > + RTE_LOG(ERR, EAL, "%s(): cannot open sysfs file %s\n", > > + __func__, filename); > > + return -1; > > + } > > + > > + if (fgets(buf, sz, f) == NULL) { > > + RTE_LOG(ERR, EAL, "%s(): cannot read sysfs file %s\n", > > + __func__, filename); > > + fclose(f); > > + return -1; > > + } > > + > > + fclose(f); > > + return 0; > > +} > > It would be helpful if function removed trailing newline. > strchrnul(buf, '\n') = '\0';
Make sense. Will fix it. Thanks, Chenbo