]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Replace custom min macro and use more C99 style in man_remote_entry_get
authorArne Schwabe <arne@rfc2549.org>
Tue, 27 Dec 2022 14:02:44 +0000 (15:02 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 27 Dec 2022 16:58:38 +0000 (17:58 +0100)
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20221227140249.3524943-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25830.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/manage.c

index be9a389521ce4d9fb96fd4a8980d1b00558af920..7e326702f5c12cb231ed82cc4ebc7a98b7679cea 100644 (file)
@@ -865,8 +865,6 @@ man_remote_entry_count(struct management *man)
     }
 }
 
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
 static void
 man_remote_entry_get(struct management *man, const char *p1, const char *p2)
 {
@@ -875,12 +873,10 @@ man_remote_entry_get(struct management *man, const char *p1, const char *p2)
     if (man->persist.callback.remote_entry_get
         && man->persist.callback.remote_entry_count)
     {
-        bool res;
-        unsigned int from, to;
         unsigned int count = (*man->persist.callback.remote_entry_count)(man->persist.callback.arg);
 
-        from = (unsigned int) atoi(p1);
-        to = p2 ? (unsigned int) atoi(p2) : from + 1;
+        unsigned int from = (unsigned int) atoi(p1);
+        unsigned int to = p2 ? (unsigned int) atoi(p2) : from + 1;
 
         if (!strcmp(p1, "all"))
         {
@@ -888,10 +884,10 @@ man_remote_entry_get(struct management *man, const char *p1, const char *p2)
             to = count;
         }
 
-        for (unsigned int i = from; i < min(to, count); i++)
+        for (unsigned int i = from; i < min_uint(to, count); i++)
         {
             char *remote = NULL;
-            res = (*man->persist.callback.remote_entry_get)(man->persist.callback.arg, i, &remote);
+            bool res = (*man->persist.callback.remote_entry_get)(man->persist.callback.arg, i, &remote);
             if (res && remote)
             {
                 msg(M_CLIENT, "%u,%s", i, remote);