cli: use IWINFO_KMGMT_NAMES
authorAndre Heider <a.heider@gmail.com>
Mon, 21 Nov 2022 09:12:27 +0000 (10:12 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 15 Dec 2022 23:09:07 +0000 (00:09 +0100)
There's no need to duplicate the strings or even miss new ones.

Signed-off-by: Andre Heider <a.heider@gmail.com>
iwinfo_cli.c

index 944c6c882e2e3f8eaf37e7b2bd3a242be7f6dfe5..b43c52e4f83efe4c905e527a04594e41306b7779 100644 (file)
@@ -160,21 +160,11 @@ static char * format_enc_suites(int suites)
 {
        static char str[64] = { 0 };
        char *pos = str;
+       int i;
 
-       if (suites & IWINFO_KMGMT_PSK)
-               pos += sprintf(pos, "PSK/");
-
-       if (suites & IWINFO_KMGMT_8021x)
-               pos += sprintf(pos, "802.1X/");
-
-       if (suites & IWINFO_KMGMT_SAE)
-               pos += sprintf(pos, "SAE/");
-
-       if (suites & IWINFO_KMGMT_OWE)
-               pos += sprintf(pos, "OWE/");
-
-       if (!suites || (suites & IWINFO_KMGMT_NONE))
-               pos += sprintf(pos, "NONE/");
+       for (i = 0; i < IWINFO_KMGMT_COUNT; i++)
+               if (suites & (1 << i))
+                       pos += sprintf(pos, "%s/", IWINFO_KMGMT_NAMES[i]);
 
        *(pos - 1) = 0;