From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 42548903 for ; Sun, 8 Feb 2015 21:00:08 +0100 (CET) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YKY58-0005PF-Vv; Sun, 08 Feb 2015 21:03:55 +0100 Message-ID: <54D7C03D.8030204@6wind.com> Date: Sun, 08 Feb 2015 20:59:57 +0100 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: Cunming Liang , dev@dpdk.org References: <1422491072-5114-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-1-git-send-email-cunming.liang@intel.com> <1422842559-13617-4-git-send-email-cunming.liang@intel.com> In-Reply-To: <1422842559-13617-4-git-send-email-cunming.liang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v4 03/17] eal: fix wrong strnlen() return value in 32bit icc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Feb 2015 20:00:08 -0000 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 > Signed-off-by: Cunming Liang > --- > 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