To prevent warnings such as "Not all control paths return a value",
we should define NO_RETURN for MSVC.

Currently for gcc, we add NO_RETURN at the end of function declaration.
But for MSVC, "__declspec(noreturn)" is needed at the beginning of function
declaration. So this commit moves NO_RETURN to the beginning of the function
declaration as it works with gcc and clang too.

Signed-off-by: Gurucharan Shetty <[email protected]>
---
 lib/compiler.h                 |    8 +++++++-
 lib/stream-nossl.c             |    2 +-
 lib/util.h                     |   20 ++++++++++----------
 lib/vlog.h                     |   20 +++++++++++---------
 ovsdb/ovsdb-client.c           |    2 +-
 ovsdb/ovsdb-server.c           |    2 +-
 ovsdb/ovsdb-tool.c             |    2 +-
 tests/test-jsonrpc.c           |    2 +-
 tests/test-netflow.c           |    2 +-
 tests/test-ovsdb.c             |    2 +-
 tests/test-rstp.c              |    5 ++---
 tests/test-sflow.c             |    2 +-
 tests/test-stp.c               |    5 ++---
 utilities/ovs-dpctl.c          |    2 +-
 utilities/ovs-ofctl.c          |    2 +-
 utilities/ovs-testcontroller.c |    2 +-
 utilities/ovs-vsctl.c          |    6 +++---
 vswitchd/ovs-vswitchd.c        |    2 +-
 vswitchd/system-stats.c        |    4 ++--
 vtep/vtep-ctl.c                |    6 +++---
 20 files changed, 52 insertions(+), 46 deletions(-)

diff --git a/lib/compiler.h b/lib/compiler.h
index 5942c30..f5f8c68 100644
--- a/lib/compiler.h
+++ b/lib/compiler.h
@@ -26,6 +26,13 @@
 
 #if __GNUC__ && !__CHECKER__
 #define NO_RETURN __attribute__((__noreturn__))
+#elif _MSC_VER
+#define NO_RETURN __declspec(noreturn)
+#else
+#define NO_RETURN
+#endif
+
+#if __GNUC__ && !__CHECKER__
 #define OVS_UNUSED __attribute__((__unused__))
 #define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1)))
 #define SCANF_FORMAT(FMT, ARG1) __attribute__((__format__(scanf, FMT, ARG1)))
@@ -37,7 +44,6 @@
 #define OVS_LIKELY(CONDITION) __builtin_expect(!!(CONDITION), 1)
 #define OVS_UNLIKELY(CONDITION) __builtin_expect(!!(CONDITION), 0)
 #else
-#define NO_RETURN
 #define OVS_UNUSED
 #define PRINTF_FORMAT(FMT, ARG1)
 #define SCANF_FORMAT(FMT, ARG1)
diff --git a/lib/stream-nossl.c b/lib/stream-nossl.c
index 23bc1fb..7dc5e0f 100644
--- a/lib/stream-nossl.c
+++ b/lib/stream-nossl.c
@@ -28,7 +28,7 @@ stream_ssl_is_configured(void)
     return false;
 }
 
