git: 8df7af9c9ecf - main - LinuxKPI: string_choices.h: use ternary operator
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 03 Feb 2026 20:01:03 UTC
The branch main has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=8df7af9c9ecf7fc0b1c664f3d95893a9fcc16fcd
commit 8df7af9c9ecf7fc0b1c664f3d95893a9fcc16fcd
Author: Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-02-03 18:50:00 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-02-03 20:00:12 +0000
LinuxKPI: string_choices.h: use ternary operator
Switch from using if () else to a direct return (?:) code.
No functional changes.
Suggested by: kib (D55029)
Sponosred by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste (before removing more () as suggested by him)
Differential Revision: https://reviews.freebsd.org/D55088
---
.../linuxkpi/common/include/linux/string_choices.h | 25 +++++-----------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/string_choices.h b/sys/compat/linuxkpi/common/include/linux/string_choices.h
index 18842dbd86a2..db540d3e7d40 100644
--- a/sys/compat/linuxkpi/common/include/linux/string_choices.h
+++ b/sys/compat/linuxkpi/common/include/linux/string_choices.h
@@ -33,37 +33,25 @@
static inline const char *
str_yes_no(bool value)
{
- if (value)
- return "yes";
- else
- return "no";
+ return (value ? "yes" : "no");
}
static inline const char *
str_on_off(bool value)
{
- if (value)
- return "on";
- else
- return "off";
+ return (value ? "on" : "off");
}
static inline const char *
str_enabled_disabled(bool value)
{
- if (value)
- return "enabled";
- else
- return "disabled";
+ return (value ? "enabled" : "disabled");
}
static inline const char *
str_enable_disable(bool value)
{
- if (value)
- return "enable";
- else
- return "disable";
+ return (value ? "enable" : "disable");
}
#define str_disable_enable(_v) str_enable_disable(!(_v))
@@ -71,10 +59,7 @@ str_enable_disable(bool value)
static inline const char *
str_read_write(bool value)
{
- if (value)
- return "read";
- else
- return "write";
+ return (value ? "read" : "write");
}
#endif