From 13a233f7b0714d6cdb20b3982fa317344dd6b331 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 22 Jul 2014 15:46:25 -0700 Subject: [PATCH] Use xstrdup() instead of strdup(), xmalloc() instead of malloc(). Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- lib/daemon-windows.c | 2 +- lib/stream-tcp.c | 4 ++-- lib/unixctl.c | 6 +++--- tests/test-odp.c | 2 +- tests/test-vconn.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/daemon-windows.c b/lib/daemon-windows.c index 33b3b36de..3d1907e51 100644 --- a/lib/daemon-windows.c +++ b/lib/daemon-windows.c @@ -478,7 +478,7 @@ char * make_pidfile_name(const char *name) { if (name && strchr(name, ':')) { - return strdup(name); + return xstrdup(name); } else { return xasprintf("%s/%s.pid", ovs_rundir(), program_name); } diff --git a/lib/stream-tcp.c b/lib/stream-tcp.c index 0a1ba6bb2..5d0602a58 100644 --- a/lib/stream-tcp.c +++ b/lib/stream-tcp.c @@ -106,7 +106,7 @@ windows_open(const char *name, char *suffix, struct stream **streamp, if (!strchr(suffix, ':')) { path = xasprintf("%s/%s", ovs_rundir(), suffix); } else { - path = strdup(suffix); + path = xstrdup(suffix); } file = fopen(path, "r"); @@ -229,7 +229,7 @@ pwindows_open(const char *name OVS_UNUSED, char *suffix, if (!strchr(suffix, ':')) { path = xasprintf("%s/%s", ovs_rundir(), suffix); } else { - path = strdup(suffix); + path = xstrdup(suffix); } error = new_pstream(suffix_new, pstreamp, dscp, path, false); diff --git a/lib/unixctl.c b/lib/unixctl.c index c982214ad..876c22627 100644 --- a/lib/unixctl.c +++ b/lib/unixctl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -224,7 +224,7 @@ unixctl_server_create(const char *path, struct unixctl_server **serverp) #ifndef _WIN32 abs_path = abs_file_name(ovs_rundir(), path); #else - abs_path = strdup(path); + abs_path = xstrdup(path); #endif punix_path = xasprintf("punix:%s", abs_path); free(abs_path); @@ -438,7 +438,7 @@ unixctl_client_create(const char *path, struct jsonrpc **client) int error; #ifdef _WIN32 - abs_path = strdup(path); + abs_path = xstrdup(path); #else abs_path = abs_file_name(ovs_rundir(), path); #endif diff --git a/tests/test-odp.c b/tests/test-odp.c index c04097051..b8d4f80ab 100644 --- a/tests/test-odp.c +++ b/tests/test-odp.c @@ -149,7 +149,7 @@ parse_filter(char *filter_parse) vlog_set_levels_from_string_assert("odp_util:console:dbg"); if (filter_parse && !strncmp(filter_parse, "filter=", 7)) { - filter = strdup(filter_parse+7); + filter = xstrdup(filter_parse + 7); memset(&flow_filter, 0, sizeof(flow_filter)); memset(&wc_filter, 0, sizeof(wc_filter)); diff --git a/tests/test-vconn.c b/tests/test-vconn.c index 8a2efa381..266ad4e77 100644 --- a/tests/test-vconn.c +++ b/tests/test-vconn.c @@ -61,7 +61,7 @@ static void check_errno(int a, int b, const char *as, const char *file, int line) { if (a != b) { - char *str_b = strdup(ovs_strerror(abs(b))); + char *str_b = xstrdup(ovs_strerror(abs(b))); ovs_fatal(0, "%s:%d: %s is %d (%s) but should be %d (%s)", file, line, as, a, ovs_strerror(abs(a)), b, str_b); } -- 2.20.1