Skip to content

Commit 44838a8

Browse files
author
David Sommerseth
committed
Get rid of a single-user macro: RETURN_STRING()
Signed-off-by: David Sommerseth <davids@redhat.com>
1 parent a05f17c commit 44838a8

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

python-ethtool/etherinfo_obj.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
145145
}
146146

147147
if( strcmp(attr, "device") == 0 ) {
148-
return RETURN_STRING(self->data->ethinfo->device);
148+
if( self->data->ethinfo->device ) {
149+
return PyString_FromString(self->data->ethinfo->device);
150+
} else {
151+
return Py_INCREF(Py_None), Py_None;
152+
}
149153
} else if( strcmp(attr, "mac_address") == 0 ) {
150154
get_etherinfo(self->data, NLQRY_LINK);
151155
Py_INCREF(self->data->ethinfo->hwaddress);

python-ethtool/etherinfo_struct.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ typedef struct {
7272
} etherinfo_py;
7373

7474

75-
/**
76-
* NULL safe PyString_FromString() wrapper. If input string is NULL, None will be returned
77-
*
78-
* @param str Input C string (char *)
79-
*
80-
* @return Returns a PyObject with either the input string wrapped up, or a Python None value.
81-
*/
82-
#define RETURN_STRING(str) (str ? PyString_FromString(str) : (Py_INCREF(Py_None), Py_None))
8375

8476
PyObject * make_python_address_from_rtnl_addr(struct rtnl_addr *addr);
8577

0 commit comments

Comments
 (0)