Skip to content

Commit 207da4c

Browse files
committed
kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL again
Commit 78d3bb4 ("kbuild: Fix <linux/version.h> for empty SUBLEVEL or PATCHLEVEL") fixed the build error for empty SUBLEVEL or PATCHLEVEL by prepending a zero. Commit 9b82f13 ("kbuild: clamp SUBLEVEL to 255") re-introduced this issue. 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/PATCHLEVEL with a zero. Fixes: 9b82f13 ("kbuild: clamp SUBLEVEL to 255") Reported-by: Christian Zigotzky <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-and-tested-by: Sasha Levin <[email protected]>
1 parent 2214945 commit 207da4c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,10 +1284,10 @@ endef
12841284
define filechk_version.h
12851285
if [ $(SUBLEVEL) -gt 255 ]; then \
12861286
echo \#define LINUX_VERSION_CODE $(shell \
1287-
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
1287+
expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
12881288
else \
12891289
echo \#define LINUX_VERSION_CODE $(shell \
1290-
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
1290+
expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
12911291
fi; \
12921292
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \
12931293
((c) > 255 ? 255 : (c)))'; \
@@ -1296,6 +1296,8 @@ define filechk_version.h
12961296
echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
12971297
endef
12981298

1299+
$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0)
1300+
$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0)
12991301
$(version_h): FORCE
13001302
$(call filechk,version.h)
13011303

0 commit comments

Comments
 (0)