Skip to content

Commit

Permalink
gdb: use a range based for loop when iterating over an array
Browse files Browse the repository at this point in the history
Make use of a range based for loop to iterate over a static global
array, removing the need to have a null entry at the end of the
array.

There should be no user visible changes after this commit.
  • Loading branch information
T-J-Teru committed Feb 24, 2022
1 parent 7ff9170 commit dd1ae8e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions gdb/python/py-type.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ static struct pyty_code pyty_codes[] =
ENTRY (TYPE_CODE_NAMESPACE),
ENTRY (TYPE_CODE_DECFLOAT),
ENTRY (TYPE_CODE_INTERNAL_FUNCTION),
{ TYPE_CODE_UNDEF, NULL }
};


Expand Down Expand Up @@ -1445,19 +1444,16 @@ _initialize_py_type ()
int
gdbpy_initialize_types (void)
{
int i;

if (PyType_Ready (&type_object_type) < 0)
return -1;
if (PyType_Ready (&field_object_type) < 0)
return -1;
if (PyType_Ready (&type_iterator_object_type) < 0)
return -1;

for (i = 0; pyty_codes[i].name; ++i)
for (const auto &item : pyty_codes)
{
if (PyModule_AddIntConstant (gdb_module, pyty_codes[i].name,
pyty_codes[i].code) < 0)
if (PyModule_AddIntConstant (gdb_module, item.name, item.code) < 0)
return -1;
}

Expand Down

0 comments on commit dd1ae8e

Please sign in to comment.