diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-06-30 18:08:58 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-06-30 18:08:58 -0300 |
commit | 269214d44de140b5f83c782b7ac30b5687c784d6 (patch) | |
tree | 9659ae1cdb444b9885a33b29771420bafbffd1dc /python-ethtool/ethtool.c | |
parent | 04f4e1bf7df81a0ddf43ab608a2030ca20bfce37 (diff) | |
download | python-ethtool-269214d44de140b5f83c782b7ac30b5687c784d6.tar.gz python-ethtool-269214d44de140b5f83c782b7ac30b5687c784d6.tar.xz python-ethtool-269214d44de140b5f83c782b7ac30b5687c784d6.zip |
ethtool: Make get_dev_int_value generic
Will be used for ETHTOOL_GCOALESCE and others that retrieve a struct.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'python-ethtool/ethtool.c')
-rw-r--r-- | python-ethtool/ethtool.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/python-ethtool/ethtool.c b/python-ethtool/ethtool.c index 752d869..cc439cf 100644 --- a/python-ethtool/ethtool.c +++ b/python-ethtool/ethtool.c @@ -405,7 +405,7 @@ static PyObject *get_businfo(PyObject *self __unused, PyObject *args) return PyString_FromString(((struct ethtool_drvinfo *)buf)->bus_info); } -static int get_dev_int_value(int cmd, PyObject *args, int *value) +static int get_dev_value(int cmd, PyObject *args, void *value, size_t len) { struct ethtool_value eval; struct ifreq ifr; @@ -438,11 +438,16 @@ static int get_dev_int_value(int cmd, PyObject *args, int *value) } close(fd); - *value = eval.data; + memcpy(value, eval.data, len); return err; } +static int get_dev_int_value(int cmd, PyObject *args, int *value) +{ + return get_dev_value(cmd, args, value, sizeof(*value)); +} + static PyObject *get_tso(PyObject *self __unused, PyObject *args) { int value; |