From patchwork Fri Dec 6 13:03:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11276103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28CE813B6 for ; Fri, 6 Dec 2019 13:03:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0618521835 for ; Fri, 6 Dec 2019 13:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575637414; bh=Svrynssv+pAbLWX5q6TOvwpz7p6/oXocxZvSEBevbK0=; h=From:To:Cc:Subject:Date:List-ID:From; b=MDti7f0CPqHw9Lgw8i7YwcnMa0qDB6zf0FrlPIdLJqHOi9sDNETg4x0cGXxopSbBj 8eQ1IORlNr++JVOcnEJ6esZLYnqaCPlaWDV762yEighU6rFVPAU48DL/Mdkk/LX1Gh 9bH3uDuxig1Cd3K64CYgFVKk3KVp4unAzOIOKXaU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726246AbfLFNDd (ORCPT ); Fri, 6 Dec 2019 08:03:33 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:45594 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbfLFNDd (ORCPT ); Fri, 6 Dec 2019 08:03:33 -0500 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id xB6D34Go005873; Fri, 6 Dec 2019 22:03:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xB6D34Go005873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1575637385; bh=4stJbos6zT3j7PistBFOOfUOCop0dkMXYxlz1QqamUc=; h=From:To:Cc:Subject:Date:From; b=BCHpRiAb+2t4Es1WaG6qGk3K48C3sN+SD+ODGXTZULJC6Gw39AoSRWGH9ykwf6pqs WE/pXz/h0ARUV1EfwaXvgVmraNMSUt7fo4hAAzip51w0CJv98iSZR9DIHV8U3hhJgv Wc34hkgeDO798FGAFfZXkO7yBa+W6QISIf4HpZigtFkue+xUYCyB88p5ecNoo77Dng 3n4Q/ZpdDQ3+7DDM6ESiPgh+rzpPcdje3oyi3K4PmLnDyBK7YSudy3XMiqoz2VrBXZ AVBOg/uc2M7lyrmn/GPuFSvjqCBK9Ag8txJqTgv1fqejxt3OpltaLgwUEm2FlrwMoy 7hQIzVZTOdXNA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mkcompile_h: git rid of UTS_TRUNCATE from LINUX_COMPILE_{BY,HOST} Date: Fri, 6 Dec 2019 22:03:01 +0900 Message-Id: <20191206130302.11473-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org UTS_VERSION is set to struct uts_namespace, hence a too long string should be truncated so it fits in 64 characters. On the other hand, LINUX_COMPILE_BY/HOST are not set to uts_namespace. They are just used in the banners, which do not have specific length limitation. I dug into the git history, but I could not find the reason why these two strings must fit in 64 characters. Remove them. Now that UTS_VERSION is the only user of UTS_TRUNCATE, I squashed it. Signed-off-by: Masahiro Yamada --- scripts/mkcompile_h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index d1d757c6edf4..3097fec1756a 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -55,12 +55,10 @@ CONFIG_FLAGS="" if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi -UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP" # Truncate to maximum length - UTS_LEN=64 -UTS_TRUNCATE="cut -b -$UTS_LEN" +UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)" # Generate a temporary compile.h @@ -69,10 +67,10 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" echo \#define UTS_MACHINE \"$ARCH\" - echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" + echo \#define UTS_VERSION \"$UTS_VERSION\" - echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" - echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" + echo \#define LINUX_COMPILE_BY \"$LINUX_COMPILE_BY\" + echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\" echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" } > .tmpcompile From patchwork Fri Dec 6 13:03:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11276105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCB97138C for ; Fri, 6 Dec 2019 13:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB3D721835 for ; Fri, 6 Dec 2019 13:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575637420; bh=1P4JJX8/2H20+EM+DrAXFfSI4JjlzpxUMZw4FcxpDLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tkC7osi0SNFdn+YEK2UWXsxC7Cc4iA/A/2G073l+k+9B9GqW7QdAM7O/3mSVe38sk fejhz9CJJyTRYLVnp+at/dSvOL1gb7AmGYDq+7l7nXANNREe13RiLGF0TIoumyBNVj vfdIXUIOvNmwmfODzWXDJ93wEul7qA8nTuPkKeEc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726128AbfLFNDg (ORCPT ); Fri, 6 Dec 2019 08:03:36 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:45593 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbfLFNDd (ORCPT ); Fri, 6 Dec 2019 08:03:33 -0500 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id xB6D34Gp005873; Fri, 6 Dec 2019 22:03:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xB6D34Gp005873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1575637387; bh=ekwM9UUGKGl3f+58UAKf0ESmjI1Emgokd72qoh9WRnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yhoE4qNwV+ZeVhLWKFj3IQCl3XNJt03vtMY2I1LAWMZyj0ZoXgeaL/tMGmv1DeKH7 Q+/8JyBFo10WNHvx6Hb/2K4aQ0rI81KnCUU6T94z+Lm+IgSi6P6VTjYls8xGglxFf3 WN01PAPEUKI5advI/4ft1YMlBOQeovQd9ifuYDa2a0kOgvyeVOYKQWoAuL+WxojluZ 5XXcPUU4rLc4p1hvkfOF5JTp+D7hJ4P7N9/LMvwUpDxfWO2BLouLws10pyXCvzjamT O/TpMjtTgHbfKzD7udhU6R03WiuCYBSYj5HonVVyg945tpHkiD0SkZt6FenaPaxkkW NjqBvEB9dsx1g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mkcompile_h: use printf for LINUX_COMPILE_BY Date: Fri, 6 Dec 2019 22:03:02 +0900 Message-Id: <20191206130302.11473-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191206130302.11473-1-masahiroy@kernel.org> References: <20191206130302.11473-1-masahiroy@kernel.org> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Commit 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension") shed light on portability issues. Here is another one. Since commit f07726048d59 ("Fix handling of backlash character in LINUX_COMPILE_BY name"), we must escape a backslash contained in LINUX_COMPILE_BY. This is not working on distros like Ubuntu. As the POSIX spec [1] says, if any of the operands contain a backslash ( '\' ) character, the results are implementation-defined. The actual shell of /bin/sh could be bash, dash depending on distros, and the behavior of builtin echo command is different among them. The bash builtin echo, unless -e is given, copies the arguments to output without expanding escape sequences (BSD-like behavior). The dash builtin echo, in contrast, adopts System V behavior, which does expand escape sequences without any option. Even non-builtin /bin/echo behaves differently depending on the system. Due to these variations, echo is considered as a non-portable command. Using printf is the common solution to avoid the portability issue. [1] https://pubs.opengroup.org/onlinepubs/009695399/utilities/echo.html Fixes: 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension") Reported-by: XXing Wei Signed-off-by: Masahiro Yamada --- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 3097fec1756a..3a5a4b210c86 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -69,7 +69,7 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)" echo \#define UTS_VERSION \"$UTS_VERSION\" - echo \#define LINUX_COMPILE_BY \"$LINUX_COMPILE_BY\" + printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY" echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\" echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"