On Thu, 11 Jul 2019 09:56:32 +0000 Krzysztof Kanas <kka...@marvell.com> wrote:
> On 19-07-10 09:04, Stephen Hemminger wrote: > > External Email > > > > ---------------------------------------------------------------------- > > On Wed, 10 Jul 2019 16:46:30 +0200 > > <kka...@marvell.com> wrote: > > > > > > > > +#define PMD_LOG_ERRNO(level, fmt, args...) \ > > > + rte_log(RTE_LOG_ ## level, af_packet_logtype, \ > > > + "%s(): " fmt ":%s\n", __func__, ##args, rte_strerror(errno)) > > > + > > > static uint16_t > > > eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) > > > { > > > @@ -603,9 +609,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > > > return -1; > > > } > > > if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) { > > > - PMD_LOG(ERR, > > > - "%s: ioctl failed (SIOCGIFINDEX)", > > > - name); > > > + PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFINDEX)", name); > > > return -1; > > > > This is wrong. > > The ioctl sets errno not rte_errno. > I was following the documentation on rte_strerror, which states: > > For non-RTE-specific error codes, this function returns the value from > the libc strerror function That document is correct, but the intended usage is to do rte_strerror(rte_errno) and since rte_errno values correspond to errno values for system errors it would work. In conclusion, your code will work but is a little confusing.