From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7E9BA04B1; Wed, 23 Sep 2020 12:25:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F050A1DABD; Wed, 23 Sep 2020 12:25:41 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 385C21C1C4; Wed, 23 Sep 2020 12:25:40 +0200 (CEST) IronPort-SDR: 47m+7q0gLL3DfJPknjUbYGbXPVoFycPqGbQQCpePgGtb7ZkCyCIyU2LN7ptia+eTI57iruWPg9 Z+hUoOuLtPmw== X-IronPort-AV: E=McAfee;i="6000,8403,9752"; a="158206094" X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="158206094" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2020 03:25:38 -0700 IronPort-SDR: dJESUw46pIHpsIaUqoOdNJC38+Zo7+gBT+cgqOxrSQagzVuXobsRUZvJF7rXSFmBEgP9Tygkop lSprWLlzyk+Q== X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="486385742" Received: from bricha3-mobl.ger.corp.intel.com ([10.213.7.171]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 23 Sep 2020 03:25:36 -0700 Date: Wed, 23 Sep 2020 11:25:32 +0100 From: Bruce Richardson To: David Marchand Cc: Kevin Laatz , dev , "Yigit, Ferruh" , dpdk stable Message-ID: <20200923102532.GA1760@bricha3-MOBL.ger.corp.intel.com> References: <20200922172015.266698-1-kevin.laatz@intel.com> <20200923093927.GA1757@bricha3-MOBL.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dpdk-dev] [PATCH] net/ring: fix unchecked return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Sep 23, 2020 at 11:43:31AM +0200, David Marchand wrote: > On Wed, Sep 23, 2020 at 11:39 AM Bruce Richardson > wrote: > > I think a more standard way of checking for trailing chars is to use %n > > which stores the number of chars processed. Then check that against > > strlen. > > > > For example something like: > > > > if (sscanf(value, "%p%n", args, n) != 1 || n != strlen(value)) { > > /* do error handling */ > > } > > > > The man is a bit scary about %n: > > The C standard says: "Execution of a %n directive does not increment > the assignment count returned at the completion of execution" but the > Corrigendum seems to contradict this. Probably it is wise not to make > any assumptions on the effect of %n conversions on the return value. > That's not in the man page on my system (Ubuntu 20.04): n Nothing is expected; instead, the number of characters consumed thus far from the input is stored through the next pointer, which must be a pointer to int. This is not a conversion and does not increase the count returned by the function. The assignment can be suppressed with the * assignment- suppression character, but the effect on the return value is undefined. Therefore %*n conversions should not be used.