scripts: coccicheck: fix troubles on non-English builds
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 18 May 2021 09:05:26 +0000 (11:05 +0200)
committerJulia Lawall <Julia.Lawall@inria.fr>
Tue, 18 May 2021 09:09:59 +0000 (11:09 +0200)
When LANG is not set to English, the logic which checks the
number of CPUs fail, as the messages can be localized, and
the logic at:

    THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")

will not get the number of threads per core.

This causes the script to not run properly, as it will produce
a warning:

$ make coccicheck COCCI=$PWD/scripts/coccinelle/misc/add_namespace.cocci MODE=report drivers/media/
./scripts/coccicheck: linha 93: [: nĂºmero excessivo de argumentos

Fix it by forcing LANG=C when calling lscpu.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
scripts/coccicheck

index 65fee63aeadba55ebf74959434842ead7d3354c4..caba0bff6da7ed2937237765a3241b77c9be8c22 100755 (executable)
@@ -87,7 +87,7 @@ else
     fi
 
     # Use only one thread per core by default if hyperthreading is enabled
-    THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")
+    THREADS_PER_CORE=$(LANG=C lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")
     if [ -z "$J" ]; then
         NPROC=$(getconf _NPROCESSORS_ONLN)
        if [ $THREADS_PER_CORE -gt 1 -a $NPROC -gt 4 ] ; then