-static void NO_RETURN
+NO_RETURN static void
 nossl_option(const char *detail)
 {
     VLOG_FATAL("%s specified but Open vSwitch was built without SSL support",
diff --git a/lib/util.h b/lib/util.h
index a2c6ee9..7da7aa8 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -74,7 +74,7 @@
     if (!OVS_LIKELY(CONDITION)) {                                       \
         ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION);       \
     }
-void ovs_assert_failure(const char *, const char *, const char *) NO_RETURN;
+NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
 
 /* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes
  * anything other than an outermost "const" or "volatile" qualifier.
@@ -275,7 +275,7 @@ void set_subprogram_name(const char *format, ...) 
PRINTF_FORMAT(1, 2);
 const char *get_program_version(void);
 void ovs_print_version(uint8_t min_ofp, uint8_t max_ofp);
 
-void out_of_memory(void) NO_RETURN;
+NO_RETURN void out_of_memory(void);
 void *xmalloc(size_t) MALLOC_LIKE;
 void *xcalloc(size_t, size_t) MALLOC_LIKE;
 void *xzalloc(size_t) MALLOC_LIKE;
@@ -294,14 +294,14 @@ void free_cacheline(void *);
 void ovs_strlcpy(char *dst, const char *src, size_t size);
 void ovs_strzcpy(char *dst, const char *src, size_t size);
 
-void ovs_abort(int err_no, const char *format, ...)
-    PRINTF_FORMAT(2, 3) NO_RETURN;
-void ovs_abort_valist(int err_no, const char *format, va_list)
-    PRINTF_FORMAT(2, 0) NO_RETURN;
-void ovs_fatal(int err_no, const char *format, ...)
-    PRINTF_FORMAT(2, 3) NO_RETURN;
-void ovs_fatal_valist(int err_no, const char *format, va_list)
-    PRINTF_FORMAT(2, 0) NO_RETURN;
+NO_RETURN void ovs_abort(int err_no, const char *format, ...)
+    PRINTF_FORMAT(2, 3);
+NO_RETURN void ovs_abort_valist(int err_no, const char *format, va_list)
+    PRINTF_FORMAT(2, 0);
+NO_RETURN void ovs_fatal(int err_no, const char *format, ...)
+    PRINTF_FORMAT(2, 3);
+NO_RETURN void ovs_fatal_valist(int err_no, const char *format, va_list)
+    PRINTF_FORMAT(2, 0);
 void ovs_error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
 void ovs_error_valist(int err_no, const char *format, va_list)
     PRINTF_FORMAT(2, 0);
diff --git a/lib/vlog.h b/lib/vlog.h
index e5af21d..974a301 100644
--- a/lib/vlog.h
+++ b/lib/vlog.h
@@ -154,15 +154,17 @@ void vlog_valist(const struct vlog_module *, enum 
vlog_level,
                  const char *, va_list)
     PRINTF_FORMAT (3, 0);
 
-void vlog_fatal(const struct vlog_module *, const char *format, ...)
-    PRINTF_FORMAT (2, 3) NO_RETURN;
-void vlog_fatal_valist(const struct vlog_module *, const char *format, va_list)
-    PRINTF_FORMAT (2, 0) NO_RETURN;
-
-void vlog_abort(const struct vlog_module *, const char *format, ...)
-    PRINTF_FORMAT (2, 3) NO_RETURN;
-void vlog_abort_valist(const struct vlog_module *, const char *format, va_list)
-    PRINTF_FORMAT (2, 0) NO_RETURN;
+NO_RETURN void vlog_fatal(const struct vlog_module *, const char *format, ...)
+    PRINTF_FORMAT (2, 3);
+NO_RETURN void vlog_fatal_valist(const struct vlog_module *,
+                                 const char *format, va_list)
+    PRINTF_FORMAT (2, 0);
+
+NO_RETURN void vlog_abort(const struct vlog_module *, const char *format, ...)
+    PRINTF_FORMAT (2, 3);
+NO_RETURN void vlog_abort_valist(const struct vlog_module *,
+                                 const char *format, va_list)
+    PRINTF_FORMAT (2, 0);
 
 void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
                      struct vlog_rate_limit *, const char *, ...)
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index 2942953..2f1a837 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -74,7 +74,7 @@ static struct table_style table_style = TABLE_STYLE_DEFAULT;
 
 static const struct ovsdb_client_command *get_all_commands(void);
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 static struct jsonrpc *open_jsonrpc(const char *server);
 static void fetch_dbs(struct jsonrpc *, struct svec *dbs);
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 7dc2adb..6219110 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -97,7 +97,7 @@ static void close_db(struct db *db);
 static void parse_options(int *argc, char **argvp[],
                           struct sset *remotes, char **unixctl_pathp,
                           char **run_command);
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 
 static char *reconfigure_remotes(struct ovsdb_jsonrpc_server *,
                                  const struct shash *all_dbs,
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index e2a30ea..350e72a 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -46,7 +46,7 @@ static int show_log_verbosity;
 
 static const struct command *get_all_commands(void);
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 
 static const char *default_db(void);
diff --git a/tests/test-jsonrpc.c b/tests/test-jsonrpc.c
index dbd0b52..cf90c44 100644
--- a/tests/test-jsonrpc.c
+++ b/tests/test-jsonrpc.c
@@ -35,7 +35,7 @@
 #include "vlog.h"
 #include "ovstest.h"
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 static struct command *get_all_commands(void);
 
diff --git a/tests/test-netflow.c b/tests/test-netflow.c
index 76f9bae..284d7ab 100644
--- a/tests/test-netflow.c
+++ b/tests/test-netflow.c
@@ -35,7 +35,7 @@
 #include "vlog.h"
 #include "ovstest.h"
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 
 static unixctl_cb_func test_netflow_exit;
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index ebb24c0..4d73a0d 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -51,7 +51,7 @@
 #include "util.h"
 #include "vlog.h"
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 static struct command *get_all_commands(void);
 
diff --git a/tests/test-rstp.c b/tests/test-rstp.c
index afc5b60..96c611a 100644
--- a/tests/test-rstp.c
+++ b/tests/test-rstp.c
@@ -335,10 +335,9 @@ simulate(struct test_case *tc, int granularity)
     }
 }
 
-static void
+NO_RETURN static void
 err(const char *message, ...)
-    PRINTF_FORMAT(1, 2)
-    NO_RETURN;
+    PRINTF_FORMAT(1, 2);
 
 static void
 err(const char *message, ...)
diff --git a/tests/test-sflow.c b/tests/test-sflow.c
index b91fd41..1d512ad 100644
--- a/tests/test-sflow.c
+++ b/tests/test-sflow.c
@@ -38,7 +38,7 @@
 #include "vlog.h"
 #include "ovstest.h"
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 
 static unixctl_cb_func test_sflow_exit;
diff --git a/tests/test-stp.c b/tests/test-stp.c
index c4e5933..45f0f4c 100644
--- a/tests/test-stp.c
+++ b/tests/test-stp.c
@@ -316,10 +316,9 @@ simulate(struct test_case *tc, int granularity)
     }
 }
 
-static void
+NO_RETURN static void
 err(const char *message, ...)
-    PRINTF_FORMAT(1, 2)
-    NO_RETURN;
+    PRINTF_FORMAT(1, 2);
 
 static void
 err(const char *message, ...)
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index 6c25bfd..94a6b90 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -44,7 +44,7 @@
 
 static struct dpctl_params dpctl_p;
 
-static void usage(void *userdata OVS_UNUSED) NO_RETURN;
+NO_RETURN static void usage(void *userdata OVS_UNUSED);
 static void parse_options(int argc, char *argv[]);
 
 static void
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index fa8bf72..c0c3561 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -106,7 +106,7 @@ static size_t n_criteria, allocated_criteria;
 
 static const struct command *get_all_commands(void);
 
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[]);
 
 static bool recv_flow_stats_reply(struct vconn *, ovs_be32 send_xid,
diff --git a/utilities/ovs-testcontroller.c b/utilities/ovs-testcontroller.c
index a615ab4..4ef7d4b 100644
--- a/utilities/ovs-testcontroller.c
+++ b/utilities/ovs-testcontroller.c
@@ -91,7 +91,7 @@ static char *unixctl_path = NULL;
 
 static void new_switch(struct switch_ *, struct vconn *);
 static void parse_options(int argc, char *argv[]);
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 
 int
 main(int argc, char *argv[])
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 5cf12cf..818184a 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -137,10 +137,10 @@ static const struct vsctl_command_syntax 
*get_all_commands(void);
 static struct ovsdb_idl *the_idl;
 static struct ovsdb_idl_txn *the_idl_txn;
 
-static void vsctl_exit(int status) NO_RETURN;
-static void vsctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2) NO_RETURN;
+NO_RETURN static void vsctl_exit(int status);
+NO_RETURN static void vsctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2);
 static char *default_db(void);
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[], struct shash *local_options);
 static bool might_write_to_db(char **argv);
 
diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c
index dba89dc..355b1b0 100644
--- a/vswitchd/ovs-vswitchd.c
+++ b/vswitchd/ovs-vswitchd.c
@@ -59,7 +59,7 @@ static bool want_mlockall;
 static unixctl_cb_func ovs_vswitchd_exit;
 
 static char *parse_options(int argc, char *argv[], char **unixctl_path);
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 
 int
 main(int argc, char *argv[])
diff --git a/vswitchd/system-stats.c b/vswitchd/system-stats.c
index 7789787..dc0f2c5 100644
--- a/vswitchd/system-stats.c
+++ b/vswitchd/system-stats.c
@@ -531,7 +531,7 @@ static bool enabled;
 static bool started OVS_GUARDED_BY(mutex);
 static struct smap *system_stats OVS_GUARDED_BY(mutex);
 
-static void *system_stats_thread_func(void *);
+NO_RETURN static void *system_stats_thread_func(void *);
 static void discard_stats(void);
 
 /* Enables or disables system stats collection, according to 'enable'. */
@@ -604,7 +604,7 @@ discard_stats(void) OVS_REQUIRES(mutex)
     }
 }
 
-static void * NO_RETURN
+static void *
 system_stats_thread_func(void *arg OVS_UNUSED)
 {
     pthread_detach(pthread_self());
diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c
index 3576313..8a16450 100644
--- a/vtep/vtep-ctl.c
+++ b/vtep/vtep-ctl.c
@@ -121,10 +121,10 @@ static struct table_style table_style = 
TABLE_STYLE_DEFAULT;
 static struct ovsdb_idl *the_idl;
 static struct ovsdb_idl_txn *the_idl_txn;
 
-static void vtep_ctl_exit(int status) NO_RETURN;
-static void vtep_ctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2) NO_RETURN;
+NO_RETURN static void vtep_ctl_exit(int status);
+NO_RETURN static void vtep_ctl_fatal(const char *, ...) PRINTF_FORMAT(1, 2);
 static char *default_db(void);
-static void usage(void) NO_RETURN;
+NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[], struct shash *local_options);
 static bool might_write_to_db(char **argv);
 
-- 
1.7.9.5

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to