Skip to content

Commit 0fe94d0

Browse files
committed
Improved intendation
1 parent 719444c commit 0fe94d0

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

python-ethtool/etherinfo.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,16 @@ static int _set_device_index(PyEtherInfo *self)
127127
*/
128128
if( self->index < 0 ) {
129129
if( (errno = rtnl_link_alloc_cache(get_nlc(), AF_UNSPEC, &link_cache)) < 0) {
130-
PyErr_SetString(PyExc_OSError, nl_geterror(errno));
131-
return 0;
132-
}
133-
134-
link = rtnl_link_get_by_name(link_cache, PyBytes_AsString(self->device));
135-
if( !link ) {
130+
PyErr_SetString(PyExc_OSError, nl_geterror(errno));
131+
return 0;
132+
}
133+
link = rtnl_link_get_by_name(link_cache, PyStr_AsString(self->device));
134+
if( !link ) {
136135
errno = ENODEV;
137136
PyErr_SetFromErrno(PyExc_IOError);
138137
nl_cache_free(link_cache);
139-
return 0;
140-
}
141-
138+
return 0;
139+
}
142140
self->index = rtnl_link_get_ifindex(link);
143141
if( self->index <= 0 ) {
144142
errno = ENODEV;
@@ -147,6 +145,7 @@ static int _set_device_index(PyEtherInfo *self)
147145
nl_cache_free(link_cache);
148146
return 0;
149147
}
148+
150149
rtnl_link_put(link);
151150
nl_cache_free(link_cache);
152151
}
@@ -244,20 +243,21 @@ PyObject * get_etherinfo_address(PyEtherInfo *self, nlQuery query)
244243
}
245244

246245
/* Query the for requested info via NETLINK */
247-
248-
/* Extract IP address information */
249-
if( (err = rtnl_addr_alloc_cache(get_nlc(), &addr_cache)) < 0) {
250-
PyErr_SetString(PyExc_OSError, nl_geterror(err));
251-
nl_cache_free(addr_cache);
252-
return NULL;
253-
}
254-
addr = rtnl_addr_alloc();
255-
if( !addr ) {
256-
errno = ENOMEM;
257-
PyErr_SetFromErrno(PyExc_OSError);
258-
return NULL;
259-
}
260-
rtnl_addr_set_ifindex(addr, self->index);
246+
/* Extract IP address information */
247+
if( (err = rtnl_addr_alloc_cache(get_nlc(), &addr_cache)) < 0) {
248+
PyErr_SetString(PyExc_OSError, nl_geterror(err));
249+
nl_cache_free(addr_cache);
250+
return NULL;
251+
}
252+
253+
addr = rtnl_addr_alloc();
254+
255+
if( !addr ) {
256+
errno = ENOMEM;
257+
PyErr_SetFromErrno(PyExc_OSError);
258+
return NULL;
259+
}
260+
rtnl_addr_set_ifindex(addr, self->index);
261261

262262
switch( query ) {
263263
case NLQRY_ADDR4:

python-ethtool/ethtool.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,19 @@ static PyObject *get_interfaces_info(PyObject *self __unused, PyObject *args) {
266266

267267
devlist = PyList_New(0);
268268
for( i = 0; i < fetch_devs_len; i++ ) {
269-
PyEtherInfo *dev = NULL;
269+
PyEtherInfo *dev = NULL;
270270

271271
/* Store the device name and a reference to the NETLINK connection for
272272
* objects to use when quering for device info
273273
*/
274274

275-
dev = PyObject_New(PyEtherInfo, &PyEtherInfo_Type);
276-
if( !dev ) {
275+
dev = PyObject_New(PyEtherInfo, &PyEtherInfo_Type);
276+
if( !dev ) {
277277
PyErr_SetFromErrno(PyExc_OSError);
278278
free(fetch_devs);
279279
return NULL;
280-
}
280+
}
281+
281282
dev->device = PyStr_FromString(fetch_devs[i]);
282283
dev->hwaddress = NULL;
283284
dev->index = -1;

0 commit comments

Comments
 (0)