From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by dpdk.org (Postfix) with ESMTP id 7F3641B90A for ; Fri, 14 Dec 2018 19:36:11 +0100 (CET) Received: by mail-pg1-f172.google.com with SMTP id z11so3082351pgu.0 for ; Fri, 14 Dec 2018 10:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yocLPCiJr6uFLQYN/GYH9KE6nx+TIhXf0bgqHXf3l+8=; b=h2Wj1+9+T9kt/4yIgFAew7YsTd2b1hhiGahC07E9wZY5GZoXzbw7Mh/5E4MBVj74Oq Ga40gp5UNlCwgysAHOybQOCBtZTYCrLmJu4ou8YpkNHsEIomHMfIoagRkQj2FNEGVoKF rrJBZ+bixs10X0N4LfXYGiG/Y+L6hzXVcxBMzauadM1CyT//yubQda4Bg74RJpdOe1+h 1ccTNmG9W/cHIwSwX23eWG20vDYMxHfyBt8zGoQdjbVESZLeI8Zs7cKPidDzHduLyvpN 9kYt18AoZlRr2V/SRZXD/nxT7t/rpd1qdngEkb9jAUTgB0gPxan+zwskK3Bg3O1Q8pt+ XtzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yocLPCiJr6uFLQYN/GYH9KE6nx+TIhXf0bgqHXf3l+8=; b=slOec2AaT0VLeaeT93mjTRcDFrFpkJdjYjPrO7LxOkGSRRAdEHcfOLPvFFd6py88CX Zrlt1X9EebB9oCZc1UzUDKTqM2CtCSAxlToTmob+D71Ncv4i1SRJ/Qb2tSRe8KstD19M ooZhZTeslFbXliydC1ZKub8sykKs9sghq1l2JWmTyrSUQgcR2BfCwoPmqw7FfMSGJlSU nM/hxVTsUDXa1MmmcZ7zPsUOVyKmZP3bPnFj/l7CR9i68mXpIMmYOmFi1g5nmVvjx5uM khJ9oF6Mhujg4kyD8EbcsDUriyX+je8mXH5yziat6Lm68pJnm2f6wkKKWI+XUvfLdjSA umpw== X-Gm-Message-State: AA+aEWb85owGIui2mc9L8vALc1PtlodAxMuFWl0zx+pThxDFDZvE5Dw/ 6bpHAGrv1KllUGdXBK03EGz/fQ== X-Google-Smtp-Source: AFSGD/V28I0m48AVEDe39BAtKnOAGKYjkavMGgsvmSMpp9HVnVqFmb4FWBFn6z7Rhh6eGFPlim13iw== X-Received: by 2002:a63:e445:: with SMTP id i5mr3626887pgk.307.1544812570458; Fri, 14 Dec 2018 10:36:10 -0800 (PST) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id r130sm12446895pfr.48.2018.12.14.10.36.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Dec 2018 10:36:10 -0800 (PST) Date: Fri, 14 Dec 2018 10:36:03 -0800 From: Stephen Hemminger To: Jeff Shaw Cc: dev@dpdk.org Message-ID: <20181214103603.59336e0e@xeon-e3> In-Reply-To: <20181214163827.9403-1-jeffrey.b.shaw@intel.com> References: <20181214163827.9403-1-jeffrey.b.shaw@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH] eal: remove variable length array 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: , X-List-Received-Date: Fri, 14 Dec 2018 18:36:11 -0000 On Fri, 14 Dec 2018 08:38:27 -0800 Jeff Shaw wrote: > Compilers that do not support the C11 standard, or do not implement > gcc extensions, may not support variable length arrays. >=20 > The code prior to this commit produced the following warning when > compiled with "-Wvla -std=3Dc90". >=20 > warning: ISO C90 forbids variable length array =E2=80=98array=E2=80=99 = [-Wvla] >=20 > This commit removes the variable length array from the PMD debug > trace function by allocating memory dynamically on the stack using > alloca(). >=20 > Signed-off-by: Jeff Shaw > --- > lib/librte_eal/common/include/rte_dev.h | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) >=20 > diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/com= mon/include/rte_dev.h > index a9724dc91..af772872b 100644 > --- a/lib/librte_eal/common/include/rte_dev.h > +++ b/lib/librte_eal/common/include/rte_dev.h > @@ -47,22 +47,21 @@ __attribute__((format(printf, 2, 0))) > static inline void > rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) > { > + char *buffer; > + int buf_len; > va_list ap; > =20 > va_start(ap, fmt); > + buf_len =3D vsnprintf(NULL, 0, fmt, ap) + 1; > + va_end(ap); > =20 > - { > - char buffer[vsnprintf(NULL, 0, fmt, ap) + 1]; > + buffer =3D (char *)alloca(buf_len); alloca is void * so cast is not necessary. You might be able to skip the buffering step entirely by using rte_log a little more creatively, see how other logging works. But to go further since rte_pmd_debug_trace is not used anywhere in current code base in DPDK, it should just be removed.