Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30EBDC2D0A8 for ; Wed, 23 Sep 2020 10:25:45 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id ABEC220658 for ; Wed, 23 Sep 2020 10:25:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABEC220658 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org 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.