[dpdk-dev] [PATCH v4 09/18] net/qede: strncpy length constant and NUL

Shaikh, Shahed Shahed.Shaikh at cavium.com
Fri May 11 19:13:30 CEST 2018



> > >>
> > >> +#include <rte_string_fns.h>
> > >> +
> > >>   #include "bcm_osal.h"
> > >>   #include "ecore.h"
> > >>   #include "ecore_spq.h"
> > >> @@ -1104,9 +1106,9 @@ static enum _ecore_status_t
> > >> ecore_int_deassertion(struct ecore_hwfn *p_hwfn,
> > >>   							      p_aeu->bit_name,
> > >>   							      num);
> > >>   					else
> > >> -						OSAL_STRNCPY(bit_name,
> > >> -							     p_aeu->bit_name,
> > >> -							     30);
> > >> +						strlcpy(bit_name,
> > >> +							p_aeu->bit_name,
> > >> +							sizeof(bit_name));
> > >>
> > >>   					/* We now need to pass bitmask in its
> > >>   					 * correct position.
> > >
> > > I'd say it should be better to change OSAL_STRNCPY to OSAL_STRLCPY
> > > and modify the macro to use strlcpy, so we avoid further uses of that strlcpy.
> > >
> > > However, this modifies base driver code, so it is up to the
> > > maintainers to make
> > that decision.
> > > (CC'ing maintainers here).
> >
> > There's no value for any OSAL_* that simply defines itself to be the
> > same as the direct api, as does OSAL_STRNCPY.
> >
> > It's better to just remove any OSAL_* that calls straight through
> > since all it does is obfuscate what the code does, for no benefit.
> 
> I agree. Since this is modifying base driver code, the maintainers can decide
> what to do with this.

Hi,

For this series, you can continue with s/OSAL_STRNCPY/strlcpy/ for this instance.
I will send a patch to cleanup OSAL_* once your series gets applied.

Thanks,
Shahed


More information about the dev mailing list