]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: vty: warn when using compatibility macros
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 12 Jul 2017 14:23:40 +0000 (16:23 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 13 Jul 2017 18:29:18 +0000 (20:29 +0200)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/vty.h

index b4a55180d39ca79eb8a3f531880eff09bfa84de1..5cd28c0c42ac8d1e96961cdf0c6f380abcb277c8 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -183,13 +183,35 @@ struct vty_arg
 #define VTYNL  ((vty->type == VTY_TERM) ? "\r\n" : "\n")
 
 /* for compatibility */
-#define VTY_NEWLINE                               VTYNL
-#define VTY_GET_INTEGER(desc,v,str)               {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_ULONG(desc,v,str)                 {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_ULL(desc,v,str)                   {(v)=strtoull ((str), NULL, 10);}
-#define VTY_GET_IPV4_ADDRESS(desc,v,str)          inet_aton ((str), &(v))
-#define VTY_GET_IPV4_PREFIX(desc,v,str)           str2prefix_ipv4 ((str), &(v))
+#if defined(__ICC)
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(message __FILE__ ": " text))
+
+#elif (defined(__GNUC__) && \
+       (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
+    (defined(__clang__) && \
+       (__clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 5)))
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(GCC warning text))
+
+#else
+#define CPP_WARN(text)
+#endif
+
+#define VTY_NEWLINE                               VTYNL \
+       CPP_WARN("VTY_NEWLINE has been replaced with VTYNL and/or vty_outln().")
+#define VTY_GET_INTEGER(desc,v,str)               {(v)=strtoul ((str), NULL, 10);} \
+       CPP_WARN("VTY_GET_INTEGER is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);} \
+       CPP_WARN("VTY_GET_INTEGER_RANGE is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_ULONG(desc,v,str)                 {(v)=strtoul ((str), NULL, 10);} \
+       CPP_WARN("VTY_GET_ULONG is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_ULL(desc,v,str)                   {(v)=strtoull ((str), NULL, 10);} \
+       CPP_WARN("VTY_GET_ULL is no longer useful, use strtoull() or DEFPY.")
+#define VTY_GET_IPV4_ADDRESS(desc,v,str)          inet_aton ((str), &(v)) \
+       CPP_WARN("VTY_GET_IPV4_ADDRESS is no longer useful, use inet_aton() or DEFPY.")
+#define VTY_GET_IPV4_PREFIX(desc,v,str)           str2prefix_ipv4 ((str), &(v)) \
+       CPP_WARN("VTY_GET_IPV4_PREFIX is no longer useful, use str2prefix_ipv4() or DEFPY.")
 
 /* Default time out value */
 #define VTY_TIMEOUT_DEFAULT 600