From 269214d44de140b5f83c782b7ac30b5687c784d6 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 30 Jun 2008 18:08:58 -0300 Subject: 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 --- python-ethtool/ethtool.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'python-ethtool') 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; -- cgit