Skip to content

Commit cd2c787

Browse files
ycsincarlescufi
authored andcommitted
posix: uname: use BUILD_VERSION only if not empty
The `BUILD_VERSION` can be defined but empty when built without git, causing version to be missing from the uname version string: ``` *** Booting Zephyr OS build 3.5.0 *** Printing everything in utsname... sysname[7]: Zephyr nodename[7]: zephyr release[13]: 3.5.0 version[61]: Apr 1 2024 23:48:30 machine[8]: riscv64 uart:~$ ``` Let's check if it is empty before using it, so that `KERNEL_VERSION_STRING`, which is generated independently with cmake can be used as a fallback: ``` *** Booting Zephyr OS build 3.5.0 *** Printing everything in utsname... sysname[7]: Zephyr nodename[7]: zephyr release[13]: 3.5.0 version[61]: 3.5.0 Apr 1 2024 23:53:48 machine[8]: riscv64 uart:~$ ``` Signed-off-by: Yong Cong Sin <[email protected]>
1 parent fbaf7df commit cd2c787

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/posix/options/uname.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define UTSNAME_VERSION(_ver) _ver
2323
#endif
2424

25-
#ifdef BUILD_VERSION
25+
#if defined(BUILD_VERSION) && !IS_EMPTY(BUILD_VERSION)
2626
#define VERSION_BUILD STRINGIFY(BUILD_VERSION)
2727
#else
2828
#define VERSION_BUILD KERNEL_VERSION_STRING

0 commit comments

Comments
 (0)