Skip to content

Commit

Permalink
vlog: Stop using explicit references to external log modules.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Russell Bryant <[email protected]>
  • Loading branch information
blp committed Feb 3, 2016
1 parent eba7755 commit 45863ce
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions ovn/utilities/ovn-nbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions ovn/utilities/ovn-sbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions tests/test-reconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions utilities/ovs-vsctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions vtep/vtep-ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 45863ce

Please sign in to comment.