diff options
author | David Sommerseth <davids@redhat.com> | 2013-12-16 12:26:24 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2013-12-16 12:26:50 +0100 |
commit | 44838a858671264cfb2085a3b1dbe6e01ca48feb (patch) | |
tree | 411578cbbc577b8e314fc3d821302f1c2e2d68ab | |
parent | a05f17ca5737d03b127dd599363f009d5c6c8d48 (diff) | |
download | python-ethtool-44838a858671264cfb2085a3b1dbe6e01ca48feb.tar.gz python-ethtool-44838a858671264cfb2085a3b1dbe6e01ca48feb.tar.xz python-ethtool-44838a858671264cfb2085a3b1dbe6e01ca48feb.zip |
Get rid of a single-user macro: RETURN_STRING()
Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r-- | python-ethtool/etherinfo_obj.c | 6 | ||||
-rw-r--r-- | python-ethtool/etherinfo_struct.h | 8 |
2 files changed, 5 insertions, 9 deletions
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c index 6acc571..56d88e7 100644 --- a/python-ethtool/etherinfo_obj.c +++ b/python-ethtool/etherinfo_obj.c @@ -145,7 +145,11 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o) } if( strcmp(attr, "device") == 0 ) { - return RETURN_STRING(self->data->ethinfo->device); + if( self->data->ethinfo->device ) { + return PyString_FromString(self->data->ethinfo->device); + } else { + return Py_INCREF(Py_None), Py_None; + } } else if( strcmp(attr, "mac_address") == 0 ) { get_etherinfo(self->data, NLQRY_LINK); Py_INCREF(self->data->ethinfo->hwaddress); diff --git a/python-ethtool/etherinfo_struct.h b/python-ethtool/etherinfo_struct.h index e5e6ecd..6d2da36 100644 --- a/python-ethtool/etherinfo_struct.h +++ b/python-ethtool/etherinfo_struct.h @@ -72,14 +72,6 @@ typedef struct { } etherinfo_py; -/** - * NULL safe PyString_FromString() wrapper. If input string is NULL, None will be returned - * - * @param str Input C string (char *) - * - * @return Returns a PyObject with either the input string wrapped up, or a Python None value. - */ -#define RETURN_STRING(str) (str ? PyString_FromString(str) : (Py_INCREF(Py_None), Py_None)) PyObject * make_python_address_from_rtnl_addr(struct rtnl_addr *addr); |