]> git.ipfire.org Git - people/ms/network.git/commitdiff
string: Define an own type for string tables
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Jun 2023 15:30:41 +0000 (15:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Jun 2023 15:45:46 +0000 (15:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/port-bonding.c
src/networkd/port-vlan.c
src/networkd/string.h

index 7bd54e138adb902748869ad00fe49b0832acaa85..b1d2c182e1bc34ef7d378917c4726182238ca3f1 100644 (file)
@@ -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" },
index e3f93d77617e8e082ebd4e9f9c1cad66a7684da3..792fd28e26c8af95cc95e532fa8c72714626cd7a 100644 (file)
@@ -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 },
index d94e27064e9361261439aa81d5138fbc42e9dc8b..270ed6be64de1b80eb2566b406529fb5ef10b7e5 100644 (file)
@@ -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)