Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libc/lib_utsname: Store version number for debugging and preventing optimization #14057

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions libs/libc/misc/lib_utsname.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
#include <nuttx/version.h>
#include <unistd.h>

/****************************************************************************
* Private Data
****************************************************************************/

#if defined(__DATE__) && defined(__TIME__) && \
W-M-R marked this conversation as resolved.
Show resolved Hide resolved
!defined(CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP)
static char g_version[] = CONFIG_VERSION_BUILD " " __DATE__ " " __TIME__;
#else
static char g_version[] = CONFIG_VERSION_BUILD;
W-M-R marked this conversation as resolved.
Show resolved Hide resolved
#endif

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down Expand Up @@ -94,13 +105,7 @@ int uname(FAR struct utsname *name)

strlcpy(name->release, CONFIG_VERSION_STRING, sizeof(name->release));

#if defined(__DATE__) && defined(__TIME__) && \
!defined(CONFIG_LIBC_UNAME_DISABLE_TIMESTAMP)
snprintf(name->version, VERSION_NAMELEN, "%s %s %s",
CONFIG_VERSION_BUILD, __DATE__, __TIME__);
#else
strlcpy(name->version, CONFIG_VERSION_BUILD, sizeof(name->version));
#endif
strlcpy(name->version, g_version, sizeof(name->version));

strlcpy(name->machine, CONFIG_ARCH, sizeof(name->machine));

Expand Down
Loading