Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3747928pxb; Tue, 17 Nov 2020 02:25:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzep7tpVTVvBIKsSRMjmEY+3xBSmAP7EtnZiLqd7R79SmX6kuTn0BDWfvKtWYU/1ICYxRL9 X-Received: by 2002:a17:906:8812:: with SMTP id zh18mr17861123ejb.361.1605608721125; Tue, 17 Nov 2020 02:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605608721; cv=none; d=google.com; s=arc-20160816; b=ET7wk62kFRzVMUxpue8sK60hGk37/OvlK9JgUmwSGr9pxnwUMZj1NYAVZvVFTEzj4N JU1wfqXjuv8INAp4CFD2CWPOyRBw3ceMQuxx+lwNcZq2bliYURD4wPUyHXaxuV0n/0u8 0xDdTy7z9Xzyle3arAI49hsONM6Oqk9ZZopmtuVppNCoiBN0vq+8RkLS2OK5j5ZPjMRu UcZVjHSAq3Z7YFmeL9PqoqBZzb1gjunSGilaAJyXQMnwE8bhT+GTScORnSVQoEsNMvCj /tP+8mZIaVEhy/QzFqtN9295GfKgBt/Z3HylfR/hMP+wvXgxmZXINFHWegXfkcbxf9mL 8uAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=NAAjJHjCzp5fnpoKL3yQiYbTzsUQi7dCfFb9mWjCsBA=; b=fSZ8lsJTRs+S6LIP2jQOJXCqQXJDDoZyFuxHCH6CJcgnDIyyFNtQswwAL3FPkF2fQu wWgD+euC5jIJ9qLB2QKUKdPuM91FtEsPIdKfVqc3J1blOxrlv8C7pyE2vBdlmjvtnUGU uf5BYNIyELUIPWTsqTQzPsF3GL64cM5InYSCVBBzM5bfAGVYCtvMEaqZF8FG20fm8HYf APNHbpInTuIHQumC/RXzLq8rLwKwKZYq6QbRD51GTEKRD2+nQI9E+0ac8PKzHknwSzAy 1P4bD9ncN2NS0c8hp2PamG+QTEcjGlrKIw8jXUIYaeLRAQnlNlh8+3fyirZ0TfndU272 1bjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si13973120edy.510.2020.11.17.02.24.58; Tue, 17 Nov 2020 02:25:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbgKQKXC (ORCPT + 99 others); Tue, 17 Nov 2020 05:23:02 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:62149 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgKQKXB (ORCPT ); Tue, 17 Nov 2020 05:23:01 -0500 X-IronPort-AV: E=Sophos;i="5.77,485,1596492000"; d="scan'208";a="364778174" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2020 11:22:35 +0100 Date: Tue, 17 Nov 2020 11:22:34 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Sumera Priyadarsini cc: Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, michal.lkml@markovi.net, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH] scripts: coccicheck: Correct usage of make coccicheck In-Reply-To: <20201111111256.ea5l7slw4cc2fggm@adolin> Message-ID: References: <20201111111256.ea5l7slw4cc2fggm@adolin> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Nov 2020, Sumera Priyadarsini wrote: > The command "make coccicheck C=1 CHECK=scripts/coccicheck" results in the > error: > ./scripts/coccicheck: line 65: -1: shift count out of range > > This happens because every time the C variable is specified, > the shell arguments need to be "shifted" in order to take only > the last argument, which is the C file to test. These shell arguments > mostly comprise flags that have been set in the Makefile. However, > when coccicheck is specified in the make command as a rule, the > number of shell arguments is zero, thus passing the invalid value -1 > to the shift command, resulting in an error. > > Modify coccicheck to print correct usage of make coccicheck so as to > avoid the error. With this, one still gets the error from shift. Could you move the test so that one only gets the error message? julia > > Signed-off-by: Sumera Priyadarsini > --- > scripts/coccicheck | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/scripts/coccicheck b/scripts/coccicheck > index 209bb0427b43..b990c8a60a94 100755 > --- a/scripts/coccicheck > +++ b/scripts/coccicheck > @@ -63,6 +63,18 @@ if [ "$C" = "1" -o "$C" = "2" ]; then > > # Take only the last argument, which is the C file to test > shift $(( $# - 1 )) > + err=$? > + if [[ $err -ne 0 ]]; then > + echo '' > + echo 'Specifying both the variable "C" and rule "coccicheck" in the make > +command results in a shift count error.' > + echo '' > + echo 'Try specifying "scripts/coccicheck" as a value for the CHECK variable instead.' > + echo '' > + echo 'Example: make C=2 CHECK=scripts/coccicheck drivers/staging/wfx/hi_t.o' > + echo '' > + exit 1 > + fi > OPTIONS="$COCCIINCLUDE $1" > > # No need to parallelize Coccinelle since this mode takes one input file. > -- > 2.25.1 > >