Skip to content

Commit 7a5f234

Browse files
committed
Remove unreachable code (CWE-561) and unnecessary labels
1 parent 6f9ad51 commit 7a5f234

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

python-ethtool/ethtool.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ static PyObject *__struct_desc_create_dict(struct struct_desc *table,
730730
PyObject *dict = PyDict_New();
731731

732732
if (dict == NULL)
733-
goto out;
733+
return NULL;
734734

735735
for (i = 0; i < nr_entries; ++i) {
736736
struct struct_desc *d = &table[i];
@@ -743,21 +743,21 @@ static PyObject *__struct_desc_create_dict(struct struct_desc *table,
743743
break;
744744
}
745745

746-
if (objval == NULL)
747-
goto free_dict;
746+
if (objval == NULL) {
747+
Py_DECREF(dict);
748+
return NULL;
749+
}
748750

749751
if (PyDict_SetItemString(dict, d->name, objval) != 0) {
750752
Py_DECREF(objval);
751-
goto free_dict;
753+
Py_DECREF(dict);
754+
return NULL;
752755
}
753756

754757
Py_DECREF(objval);
755758
}
756-
out:
759+
757760
return dict;
758-
free_dict:
759-
goto out;
760-
dict = NULL;
761761
}
762762

763763
#define struct_desc_create_dict(table, values) \

tests/parse_ifconfig.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,6 @@ def _parse_line_old(self, line):
540540

541541
return
542542

543-
raise ValueError('parser could not handle line: %r' % line)
544-
545543
# ifconfig = IfConfig()
546544
# for dev in ifconfig.devices:
547545
# print(dev)

0 commit comments

Comments
 (0)