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.
- [dpdk-dev] [PATCH 0/5] clean up snprintf use for string ... Bruce Richardson
- [dpdk-dev] [PATCH 1/5] net/bonding: fix buffer leng... Bruce Richardson
- Re: [dpdk-dev] [PATCH 1/5] net/bonding: fix buf... Stephen Hemminger
- Re: [dpdk-dev] [PATCH 1/5] net/bonding: fix... Bruce Richardson
- Re: [dpdk-dev] [PATCH 1/5] net/bonding:... Stephen Hemminger
- [dpdk-dev] [PATCH 3/5] devtools/cocci: create safer... Bruce Richardson
- [dpdk-dev] [PATCH 2/5] devtools/cocci: make strlcpy... Bruce Richardson
- [dpdk-dev] [PATCH 4/5] replace snprintf with strlcp... Bruce Richardson
- Re: [dpdk-dev] [PATCH 4/5] replace snprintf wit... Stephen Hemminger
- Re: [dpdk-dev] [PATCH 4/5] replace snprintf... Bruce Richardson
- Re: [dpdk-dev] [PATCH 4/5] replace snpr... Thomas Monjalon
- [dpdk-dev] [PATCH 5/5] replace snprintf with strlcp... Bruce Richardson
- Re: [dpdk-dev] [PATCH 0/5] clean up snprintf use fo... Wiles, Keith
- Re: [dpdk-dev] [PATCH 0/5] clean up snprintf us... Bruce Richardson
- Re: [dpdk-dev] [PATCH 0/5] clean up snprintf us... Stephen Hemminger
- Re: [dpdk-dev] [PATCH 0/5] clean up snprintf use fo... Thomas Monjalon