public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber•org>
To: netdev@vger•kernel.org
Cc: Stephen Hemminger <stephen@networkplumber•org>
Subject: [PATCH iproute2 1/5] dcb: fully initialize flag table
Date: Wed, 28 Jun 2023 16:38:09 -0700	[thread overview]
Message-ID: <20230628233813.6564-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20230628233813.6564-1-stephen@networkplumber.org>

And make the flag table const since only used for lookup.

Signed-off-by: Stephen Hemminger <stephen@networkplumber•org>
---
 dcb/dcb_dcbx.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/dcb/dcb_dcbx.c b/dcb/dcb_dcbx.c
index 244b671b893b..9e3dd2a0af87 100644
--- a/dcb/dcb_dcbx.c
+++ b/dcb/dcb_dcbx.c
@@ -42,12 +42,12 @@ struct dcb_dcbx_flag {
 	const char *key_json;
 };
 
-static struct dcb_dcbx_flag dcb_dcbx_flags[] = {
-	{DCB_CAP_DCBX_HOST, "host"},
-	{DCB_CAP_DCBX_LLD_MANAGED, "lld-managed", "lld_managed"},
-	{DCB_CAP_DCBX_VER_CEE, "cee"},
-	{DCB_CAP_DCBX_VER_IEEE, "ieee"},
-	{DCB_CAP_DCBX_STATIC, "static"},
+static const struct dcb_dcbx_flag dcb_dcbx_flags[] = {
+	{DCB_CAP_DCBX_HOST, "host", NULL },
+	{DCB_CAP_DCBX_LLD_MANAGED, "lld-managed", "lld_managed" },
+	{DCB_CAP_DCBX_VER_CEE, "cee", NULL },
+	{DCB_CAP_DCBX_VER_IEEE, "ieee", NULL },
+	{DCB_CAP_DCBX_STATIC, "static", NULL },
 };
 
 static void dcb_dcbx_print(__u8 dcbx)
@@ -60,7 +60,7 @@ static void dcb_dcbx_print(__u8 dcbx)
 
 		bit--;
 		for (i = 0; i < ARRAY_SIZE(dcb_dcbx_flags); i++) {
-			struct dcb_dcbx_flag *flag = &dcb_dcbx_flags[i];
+			const struct dcb_dcbx_flag *flag = &dcb_dcbx_flags[i];
 
 			if (flag->value == 1 << bit) {
 				print_bool(PRINT_JSON, flag->key_json ?: flag->key_fp,
@@ -123,7 +123,7 @@ static int dcb_cmd_dcbx_set(struct dcb *dcb, const char *dev, int argc, char **a
 		}
 
 		for (i = 0; i < ARRAY_SIZE(dcb_dcbx_flags); i++) {
-			struct dcb_dcbx_flag *flag = &dcb_dcbx_flags[i];
+			const struct dcb_dcbx_flag *flag = &dcb_dcbx_flags[i];
 
 			if (matches(*argv, flag->key_fp) == 0) {
 				dcbx |= flag->value;
-- 
2.39.2


  reply	other threads:[~2023-06-28 23:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 23:38 [PATCH iproute2 0/5] Warning fixes Stephen Hemminger
2023-06-28 23:38 ` Stephen Hemminger [this message]
2023-06-29 13:08   ` [PATCH iproute2 1/5] dcb: fully initialize flag table Petr Machata
2023-06-28 23:38 ` [PATCH iproute2 2/5] fix fallthrough warnings Stephen Hemminger
2023-06-29 13:54   ` Petr Machata
2023-06-28 23:38 ` [PATCH iproute2 3/5] ss: fix warning about empty if() Stephen Hemminger
2023-06-29 13:14   ` Petr Machata
2023-06-28 23:38 ` [PATCH iproute2 4/5] ct: check for invalid proto Stephen Hemminger
2023-06-29 13:44   ` Petr Machata
2023-06-28 23:38 ` [PATCH iproute2 5/5] ifstat: fix warning about conditional Stephen Hemminger
2023-06-29 13:49   ` Petr Machata
2023-06-29 16:10 ` [PATCH iproute2 0/5] Warning fixes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230628233813.6564-2-stephen@networkplumber.org \
    --to=stephen@networkplumber$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox