[ovs-dev] [PATCH] Use xstrdup() instead of strdup(), xmalloc() instead of malloc().

Justin Pettit jpettit at nicira.com
Tue Jul 22 22:51:33 UTC 2014


Acked-by: Justin Pettit <jpettit at nicira.com>



On Tue, Jul 22, 2014 at 3:48 PM, Ben Pfaff <blp at nicira.com> wrote:

> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  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 33b3b36..3d1907e 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 0a1ba6b..5d0602a 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 c982214..876c226 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 c040970..b8d4f80 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 8a2efa3..266ad4e 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);
>      }
> --
> 1.7.10.4
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list