On Wed, Apr 03, 2019 at 08:51:32AM -0700, Stephen Hemminger wrote:
> On Wed,  3 Apr 2019 15:45:04 +0100
> Bruce Richardson <bruce.richard...@intel.com> wrote:
> 
> > diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c
> > index d215acecc..a542f6f5d 100644
> > --- a/lib/librte_ring/rte_ring.c
> > +++ b/lib/librte_ring/rte_ring.c
> > @@ -78,7 +78,7 @@ rte_ring_init(struct rte_ring *r, const char *name, 
> > unsigned count,
> >  
> >     /* init the ring structure */
> >     memset(r, 0, sizeof(*r));
> > -   ret = snprintf(r->name, sizeof(r->name), "%s", name);
> > +   ret = strlcpy(r->name, name, sizeof(r->name));
> >     if (ret < 0 || ret >= (int)sizeof(r->name))
> 
> I would rather use the name length that is part of the header file.
> 
>       if (strnlen(name, RTE_RING_NAMESIZE) == RTE_RING_NAMESIZE)
>               return -ENAMETOOLONG;
> 
>       strlcpy(r->name, name, sizeof(r->name))
>
Yes, though honestly it's a matter of preference. Since this was a scripted
replacement each change wasn't checked in too much detail other than a
cursory check for correctness.

Reply via email to