summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2013-01-15 15:32:59 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2013-01-15 15:32:59 -0500
commitd33ad02be5a459a26451a1ae3c6506040894bee4 (patch)
treefb768480695fef212fb2de96a548084b1c157f75
parent9ddf5312fe4f890438153fe3d8d50ea61ef326a8 (diff)
downloadpython-ethtool-d33ad02be5a459a26451a1ae3c6506040894bee4.tar.gz
python-ethtool-d33ad02be5a459a26451a1ae3c6506040894bee4.tar.xz
python-ethtool-d33ad02be5a459a26451a1ae3c6506040894bee4.zip
Eliminate "ret" within _ethtool_etherinfo_getter
This variable was confusing cppcheck and potentially could introduce a read of an uninitialized variable if the code were carelessly modified - simplify it.
-rw-r--r--python-ethtool/etherinfo_obj.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/python-ethtool/etherinfo_obj.c b/python-ethtool/etherinfo_obj.c
index cf90601..b158a47 100644
--- a/python-ethtool/etherinfo_obj.c
+++ b/python-ethtool/etherinfo_obj.c
@@ -101,7 +101,6 @@ int _ethtool_etherinfo_init(etherinfo_py *self, PyObject *args, PyObject *kwds)
*/
PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
{
- PyObject *ret;
char *attr = PyString_AsString(attr_o);
if( !self || !self->data ) {
@@ -110,24 +109,22 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
}
if( strcmp(attr, "device") == 0 ) {
- ret = RETURN_STRING(self->data->ethinfo->device);
+ return RETURN_STRING(self->data->ethinfo->device);
} else if( strcmp(attr, "mac_address") == 0 ) {
get_etherinfo(self->data, NLQRY_LINK);
- ret = RETURN_STRING(self->data->ethinfo->hwaddress);
+ return RETURN_STRING(self->data->ethinfo->hwaddress);
} else if( strcmp(attr, "ipv4_address") == 0 ) {
get_etherinfo(self->data, NLQRY_ADDR);
- ret = RETURN_STRING(self->data->ethinfo->ipv4_address);
+ return RETURN_STRING(self->data->ethinfo->ipv4_address);
} else if( strcmp(attr, "ipv4_netmask") == 0 ) {
get_etherinfo(self->data, NLQRY_ADDR);
- ret = PyInt_FromLong(self->data->ethinfo->ipv4_netmask);
+ return PyInt_FromLong(self->data->ethinfo->ipv4_netmask);
} else if( strcmp(attr, "ipv4_broadcast") == 0 ) {
get_etherinfo(self->data, NLQRY_ADDR);
- ret = RETURN_STRING(self->data->ethinfo->ipv4_broadcast);
+ return RETURN_STRING(self->data->ethinfo->ipv4_broadcast);
} else {
- ret = PyObject_GenericGetAttr((PyObject *)self, attr_o);
+ return PyObject_GenericGetAttr((PyObject *)self, attr_o);
}
-
- return ret;
}
/**