Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1606656pxb; Mon, 11 Oct 2021 09:21:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK5dWNLxzrt7K/AWG5scKYN/CSyCAXEho6E9BycFB0+YL806E9iE01Ije1sev1aTyAY1O/ X-Received: by 2002:a50:cf87:: with SMTP id h7mr42541767edk.330.1633969292035; Mon, 11 Oct 2021 09:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969292; cv=none; d=google.com; s=arc-20160816; b=S0JlYIqUru8iUpZSkNaYSku1COhXJYQ4Tsa+BM5xljG5eshdTNJ6dl9ZFUMr0B32hy EfUL56FBpjogwY+O/fV1O1xrXhndCIZUGvTVz6G3pPvrs+zpLMC1YhHFkCnbBhQEnWCy u50HTo7135ZRKEBZTprpOWSyFTHZdVP7269B0wYw4TrRgQAObWwJBuPSnQZ2nEuIUcIP Gwt8NV5tDoBxcBeTBnu78ukFygwVQy4bGlE6Bkjw+G+yhjYeGs3YPl5Qus538cc1y0KG 8Y75XUkimm20QbasJx5Z9V0RlaU5c4M2d7+utyAUwGIuOK9XC1GOvbOe4iWrVTfz+uwK hywQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=KEXDnZNyzy8oQajLUrFq+I0axtryIZhAIne0xssEYmE=; b=HJ7oLjMy8RUmSAhqlL9yy2ry7/8BMD3CC3JJuoEAOXBON6PKzttwIRPOC14efV08xX fURgMq0DRxAhGZsTuZbk91qjR2tJ7yxeP8aGtPWPTxgxCK6MvyVFUVorxQsxlyo2sZD3 PS8ujqp46pzd/591/WCdroY79XaZgioLtuTB8b/31YmbAnGwFrYMzv7Ze7p/Dqun2lYK JOFJTQl5bApFgBwNW1cWsyWuz4dwI1R/GOzw1YsvJb3CqIgNm7yi65fcxkyturmDo0yv neDC8qaP+i5aFP6ZIbvm1c+Jd5kftXXYeZv3+9GJLxn3n26x5iSc3ddz5DUxBNrSsx8J P/cA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr14si18081083ejc.16.2021.10.11.09.21.08; Mon, 11 Oct 2021 09:21:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235933AbhJKLXO (ORCPT + 99 others); Mon, 11 Oct 2021 07:23:14 -0400 Received: from mga09.intel.com ([134.134.136.24]:51373 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbhJKLXO (ORCPT ); Mon, 11 Oct 2021 07:23:14 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10133"; a="226751137" X-IronPort-AV: E=Sophos;i="5.85,364,1624345200"; d="scan'208";a="226751137" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 04:21:09 -0700 X-IronPort-AV: E=Sophos;i="5.85,364,1624345200"; d="scan'208";a="490431900" Received: from acleivam-mobl1.amr.corp.intel.com (HELO [10.249.40.144]) ([10.249.40.144]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 04:21:07 -0700 Message-ID: <52742f2b-0cde-26f4-1de2-abe83baa0095@linux.intel.com> Date: Mon, 11 Oct 2021 14:21:17 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v3] checkpatch: get default codespell dictionary path from package location Content-Language: en-US To: apw@canonical.com, joe@perches.com Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com, linux-kernel@vger.kernel.org References: <20211011093748.2455-1-peter.ujfalusi@linux.intel.com> From: =?UTF-8?Q?P=c3=a9ter_Ujfalusi?= In-Reply-To: <20211011093748.2455-1-peter.ujfalusi@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/10/2021 12:37, Peter Ujfalusi wrote: > The standard location of dictionary.txt is under codespell's package, on > my machine atm (codespell 2.1, Artix Linux): > /usr/lib/python3.9/site-packages/codespell_lib/data/dictionary.txt > > Since we enable the codespell by default for SOF I have constant: > No codespell typos will be found - \ > file '/usr/share/codespell/dictionary.txt': No such file or directory > > The patch proposes to try to fix up the path following the recommendation > found here: > https://github.com/codespell-project/codespell/issues/1540 > > Signed-off-by: Peter Ujfalusi > --- > Hi, > > Changes since v2: > - Only try to check for dictionary path it is enabled or when the help is > displayed > - Move the check after the GetOptions() > - Set $help to 2 in case invalid option is passed in order to be able to use > correct exitcode and still display the correct path for dictionary.txt > > Changes sicne v1: > - add missing ';' to the line updating the $codespellfile with $codespell_dict > > Regards, > Peter > > scripts/checkpatch.pl | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index c27d2312cfc3..179e02acab6e 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -130,7 +130,7 @@ Options: > --ignore-perl-version override checking of perl version. expect > runtime errors. > --codespell Use the codespell dictionary for spelling/typos > - (default:/usr/share/codespell/dictionary.txt) > + (default:$codespellfile) > --codespellfile Use this codespell dictionary > --typedefsfile Read additional types from this file > --color[=WHEN] Use colors 'always', 'never', or only when output > @@ -325,9 +325,19 @@ GetOptions( > 'kconfig-prefix=s' => \${CONFIG_}, > 'h|help' => \$help, > 'version' => \$help > -) or help(1); > +) or $help = 2; > > -help(0) if ($help); > +print($help); > + > +# Override the codespellfile location based on codespell install location > +if (($codespell || $help) && which("codespell") ne "" && which("python") ne "") { > + my $codespell_dict = `python -c "import os.path as op; import codespell_lib; print(op.join(op.dirname(codespell_lib.__file__), 'data', 'dictionary.txt'), end='')" 2> /dev/null`; > + $codespellfile = $codespell_dict if (-e $codespell_dict); Hrm, I think this will prevent the use of --codespellfile > +} > + > +# $help is 1 if either -h, --help or --version is passed as option - exitcode: 0 > +# $help is 2 if invalid option is passed - exitcode: 1 > +help($help - 1) if ($help); > > die "$P: --git cannot be used with --file or --fix\n" if ($git && ($file || $fix)); > die "$P: --verbose cannot be used with --terse\n" if ($verbose && $terse); > -- Péter