Hi, On 02/02/2015 03:02 AM, Cunming Liang wrote: > The problem is that strnlen() here may return invalid value with 32bit icc. > (actually it returns it?s second parameter,e.g: sysconf(_SC_ARG_MAX)). > It starts to manifest hwen max_len parameter is > 2M and using icc ?m32 ?O2 > (or above). > > Suggested-by: Konstantin Ananyev <konstantin.ananyev at intel.com> > Signed-off-by: Cunming Liang <cunming.liang at intel.com> > --- > lib/librte_eal/common/eal_common_options.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_options.c > b/lib/librte_eal/common/eal_common_options.c > index 29ebb6f..22d5d37 100644 > --- a/lib/librte_eal/common/eal_common_options.c > +++ b/lib/librte_eal/common/eal_common_options.c > @@ -227,7 +227,7 @@ eal_parse_corelist(const char *corelist) > /* Remove all blank characters ahead and after */ > while (isblank(*corelist)) > corelist++; > - i = strnlen(corelist, sysconf(_SC_ARG_MAX)); > + i = strnlen(corelist, PATH_MAX); > while ((i > 0) && isblank(corelist[i - 1])) > i--; > > @@ -469,7 +469,7 @@ eal_parse_lcores(const char *lcores) > /* Remove all blank characters ahead and after */ > while (isblank(*lcores)) > lcores++; > - i = strnlen(lcores, sysconf(_SC_ARG_MAX)); > + i = strnlen(lcores, PATH_MAX); > while ((i > 0) && isblank(lcores[i - 1])) > i--; > >
I think PATH_MAX is not equivalent to _SC_ARG_MAX. But the main question is: why do we need to use strnlen() here instead of strlen? We can expect that argv[] pointers are always nul-terminated. Replacing them by strlen() would probably also solve the icc issue. Regards, Olivier