vlog: Stop using explicit references to external log modules.
authorBen Pfaff <blp@ovn.org>
Wed, 3 Feb 2016 21:15:48 +0000 (13:15 -0800)
committerBen Pfaff <blp@ovn.org>
Wed, 3 Feb 2016 23:20:11 +0000 (15:20 -0800)
It's always risky to write "extern" declarations outside a header file,
since there's no way to ensure the type of what's being referenced is
correct.  In these cases, we can easily avoid the extern reference, so do
so.

There is a little tradeoff here, in that referring to the log modules
through strings means that we catch an incorrect module name at runtime
instead of at link time, but I think that the risk here is minimal because
the mistake will be found by every test in "make check" that runs any of
the utilities, since they make these calls as one of their first tasks
during initialization.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
ovn/utilities/ovn-nbctl.c
ovn/utilities/ovn-sbctl.c
tests/test-reconnect.c
utilities/ovs-vsctl.c
vtep/vtep-ctl.c

index 8c3b3c8..324a0a4 100644 (file)
@@ -73,7 +73,6 @@ static void do_nbctl(const char *args, struct ctl_command *, size_t n,
 int
 main(int argc, char *argv[])
 {
-    extern struct vlog_module VLM_reconnect;
     struct ovsdb_idl *idl;
     struct ctl_command *commands;
     struct shash local_options;
@@ -84,7 +83,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
-    vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
+    vlog_set_levels_from_string_assert("reconnect:warn");
     nbrec_init();
 
     nbctl_cmd_init();
index cf3c559..b428a35 100644 (file)
@@ -86,7 +86,6 @@ static void do_sbctl(const char *args, struct ctl_command *, size_t n,
 int
 main(int argc, char *argv[])
 {
-    extern struct vlog_module VLM_reconnect;
     struct ovsdb_idl *idl;
     struct ctl_command *commands;
     struct shash local_options;
@@ -97,7 +96,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
-    vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
+    vlog_set_levels_from_string_assert("reconnect:warn");
     sbrec_init();
 
     sbctl_cmd_init();
index a55c57c..b70a7d5 100644 (file)
@@ -39,13 +39,12 @@ static const struct ovs_cmdl_command *get_all_commands(void);
 static void
 test_reconnect_main(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
 {
-    extern struct vlog_module VLM_reconnect;
     struct reconnect_stats prev;
     unsigned int old_max_tries;
     int old_time;
     char line[128];
 
-    vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_OFF);
+    vlog_set_levels_from_string_assert("reconnect:off");
 
     now = 1000;
     reconnect = reconnect_create(now);
index c5a28e0..00ac458 100644 (file)
@@ -130,7 +130,6 @@ static size_t allocated_neoteric_ifaces;
 int
 main(int argc, char *argv[])
 {
-    extern struct vlog_module VLM_reconnect;
     struct ovsdb_idl *idl;
     struct ctl_command *commands;
     struct shash local_options;
@@ -141,7 +140,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
-    vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
+    vlog_set_levels_from_string_assert("reconnect:warn");
     ovsrec_init();
 
     vsctl_cmd_init();
index 2e80581..2f13dc6 100644 (file)
@@ -94,7 +94,6 @@ static struct vtep_ctl_lrouter *find_lrouter(struct vtep_ctl_context *,
 int
 main(int argc, char *argv[])
 {
-    extern struct vlog_module VLM_reconnect;
     struct ovsdb_idl *idl;
     struct ctl_command *commands;
     struct shash local_options;
@@ -105,7 +104,7 @@ main(int argc, char *argv[])
     set_program_name(argv[0]);
     fatal_ignore_sigpipe();
     vlog_set_levels(NULL, VLF_CONSOLE, VLL_WARN);
-    vlog_set_levels(&VLM_reconnect, VLF_ANY_DESTINATION, VLL_WARN);
+    vlog_set_levels_from_string_assert("reconnect:warn");
     vteprec_init();
 
     vtep_ctl_cmd_init();