Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3365316pxk; Mon, 7 Sep 2020 10:46:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk7mU/J+5sC6V0p2/3xYii3M6Oj+aHtnRxygzQZja/bRcrUm6oSQCPTsbe3eP3VwPjEvz4 X-Received: by 2002:a17:906:f1d5:: with SMTP id gx21mr20842647ejb.165.1599500763589; Mon, 07 Sep 2020 10:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599500763; cv=none; d=google.com; s=arc-20160816; b=hiDQBVTp5fJ3mrdJRGVnzyJc76RD3bBffCk5EERvXr0TI2IOkfx+CXqh6eS4oGqtmp 1tDlWwkj7biI+sPXa7kz5VWzvYjGha+0yXfUdNf9MAwd/8V4LZ9JsfcVToYzMG+vLFoB gsk86siBL5sv6GeLKMCWH8UmI4SEVHOzdvBCNwtD3Z7GaMYm9AEclDcuxtv/1DcCtbEV auuam1Djbdcn0WZCzN8g3yx2Je3bGYm1KaJ3uxeMR7Sf1sn6JnDzDWEUoXrlkyt2Vx2K sIBOyoAODirjGl+mt/wJnRbV3tZtb+T4/TQvS1xBb/Cxc5fLrKqAxPb/0K/+PlE2Opz2 l3WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=tXlaUzLwVVKkp2nug9LSgDtLZzxwlV3OQrTwOaM4mCk=; b=SNs2V+WBbC/Ge3fGUnblC3iv4pkuiyvY1/J+v1eeWAoJ8uDuNqfDjmY9Bg/2hrcrbY /fGDGqbG5aQ2lIIzXP3/MP9G1gCz8z386coES9YNGTnPIkuJqWtM/Gzv7b4lrxZKz15T r2D06luoQ/hCSuNAJBAifnXPVG4B+X4cwCQkMiVSuxjI1OalMTHcoDy3+KsAPquMYrbT VQike6iNrzscSu3zDQqgaJxAlgCx3ujN9GcGwKyLqKujuhe4yylQB4Je8NulcaDfECNt 1kh1FMTaazbMFpvK2Jme+ewk+oem7dsuTITwl3p3vyqmf5ZIhE9iB60HmrQCfkpTOhdv dyDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KDZFrT3F; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si10179635edq.395.2020.09.07.10.45.41; Mon, 07 Sep 2020 10:46:03 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KDZFrT3F; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbgIGRnJ (ORCPT + 99 others); Mon, 7 Sep 2020 13:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729408AbgIGNRv (ORCPT ); Mon, 7 Sep 2020 09:17:51 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBB79C061573 for ; Mon, 7 Sep 2020 06:17:48 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id 5so8040692pgl.4 for ; Mon, 07 Sep 2020 06:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=tXlaUzLwVVKkp2nug9LSgDtLZzxwlV3OQrTwOaM4mCk=; b=KDZFrT3FUBB8HCrkkMnC0JoRhryFVJVEbvDoEnKDDDrbvyB1TEY+8XUaj7rYgbZ/mE pVjrk4ACiNUHNmMPKLOjaKbZQlbMonq3ZFL3mERUDc3PX5h68nkuoyhrTvv9JxePD0kW TdllSXmLkyy25eJXKuv53OIv5xdVOsCLwYpUJppm6Q9T0SKTUBmAdxGiEvTdHUPhKqO1 ScGUoNxdA+/n1icMgAKHFSzzZdT6U2Kh8eL7I7KHV67SvAL7C3z8UeEBGPoxDGsb6/RX Rn8WBCMmfRBR9I2CuMyrkhRhZ965+5KzcxjIjRUMnNhO94DUwtpvZnQahfveNNOKntNw bXLQ== 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:mime-version :content-disposition; bh=tXlaUzLwVVKkp2nug9LSgDtLZzxwlV3OQrTwOaM4mCk=; b=VP+waZrS/JmuC58ZXH0uf/lX5Gv32CAFz+dgFjRnNZFnwZnlrAH8l6Fxc/oOorMr5x 0sMJGHL7Qjsp24jpzBBvcmD6bZjYz5t7zWMAlX8caNOz8nvdlLgz5mwA0ES1nUH6UTjc hc8QM4ucB3t4GC15OEo4TY5NfxqI6B2zxShV/ARndlY0zOjJr5jQA93NXYS8WMwTGMP8 DD/nZnrvYQPdbGdSus4l5awvwwwyE0lODuGnr7gCnWIcSu/1nJzYBFjgokCw+l+yiaAd kzCzL1SykC3Zu94uecYofr6QeU2Ot2CDyj4FkEGBiAmBMQ4debzEsFZ3wdnf8YGuK7rJ jz2A== X-Gm-Message-State: AOAM532qJMnVTeSrYcH6jrDn5XngI3AQxBO/udxEoNoJ/USfxxRC+wMq I8such+ZtPUnTzNgfAIWKa7njBZFdc5DlkAP X-Received: by 2002:a62:fccf:: with SMTP id e198mr20409326pfh.183.1599484668372; Mon, 07 Sep 2020 06:17:48 -0700 (PDT) Received: from adolin ([49.207.196.129]) by smtp.gmail.com with ESMTPSA id m13sm5229752pjl.45.2020.09.07.06.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 06:17:47 -0700 (PDT) Date: Mon, 7 Sep 2020 18:47:44 +0530 From: Sumera Priyadarsini To: Julia.Lawall@lip6.fr Cc: Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, michal.lkml@markovi.net, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Subject: [PATCH] scripts: coccicheck: Do not use shift command when rule is specfified Message-ID: <20200907131744.xovlxbmrzrfm2w3x@adolin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Makfeile. However, when coccicheck is specified in the make command as a rule, number of shell arguments is zero, thus paasing the invalid value -1 to the shift command, resuting in an error. This patch modifies coccicheck to use the shift command only when number of shell arguments is not zero. Signed-off-by: Sumera Priyadarsini --- scripts/coccicheck | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/coccicheck b/scripts/coccicheck index e04d328210ac..5c8df337e1e3 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -61,9 +61,19 @@ COCCIINCLUDE=${COCCIINCLUDE// -include/ --include} if [ "$C" = "1" -o "$C" = "2" ]; then ONLINE=1 - # Take only the last argument, which is the C file to test - shift $(( $# - 1 )) - OPTIONS="$COCCIINCLUDE $1" + # If the rule coccicheck is specified when calling make, number of + # arguments is zero + if [ $# -ne 0 ]; then + # Take only the last argument, which is the C file to test + shift $(( $# -1 )) + OPTIONS="$COCCIINCLUDE $1" + else + if [ "$KBUILD_EXTMOD" = "" ] ; then + OPTIONS="--dir $srctree $COCCIINCLUDE" + else + OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE" + fi + fi # No need to parallelize Coccinelle since this mode takes one input file. NPROC=1 -- 2.25.1