This patch fixes two compile warnings introduced by commit
64b73291 ("util: create a copy of program_name"):
1. ../lib/util.c:457:5: error: passing argument 1 of 'free'
discards 'const' qualifier from pointer target type; And
2. ../lib/util.c:463:5: error: ISO C90 forbids mixed declarations
and code [-Werror=declaration-after-statement] (affected only
branch-2.3 that is C90 compliant and not the master)
Reported-By: Joe Stringer <[email protected]>
Reported-By: Lorand Jakab <[email protected]>
Signed-Off-By: Ansis Atteka <[email protected]>
---
lib/util.c | 11 +++++++----
lib/util.h | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib/util.c b/lib/util.c
index 4f9b079..0e13341 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -43,7 +43,7 @@ VLOG_DEFINE_THIS_MODULE(util);
COVERAGE_DEFINE(util_xalloc);
/* argv[0] without directory names. */
-const char *program_name;
+char *program_name;
/* Name for the currently running thread or process, for log messages, process
* listings, and debuggers. */
@@ -455,12 +455,16 @@ void
set_program_name__(const char *argv0, const char *version, const char *date,
const char *time)
{
- free(program_name);
-
#ifdef _WIN32
char *basename;
size_t max_len = strlen(argv0) + 1;
+#else
+ const char *slash = strrchr(argv0, '/');
+#endif
+ free(program_name);
+
+#ifdef _WIN32
SetErrorMode(GetErrorMode() | SEM_NOGPFAULTERRORBOX);
_set_output_format(_TWO_DIGIT_EXPONENT);
@@ -469,7 +473,6 @@ set_program_name__(const char *argv0, const char *version,
const char *date,
assert_single_threaded();
program_name = basename;
#else
- const char *slash = strrchr(argv0, '/');
assert_single_threaded();
program_name = xstrdup(slash ? slash + 1 : argv0);
#endif
diff --git a/lib/util.h b/lib/util.h
index b626c0b..dc34ee5 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -86,7 +86,7 @@ void ovs_assert_failure(const char *, const char *, const
char *) NO_RETURN;
((void) sizeof ((int) ((POINTER) == (TYPE) (POINTER))), \
(TYPE) (POINTER))
-extern const char *program_name;
+extern char *program_name;
#define __ARRAY_SIZE_NOCHECK(ARRAY) (sizeof(ARRAY) / sizeof((ARRAY)[0]))
#ifdef __GNUC__
--
1.8.1.2
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev