|
From: openocd-gerrit <ope...@us...> - 2025-08-02 12:55:29
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via caf7ffc7ebb257b589d88aec4c3958ab2e6897f7 (commit)
from 6872f7e406ad74f366f55947d23becd5a5faca15 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit caf7ffc7ebb257b589d88aec4c3958ab2e6897f7
Author: Marc Schink <de...@za...>
Date: Sun Jul 20 11:12:57 2025 +0000
helper: Add string_choices.h
Add the helper function str_enabled_disabled() to select between the two
strings 'enabled' and 'disabled' depending on a boolean value.
Additional functions for frequently used strings can be added in the future
if required.
Change-Id: I2d8ae96b141f87966836e6e4c3a2ed6d12b71fa5
Signed-off-by: Marc Schink <de...@za...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9006
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/src/helper/Makefile.am b/src/helper/Makefile.am
index 807212478..1a61f7871 100644
--- a/src/helper/Makefile.am
+++ b/src/helper/Makefile.am
@@ -32,6 +32,7 @@ noinst_LTLIBRARIES += %D%/libhelper.la
%D%/crc32.h \
%D%/time_support.h \
%D%/replacements.h \
+ %D%/string_choices.h \
%D%/fileio.h \
%D%/system.h \
%D%/jep106.h \
diff --git a/src/helper/string_choices.h b/src/helper/string_choices.h
new file mode 100644
index 000000000..7e535845d
--- /dev/null
+++ b/src/helper/string_choices.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef OPENOCD_HELPER_STRING_CHOICES_H
+#define OPENOCD_HELPER_STRING_CHOICES_H
+
+#include <helper/types.h>
+
+/*
+ * This file contains helper functions that return one of two strings depending
+ * on a boolean value. The format of these functions is 'str_$true_$false' where
+ * $true and $false are the two corresponding strings.
+ *
+ * These helper functions are beneficial because they improve code consistency
+ * and reduce the number of hardcoded strings.
+ */
+
+static inline const char *str_enabled_disabled(bool value)
+{
+ return value ? "enabled" : "disabled";
+}
+
+#endif /* OPENOCD_HELPER_STRING_CHOICES_H */
-----------------------------------------------------------------------
Summary of changes:
src/helper/Makefile.am | 1 +
src/helper/string_choices.h | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 src/helper/string_choices.h
hooks/post-receive
--
Main OpenOCD repository
|