From 644eb1c88dc179c3efdeb6af32c5d153d5483957 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 8 Jun 2023 15:30:41 +0000 Subject: [PATCH] string: Define an own type for string tables Signed-off-by: Michael Tremer --- src/networkd/port-bonding.c | 2 +- src/networkd/port-vlan.c | 2 +- src/networkd/string.h | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/networkd/port-bonding.c b/src/networkd/port-bonding.c index 7bd54e13..b1d2c182 100644 --- a/src/networkd/port-bonding.c +++ b/src/networkd/port-bonding.c @@ -27,7 +27,7 @@ #include "port-bonding.h" #include "string.h" -const struct nw_string_table nw_port_bonding_mode[] = { +const nw_string_table_t nw_port_bonding_mode[] = { { NW_BONDING_MODE_ROUNDROBIN, "round-robin" }, { NW_BONDING_MODE_ACTIVEBACKUP, "active-backup" }, { NW_BONDING_MODE_XOR, "xor" }, diff --git a/src/networkd/port-vlan.c b/src/networkd/port-vlan.c index e3f93d77..792fd28e 100644 --- a/src/networkd/port-vlan.c +++ b/src/networkd/port-vlan.c @@ -30,7 +30,7 @@ #include "port-vlan.h" #include "string.h" -const struct nw_string_table nw_port_vlan_proto[] = { +const nw_string_table_t nw_port_vlan_proto[] = { { NW_VLAN_PROTO_8021Q, "802.1Q" }, { NW_VLAN_PROTO_8021ad, "802.1ad" }, { -1, NULL }, diff --git a/src/networkd/string.h b/src/networkd/string.h index d94e2706..270ed6be 100644 --- a/src/networkd/string.h +++ b/src/networkd/string.h @@ -129,14 +129,14 @@ static inline void nw_string_empty(char* s) { Tables */ -struct nw_string_table { +typedef struct nw_string_table { const int id; const char* string; -}; +} nw_string_table_t; static inline const char* nw_string_table_lookup_string( - const struct nw_string_table* table, const int id) { - const struct nw_string_table* entry = NULL; + const nw_string_table_t* table, const int id) { + const nw_string_table_t* entry = NULL; for (entry = table; entry->string; entry++) if (entry->id == id) @@ -146,8 +146,8 @@ static inline const char* nw_string_table_lookup_string( } static inline int nw_string_table_lookup_id( - const struct nw_string_table* table, const char* string) { - const struct nw_string_table* entry = NULL; + const nw_string_table_t* table, const char* string) { + const nw_string_table_t* entry = NULL; for (entry = table; entry->string; entry++) if (strcmp(entry->string, string) == 0) -- 2.47.2