Skip to content

Commit 959251d

Browse files
PEP 7hroncok
authored andcommitted
Lines under 80 chars
1 parent 9779a0b commit 959251d

File tree

8 files changed

+135
-78
lines changed

8 files changed

+135
-78
lines changed

python-ethtool/etherinfo.c

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@
4646

4747

4848
/**
49-
* libnl callback function. Does the real parsing of a record returned by NETLINK. This function
50-
* parses LINK related packets
49+
* libnl callback function.
50+
* Does the real parsing of a record returned by NETLINK.
51+
* This function parses LINK related packets
5152
*
5253
* @param obj Pointer to a struct nl_object response
53-
* @param arg Pointer to a struct etherinfo element where the parse result will be saved
54+
* @param arg Pointer to a struct etherinfo element where the parse result
55+
* will be saved
5456
*/
5557
static void callback_nl_link(struct nl_object *obj, void *arg)
5658
{
@@ -72,11 +74,12 @@ static void callback_nl_link(struct nl_object *obj, void *arg)
7274

7375

7476
/**
75-
* libnl callback function. Does the real parsing of a record returned by NETLINK. This function
76-
* parses ADDRESS related packets
77+
* libnl callback function. Does the real parsing of a record returned by
78+
* NETLINK. This function parses ADDRESS related packets
7779
*
7880
* @param obj Pointer to a struct nl_object response
79-
* @param arg Pointer to a struct etherinfo element where the parse result will be saved
81+
* @param arg Pointer to a struct etherinfo element where the parse result
82+
* will be saved
8083
*/
8184
static void callback_nl_address(struct nl_object *obj, void *arg)
8285
{
@@ -109,12 +112,15 @@ static void callback_nl_address(struct nl_object *obj, void *arg)
109112

110113

111114
/**
112-
* Sets the etherinfo.index member to the corresponding device set in etherinfo.device
115+
* Sets the etherinfo.index member to the corresponding device set in
116+
* etherinfo.device
113117
*
114-
* @param self A pointer the current PyEtherInfo Python object which contains the device name
115-
* and the place where to save the corresponding index value.
118+
* @param self A pointer the current PyEtherInfo Python object which contains
119+
* the device name and the place where to save the corresponding
120+
* index value.
116121
*
117-
* @return Returns 1 on success, otherwise 0. On error, a Python error exception is set.
122+
* @return Returns 1 on success, otherwise 0. On error, a Python error
123+
* exception is set.
118124
*/
119125
static int _set_device_index(PyEtherInfo *self)
120126
{
@@ -126,7 +132,8 @@ static int _set_device_index(PyEtherInfo *self)
126132
* interface index if we have that
127133
*/
128134
if (self->index < 0) {
129-
if ((errno = rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache)) < 0) {
135+
if ((errno = rtnl_link_alloc_cache(get_nlc(),
136+
AF_UNSPEC, &link_cache)) < 0) {
130137
PyErr_SetString(PyExc_OSError, nl_geterror(errno));
131138
return 0;
132139
}
@@ -160,7 +167,8 @@ static int _set_device_index(PyEtherInfo *self)
160167
*/
161168

162169
/**
163-
* Populate the PyEtherInfo Python object with link information for the current device
170+
* Populate the PyEtherInfo Python object with link information for the current
171+
* device
164172
*
165173
* @param self Pointer to the device object, a PyEtherInfo Python object
166174
*
@@ -200,7 +208,8 @@ int get_etherinfo_link(PyEtherInfo *self)
200208
return 0;
201209
}
202210
rtnl_link_set_ifindex(link, self->index);
203-
nl_cache_foreach_filter(link_cache, OBJ_CAST(link), callback_nl_link, self);
211+
nl_cache_foreach_filter(link_cache, OBJ_CAST(link),
212+
callback_nl_link, self);
204213
rtnl_link_put(link);
205214
nl_cache_free(link_cache);
206215

@@ -212,12 +221,13 @@ int get_etherinfo_link(PyEtherInfo *self)
212221
/**
213222
* Query NETLINK for device IP address configuration
214223
*
215-
* @param self A PyEtherInfo Python object for the current device to retrieve IP address
216-
* configuration data from
217-
* @param query What to query for. Must be NLQRY_ADDR4 for IPv4 addresses or NLQRY_ADDR6
218-
* for IPv6 addresses.
224+
* @param self A PyEtherInfo Python object for the current device to retrieve
225+
* IP address configuration data from
226+
* @param query What to query for. Must be NLQRY_ADDR4 for IPv4 addresses or
227+
* NLQRY_ADDR6 for IPv6 addresses.
219228
*
220-
* @return Returns a Python list containing PyNetlinkIPaddress objects on success, otherwise NULL
229+
* @return Returns a Python list containing PyNetlinkIPaddress objects on
230+
* success, otherwise NULL
221231
*/
222232
PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
223233
{
@@ -277,7 +287,8 @@ PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
277287
assert(addrlist);
278288

279289
/* Loop through all configured addresses */
280-
nl_cache_foreach_filter(addr_cache, OBJ_CAST(addr), callback_nl_address, addrlist);
290+
nl_cache_foreach_filter(addr_cache, OBJ_CAST(addr),
291+
callback_nl_address, addrlist);
281292
rtnl_addr_put(addr);
282293
nl_cache_free(addr_cache);
283294

python-ethtool/etherinfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#ifndef _ETHERINFO_H
1818
#define _ETHERINFO_H
1919

20-
typedef enum {NLQRY_ADDR4, NLQRY_ADDR6} nlQuery; /**< Supported query types in the etherinfo code */
20+
/** Supported query types in the etherinfo code */
21+
typedef enum {NLQRY_ADDR4, NLQRY_ADDR6} nlQuery;
2122

2223
int get_etherinfo_link(PyEtherInfo *data);
2324
PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query);

python-ethtool/etherinfo_obj.c

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ static PyNetlinkIPaddress * get_last_ipv4_address(PyObject *addrlist)
7171

7272
size = PyList_Size(addrlist);
7373
if (size > 0) {
74-
PyNetlinkIPaddress *item = (PyNetlinkIPaddress *)PyList_GetItem(addrlist, size - 1);
74+
PyNetlinkIPaddress *item = (PyNetlinkIPaddress *)
75+
PyList_GetItem(addrlist, size - 1);
7576
if (Py_TYPE(item) == &ethtool_netlink_ip_address_Type) {
7677
return item;
7778
}
@@ -81,7 +82,8 @@ static PyNetlinkIPaddress * get_last_ipv4_address(PyObject *addrlist)
8182
}
8283

8384
/**
84-
* Creates a human readable format of the information when object is being treated as a string
85+
* Creates a human readable format of the information when object is being
86+
* treated as a string
8587
*
8688
* @param self Pointer to the current PyEtherInfo device object
8789
*
@@ -111,14 +113,17 @@ PyObject *_ethtool_etherinfo_str(PyEtherInfo *self)
111113
if (ipv4addrs) {
112114
Py_ssize_t i;
113115
for (i = 0; i < PyList_Size(ipv4addrs); i++) {
114-
PyNetlinkIPaddress *py_addr = (PyNetlinkIPaddress *)PyList_GetItem(ipv4addrs, i);
116+
PyNetlinkIPaddress *py_addr = (PyNetlinkIPaddress *)
117+
PyList_GetItem(ipv4addrs, i);
115118
PyObject *tmp = PyStr_FromFormat("\tIPv4 address: ");
116119
tmp = PyStr_Concat(tmp, py_addr->local);
117-
tmp = PyStr_Concat(tmp, PyStr_FromFormat("/%d", py_addr->prefixlen));
120+
tmp = PyStr_Concat(tmp,
121+
PyStr_FromFormat("/%d", py_addr->prefixlen));
118122
if (py_addr->ipv4_broadcast) {
119-
tmp = PyStr_Concat(tmp,
120-
PyStr_FromFormat("\tBroadcast: %s\n",
121-
PyStr_AsString(py_addr->ipv4_broadcast)));
123+
tmp = PyStr_Concat(
124+
tmp, PyStr_FromFormat("\tBroadcast: %s\n",
125+
PyStr_AsString(
126+
py_addr->ipv4_broadcast)));
122127
} else {
123128
tmp = PyStr_Concat(tmp, PyStr_FromFormat("\n"));
124129
}
@@ -131,7 +136,8 @@ PyObject *_ethtool_etherinfo_str(PyEtherInfo *self)
131136
if (ipv6addrs) {
132137
Py_ssize_t i;
133138
for (i = 0; i < PyList_Size(ipv6addrs); i++) {
134-
PyNetlinkIPaddress *py_addr = (PyNetlinkIPaddress *)PyList_GetItem(ipv6addrs, i);
139+
PyNetlinkIPaddress *py_addr = (PyNetlinkIPaddress *)
140+
PyList_GetItem(ipv6addrs, i);
135141
PyObject *tmp = PyStr_FromFormat("\tIPv6 address: [%s] %s/%d\n",
136142
PyStr_AsString(py_addr->scope),
137143
PyStr_AsString(py_addr->local),
@@ -146,12 +152,14 @@ PyObject *_ethtool_etherinfo_str(PyEtherInfo *self)
146152
/**
147153
* Returns a tuple list of configured IPv4 addresses
148154
*
149-
* @param self Pointer to the current PyEtherInfo device object to extract IPv4 info from
155+
* @param self Pointer to the current PyEtherInfo device object to extract
156+
* IPv4 info from
150157
* @param notused
151158
*
152159
* @return Returns a Python tuple list of NetlinkIP4Address objects
153160
*/
154-
static PyObject *_ethtool_etherinfo_get_ipv4_addresses(PyEtherInfo *self, PyObject *notused) {
161+
static PyObject *_ethtool_etherinfo_get_ipv4_addresses(PyEtherInfo *self,
162+
PyObject *notused) {
155163
if (!self) {
156164
PyErr_SetString(PyExc_AttributeError, "No data available");
157165
return NULL;
@@ -164,12 +172,14 @@ static PyObject *_ethtool_etherinfo_get_ipv4_addresses(PyEtherInfo *self, PyObje
164172
/**
165173
* Returns a tuple list of configured IPv6 addresses
166174
*
167-
* @param self Pointer to the current PyEtherInfo device object to extract IPv6 info from
175+
* @param self Pointer to the current PyEtherInfo device object to extract
176+
* IPv6 info from
168177
* @param notused
169178
*
170179
* @return Returns a Python tuple list of NetlinkIP6Address objects
171180
*/
172-
static PyObject *_ethtool_etherinfo_get_ipv6_addresses(PyEtherInfo *self, PyObject *notused) {
181+
static PyObject *_ethtool_etherinfo_get_ipv6_addresses(PyEtherInfo *self,
182+
PyObject *notused) {
173183
if (!self) {
174184
PyErr_SetString(PyExc_AttributeError, "No data available");
175185
return NULL;
@@ -184,11 +194,15 @@ static PyObject *_ethtool_etherinfo_get_ipv6_addresses(PyEtherInfo *self, PyObje
184194
*
185195
*/
186196
static PyMethodDef _ethtool_etherinfo_methods[] = {
187-
{ "get_ipv4_addresses", (PyCFunction)_ethtool_etherinfo_get_ipv4_addresses, METH_NOARGS,
188-
"Retrieve configured IPv4 addresses. Returns a list of NetlinkIPaddress objects"
197+
{ "get_ipv4_addresses",
198+
(PyCFunction)_ethtool_etherinfo_get_ipv4_addresses, METH_NOARGS,
199+
"Retrieve configured IPv4 addresses. "
200+
"Returns a list of NetlinkIPaddress objects"
189201
},
190-
{ "get_ipv6_addresses", (PyCFunction)_ethtool_etherinfo_get_ipv6_addresses, METH_NOARGS,
191-
"Retrieve configured IPv6 addresses. Returns a list of NetlinkIPaddress objects"
202+
{ "get_ipv6_addresses",
203+
(PyCFunction)_ethtool_etherinfo_get_ipv6_addresses, METH_NOARGS,
204+
"Retrieve configured IPv6 addresses. "
205+
"Returns a list of NetlinkIPaddress objects"
192206
},
193207
{NULL} /**< No methods defined */
194208
};

python-ethtool/etherinfo_struct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct PyNetlinkIPaddress {
3434
int family; /**< int: must be AF_INET or AF_INET6 */
3535
PyObject *local; /**< string: Configured local IP address */
3636
PyObject *peer; /**< string: Configured peer IP address */
37-
PyObject *ipv4_broadcast; /**< string: Configured IPv4 broadcast address */
37+
PyObject *ipv4_broadcast; /**< string: Configured IPv4 broadcast add. */
3838
int prefixlen; /**< int: Configured network prefix (netmask) */
3939
PyObject *scope; /**< string: IP address scope */
4040
} PyNetlinkIPaddress;

python-ethtool/ethtool-copy.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ struct ethtool_stats {
272272
#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters, priv. */
273273
#define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
274274
#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters, priv. */
275-
#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
276-
#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
277-
#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
278-
#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
275+
#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (e.v.) */
276+
#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (e.v.) */
277+
#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (e.v.) */
278+
#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (e.v.) */
279279
#define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
280280
* (ethtool_value) */
281281
#define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
@@ -284,12 +284,12 @@ struct ethtool_stats {
284284
#define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
285285
#define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
286286
#define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
287-
#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
288-
#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
289-
#define ETHTOOL_GUFO 0x00000021 /* Get UFO enable (ethtool_value) */
290-
#define ETHTOOL_SUFO 0x00000022 /* Set UFO enable (ethtool_value) */
291-
#define ETHTOOL_GGSO 0x00000023 /* Get GSO enable (ethtool_value) */
292-
#define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (ethtool_value) */
287+
#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (e.v.) */
288+
#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (e.v.) */
289+
#define ETHTOOL_GUFO 0x00000021 /* Get UFO enable (e.v.) */
290+
#define ETHTOOL_SUFO 0x00000022 /* Set UFO enable (e.v.) */
291+
#define ETHTOOL_GGSO 0x00000023 /* Get GSO enable (e.v.) */
292+
#define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (e.v.) */
293293

294294
/* compatibility with older code */
295295
#define SPARC_ETH_GSET ETHTOOL_GSET

0 commit comments

Comments
 (0)