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 <jstringer@nicira.com>
Reported-By: Lorand Jakab <lojakab@cisco.com>
Signed-Off-By: Ansis Atteka <aatteka@nicira.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
COVERAGE_DEFINE(util_xalloc);
/* argv[0] without directory names. */
COVERAGE_DEFINE(util_xalloc);
/* argv[0] without directory names. */
-const char *program_name;
/* Name for the currently running thread or process, for log messages, process
* listings, and debuggers. */
/* Name for the currently running thread or process, for log messages, process
* listings, and debuggers. */
set_program_name__(const char *argv0, const char *version, const char *date,
const char *time)
{
set_program_name__(const char *argv0, const char *version, const char *date,
const char *time)
{
- free(CONST_CAST(char *, program_name));
-
-#ifdef _WIN32
size_t max_len = strlen(argv0) + 1;
SetErrorMode(GetErrorMode() | SEM_NOGPFAULTERRORBOX);
basename = xmalloc(max_len);
_splitpath_s(argv0, NULL, 0, NULL, 0, basename, max_len, NULL, 0);
size_t max_len = strlen(argv0) + 1;
SetErrorMode(GetErrorMode() | SEM_NOGPFAULTERRORBOX);
basename = xmalloc(max_len);
_splitpath_s(argv0, NULL, 0, NULL, 0, basename, max_len, NULL, 0);
- assert_single_threaded();
- program_name = basename;
#else
const char *slash = strrchr(argv0, '/');
#else
const char *slash = strrchr(argv0, '/');
- assert_single_threaded();
- program_name = xstrdup(slash ? slash + 1 : argv0);
+ basename = xstrdup(slash ? slash + 1 : argv0);
+ assert_single_threaded();
+ free(program_name);
+ program_name = basename;
free(program_version);
if (!strcmp(version, VERSION)) {
free(program_version);
if (!strcmp(version, VERSION)) {
((void) sizeof ((int) ((POINTER) == (TYPE) (POINTER))), \
(TYPE) (POINTER))
((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__
#define __ARRAY_SIZE_NOCHECK(ARRAY) (sizeof(ARRAY) / sizeof((ARRAY)[0]))
#ifdef __GNUC__