All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again
@ 2021-02-27 14:20 Masahiro Yamada
  2021-02-28  1:19 ` Sasha Levin
  2021-03-01 17:10 ` David Laight
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2021-02-27 14:20 UTC (permalink / raw)
  To: linux-kbuild, Christophe Leroy, Christian Zigotzky
  Cc: Sasha Levin, Masahiro Yamada, Michal Marek, linux-kernel

Commit 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255") breaks the build
if SUBLEVEL or PATCHLEVEL is empty.

Commit 78d3bb4483ba ("kbuild: Fix <linux/version.h> for empty SUBLEVEL
or PATCHLEVEL") fixed the issue by prepending a zero.

This time, we cannot take the same approach because we have C code:

  #define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL)
  #define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)

Replace empty SUBLEVEL or PATCHLEVEL with a zero.

Fixes: 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255")
Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f2dc2f953e23..14c13b09a9e7 100644
--- a/Makefile
+++ b/Makefile
@@ -1283,10 +1283,10 @@ endef
 define filechk_version.h
 	if [ $(SUBLEVEL) -gt 255 ]; then                                 \
 		echo \#define LINUX_VERSION_CODE $(shell                 \
-		expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
+		expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
 	else                                                             \
 		echo \#define LINUX_VERSION_CODE $(shell                 \
-		expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
+		expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
 	fi;                                                              \
 	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) +  \
 	((c) > 255 ? 255 : (c)))';                                       \
@@ -1295,6 +1295,8 @@ define filechk_version.h
 	echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
 endef
 
+$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0)
+$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0)
 $(version_h): FORCE
 	$(call filechk,version.h)
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again
  2021-02-27 14:20 [PATCH] kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again Masahiro Yamada
@ 2021-02-28  1:19 ` Sasha Levin
  2021-03-01 17:10 ` David Laight
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2021-02-28  1:19 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Christophe Leroy, Christian Zigotzky, Michal Marek,
	linux-kernel

On Sat, Feb 27, 2021 at 11:20:23PM +0900, Masahiro Yamada wrote:
>Commit 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255") breaks the build
>if SUBLEVEL or PATCHLEVEL is empty.
>
>Commit 78d3bb4483ba ("kbuild: Fix <linux/version.h> for empty SUBLEVEL
>or PATCHLEVEL") fixed the issue by prepending a zero.
>
>This time, we cannot take the same approach because we have C code:
>
>  #define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL)
>  #define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
>
>Replace empty SUBLEVEL or PATCHLEVEL with a zero.
>
>Fixes: 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255")
>Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Reviewed-and-tested-by: Sasha Levin <sashal@kernel.org>

Thank you!

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again
  2021-02-27 14:20 [PATCH] kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again Masahiro Yamada
  2021-02-28  1:19 ` Sasha Levin
@ 2021-03-01 17:10 ` David Laight
  1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2021-03-01 17:10 UTC (permalink / raw)
  To: 'Masahiro Yamada',
	linux-kbuild, Christophe Leroy, Christian Zigotzky
  Cc: Sasha Levin, Michal Marek, linux-kernel

From: Masahiro Yamada
> Sent: 27 February 2021 14:20
> 
> Commit 9b82f13e7ef3 ("kbuild: clamp SUBLEVEL to 255") breaks the build
> if SUBLEVEL or PATCHLEVEL is empty.
> 
> Commit 78d3bb4483ba ("kbuild: Fix <linux/version.h> for empty SUBLEVEL
> or PATCHLEVEL") fixed the issue by prepending a zero.
> 
> This time, we cannot take the same approach because we have C code:
> 
>   #define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL)
>   #define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
> 
> Replace empty SUBLEVEL or PATCHLEVEL with a zero.

You could do:

#define LINUX_VERSION_PATCHLEVEL ($(PATCHLEVEL) + 0)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-01 21:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-27 14:20 [PATCH] kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again Masahiro Yamada
2021-02-28  1:19 ` Sasha Levin
2021-03-01 17:10 ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.