summaryrefslogtreecommitdiffstats
path: root/lib/keychain.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2015-03-03 08:56:48 +0100
committerDaniel Walton <dwalton@cumulusnetworks.com>2016-05-26 17:33:29 +0200
commit5eafab7614e5bcb0901d670c1d24eac83ae36cea (patch)
tree9ccf8ce277578eba97960d2d885f8851df8f5519 /lib/keychain.c
parentzebra: static int inline -> static inline int (diff)
downloadfrr-5eafab7614e5bcb0901d670c1d24eac83ae36cea.tar.xz
frr-5eafab7614e5bcb0901d670c1d24eac83ae36cea.zip
lib: silence type range warning in macro
While splitting up the CLI input macro is a bit annoying, this seems to be the least annoying way to get rid of the "< 0" comparison warning for unsigned long. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 81a4e85442e2011a47bbb25e8301dc40ec4ed9b6)
Diffstat (limited to 'lib/keychain.c')
-rw-r--r--lib/keychain.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/keychain.c b/lib/keychain.c
index ac2627ee0..c4a007edd 100644
--- a/lib/keychain.c
+++ b/lib/keychain.c
@@ -381,18 +381,22 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
NULL
};
-#define GET_LONG_RANGE(V,STR,MIN,MAX) \
+#define _GET_LONG_RANGE(V,STR,MMCOND) \
{ \
unsigned long tmpl; \
char *endptr = NULL; \
tmpl = strtoul ((STR), &endptr, 10); \
if (*endptr != '\0' || tmpl == ULONG_MAX) \
return -1; \
- if ( tmpl < (MIN) || tmpl > (MAX)) \
+ if (MMCOND) \
return -1; \
(V) = tmpl; \
}
-
+#define GET_LONG_RANGE(V,STR,MIN,MAX) \
+ _GET_LONG_RANGE(V,STR,tmpl < (MIN) || tmpl > (MAX))
+#define GET_LONG_RANGE0(V,STR,MAX) \
+ _GET_LONG_RANGE(V,STR,tmpl > (MAX))
+
/* Check hour field of time_str. */
colon = strchr (time_str, ':');
if (colon == NULL)
@@ -400,7 +404,7 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
*colon = '\0';
/* Hour must be between 0 and 23. */
- GET_LONG_RANGE (hour, time_str, 0, 23);
+ GET_LONG_RANGE0 (hour, time_str, 23);
/* Check min field of time_str. */
time_str = colon + 1;
@@ -410,7 +414,7 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
*colon = '\0';
/* Min must be between 0 and 59. */
- GET_LONG_RANGE (min, time_str, 0, 59);
+ GET_LONG_RANGE0 (min, time_str, 59);
/* Check sec field of time_str. */
time_str = colon + 1;
@@ -418,7 +422,7 @@ key_str2time (const char *time_str, const char *day_str, const char *month_str,
return -1;
/* Sec must be between 0 and 59. */
- GET_LONG_RANGE (sec, time_str, 0, 59);
+ GET_LONG_RANGE0 (sec, time_str, 59);
/* Check day_str. Day must be <1-31>. */
GET_LONG_RANGE (day, day_str, 1, 31);