diff options
author | Ben Pfaff <blp@nicira.com> | 2013-01-24 14:17:21 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-02-01 14:26:46 -0800 |
commit | 316bd0f8229ec252ce714ca2ece8367a49d929c3 (patch) | |
tree | 4248e1488c6f31538889ce4b4c8bf52f603e62f3 /lib | |
parent | 146356e958188ef0a9f32e66e674fee2cf669102 (diff) |
vlog: New function vlog_set_levels_from_string_assert().
Two of the users of vlog_set_levels_from_string() in the tests could have
silently failed, if their arguments were invalid. This avoids that problem
(and a memory leak).
Found by Coverity.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vlog.c | 10 | ||||
-rw-r--r-- | lib/vlog.h | 5 |
2 files changed, 13 insertions, 2 deletions
@@ -431,6 +431,16 @@ exit: return msg; } +/* Set debugging levels. Abort with an error message if 's' is invalid. */ +void +vlog_set_levels_from_string_assert(const char *s) +{ + char *error = vlog_set_levels_from_string(s); + if (error) { + ovs_fatal(0, "%s", error); + } +} + /* If 'arg' is null, configure maximum verbosity. Otherwise, sets * configuration according to 'arg' (see vlog_set_levels_from_string()). */ void @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,7 +114,8 @@ struct vlog_rate_limit { enum vlog_level vlog_get_level(const struct vlog_module *, enum vlog_facility); void vlog_set_levels(struct vlog_module *, enum vlog_facility, enum vlog_level); -char *vlog_set_levels_from_string(const char *); +char *vlog_set_levels_from_string(const char *) WARN_UNUSED_RESULT; +void vlog_set_levels_from_string_assert(const char *); char *vlog_get_levels(void); bool vlog_is_enabled(const struct vlog_module *, enum vlog_level); bool vlog_should_drop(const struct vlog_module *, enum vlog_level, |