string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends

Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
This commit is contained in:
Daan De Meyer
2026-01-02 04:05:45 +09:00
committed by Yu Watanabe
parent daff8ea8bb
commit aec52c1e6e
139 changed files with 351 additions and 589 deletions
+2 -4
View File
@@ -11,10 +11,8 @@ typedef enum RuntimeScope {
_RUNTIME_SCOPE_INVALID = -EINVAL,
} RuntimeScope;
const char* runtime_scope_to_string(RuntimeScope scope) _const_;
RuntimeScope runtime_scope_from_string(const char *s) _const_;
const char* runtime_scope_cmdline_option_to_string(RuntimeScope scope) _const_;
DECLARE_STRING_TABLE_LOOKUP(runtime_scope, RuntimeScope);
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(runtime_scope_cmdline_option, RuntimeScope);
static inline mode_t runtime_scope_to_socket_mode(RuntimeScope scope) {
/* Returns the right socket mode to use for binding AF_UNIX sockets intended for the specified