diff options
author | Ben Pfaff <blp@ovn.org> | 2016-06-24 21:23:16 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-06-26 20:31:28 -0700 |
commit | 2225c0b9355e6823a2adccfeef2fb3fe3cccb557 (patch) | |
tree | 03d24cfb8f4d38cc82dc08f728e4a0d4dae809d6 /ofproto | |
parent | 05e81316ca53077b97ecf56c32b24b99efe3e51e (diff) | |
download | openvswitch-2225c0b9355e6823a2adccfeef2fb3fe3cccb557.tar.gz |
util: New function nullable_xstrdup().
It's a pretty common pattern so create a function for it.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r-- | ofproto/ofproto-dpif-ipfix.c | 6 | ||||
-rw-r--r-- | ofproto/ofproto-dpif-sflow.c | 6 | ||||
-rw-r--r-- | ofproto/ofproto.c | 5 |
3 files changed, 5 insertions, 12 deletions
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c index 35f481d0a..5744abbcb 100644 --- a/ofproto/ofproto-dpif-ipfix.c +++ b/ofproto/ofproto-dpif-ipfix.c @@ -469,12 +469,6 @@ nullable_string_is_equal(const char *a, const char *b) return a ? b && !strcmp(a, b) : !b; } -static char * -nullable_xstrdup(const char *s) -{ - return s ? xstrdup(s) : NULL; -} - static bool ofproto_ipfix_bridge_exporter_options_equal( const struct ofproto_ipfix_bridge_exporter_options *a, diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c index 5d26b7c47..7d0aa36f0 100644 --- a/ofproto/ofproto-dpif-sflow.c +++ b/ofproto/ofproto-dpif-sflow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. * Copyright (c) 2009 InMon Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -115,8 +115,8 @@ ofproto_sflow_options_clone(const struct ofproto_sflow_options *old) { struct ofproto_sflow_options *new = xmemdup(old, sizeof *old); sset_clone(&new->targets, &old->targets); - new->agent_device = old->agent_device ? xstrdup(old->agent_device) : NULL; - new->control_ip = old->control_ip ? xstrdup(old->control_ip) : NULL; + new->agent_device = nullable_xstrdup(old->agent_device); + new->control_ip = nullable_xstrdup(old->control_ip); return new; } diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 087b32161..cf3235a63 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -784,8 +784,7 @@ void ofproto_set_cpu_mask(const char *cmask) { free(pmd_cpu_mask); - - pmd_cpu_mask = cmask ? xstrdup(cmask) : NULL; + pmd_cpu_mask = nullable_xstrdup(cmask); } void @@ -811,7 +810,7 @@ void ofproto_set_dp_desc(struct ofproto *p, const char *dp_desc) { free(p->dp_desc); - p->dp_desc = dp_desc ? xstrdup(dp_desc) : NULL; + p->dp_desc = nullable_xstrdup(dp_desc); } int |