Fix possible undefined use od preprocessor.

Mixing preprocessor #if and code is undefined behavior in general,
rewrite tools_package_version to not use it.
This commit is contained in:
Milan Broz
2022-11-18 14:50:34 +01:00
parent faf3b27f51
commit 4b95f36804

View File

@@ -435,29 +435,34 @@ int tools_write_mk(const char *file, const char *key, int keysize)
void tools_package_version(const char *name, bool use_pwlibs) void tools_package_version(const char *name, bool use_pwlibs)
{ {
log_std("%s %s flags: %s%s\n", name, PACKAGE_VERSION, bool udev = false, blkid = false, keyring = false, fips = false;
bool kernel_capi = false, pwquality = false, passwdqc = false;
#ifdef USE_UDEV #ifdef USE_UDEV
"UDEV " udev = true;
#endif #endif
#ifdef HAVE_BLKID #ifdef HAVE_BLKID
"BLKID " blkid = true;
#endif #endif
#ifdef KERNEL_KEYRING #ifdef KERNEL_KEYRING
"KEYRING " keyring = true;
#endif #endif
#ifdef ENABLE_FIPS #ifdef ENABLE_FIPS
"FIPS " fips = true;
#endif #endif
#ifdef ENABLE_AF_ALG #ifdef ENABLE_AF_ALG
"KERNEL_CAPI " kernel_capi = true;
#endif #endif
,
#if defined(ENABLE_PWQUALITY) #if defined(ENABLE_PWQUALITY)
use_pwlibs ? "PWQUALITY " : "" pwquality = true;
#elif defined(ENABLE_PASSWDQC) #elif defined(ENABLE_PASSWDQC)
use_pwlibs ? "PASSWDQC " : "" passwdqc = true;
#else
""
#endif #endif
); log_std("%s %s flags: %s%s%s%s%s%s%s\n", name, PACKAGE_VERSION,
udev ? "UDEV " : "",
blkid ? "BLKID " : "",
keyring ? "KEYRING " : "",
fips ? "FIPS " : "",
kernel_capi ? "KERNEL_CAPI " : "",
pwquality && use_pwlibs ? "PWQUALITY " : "",
passwdqc && use_pwlibs ? "PASSWDQC " : "");
} }