mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
util: fix compile warnings
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>
This commit is contained in:
committed by
Joe Stringer
parent
03093a4f7a
commit
91e12f0d0f
14
lib/util.c
14
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,10 +455,8 @@ void
|
||||
set_program_name__(const char *argv0, const char *version, const char *date,
|
||||
const char *time)
|
||||
{
|
||||
free(CONST_CAST(char *, program_name));
|
||||
|
||||
#ifdef _WIN32
|
||||
char *basename;
|
||||
#ifdef _WIN32
|
||||
size_t max_len = strlen(argv0) + 1;
|
||||
|
||||
SetErrorMode(GetErrorMode() | SEM_NOGPFAULTERRORBOX);
|
||||
@@ -466,14 +464,14 @@ set_program_name__(const char *argv0, const char *version, const char *date,
|
||||
|
||||
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, '/');
|
||||
assert_single_threaded();
|
||||
program_name = xstrdup(slash ? slash + 1 : argv0);
|
||||
basename = xstrdup(slash ? slash + 1 : argv0);
|
||||
#endif
|
||||
|
||||
assert_single_threaded();
|
||||
free(program_name);
|
||||
program_name = basename;
|
||||
free(program_version);
|
||||
|
||||
if (!strcmp(version, VERSION)) {
|
||||
|
Reference in New Issue
Block a user