Skip to content

Commit 269214d

Browse files
committed
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>
1 parent 04f4e1b commit 269214d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python-ethtool/ethtool.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static PyObject *get_businfo(PyObject *self __unused, PyObject *args)
405405
return PyString_FromString(((struct ethtool_drvinfo *)buf)->bus_info);
406406
}
407407

408-
static int get_dev_int_value(int cmd, PyObject *args, int *value)
408+
static int get_dev_value(int cmd, PyObject *args, void *value, size_t len)
409409
{
410410
struct ethtool_value eval;
411411
struct ifreq ifr;
@@ -438,11 +438,16 @@ static int get_dev_int_value(int cmd, PyObject *args, int *value)
438438
}
439439

440440
close(fd);
441-
*value = eval.data;
441+
memcpy(value, eval.data, len);
442442

443443
return err;
444444
}
445445

446+
static int get_dev_int_value(int cmd, PyObject *args, int *value)
447+
{
448+
return get_dev_value(cmd, args, value, sizeof(*value));
449+
}
450+
446451
static PyObject *get_tso(PyObject *self __unused, PyObject *args)
447452
{
448453
int value;

0 commit comments

Comments
 (0)