From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 8F0B03858402; Thu, 24 Feb 2022 16:39:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F0B03858402 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: use a range based for loop when iterating over an array X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 7ff917016a203cdff3074abfcf96c1553944af94 X-Git-Newrev: dd1ae8eaa369ac5c7df7e55c929b42ac8ac44526 Message-Id: <20220224163949.8F0B03858402@sourceware.org> Date: Thu, 24 Feb 2022 16:39:49 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2022 16:39:49 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Ddd1ae8eaa369= ac5c7df7e55c929b42ac8ac44526 commit dd1ae8eaa369ac5c7df7e55c929b42ac8ac44526 Author: Andrew Burgess Date: Tue Nov 30 14:18:09 2021 +0000 gdb: use a range based for loop when iterating over an array =20 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. =20 There should be no user visible changes after this commit. Diff: --- gdb/python/py-type.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 8613534d060..13dae1e2559 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -113,7 +113,6 @@ static struct pyty_code pyty_codes[] =3D ENTRY (TYPE_CODE_NAMESPACE), ENTRY (TYPE_CODE_DECFLOAT), ENTRY (TYPE_CODE_INTERNAL_FUNCTION), - { TYPE_CODE_UNDEF, NULL } }; =20 =0C @@ -1445,8 +1444,6 @@ _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) @@ -1454,10 +1451,9 @@ gdbpy_initialize_types (void) if (PyType_Ready (&type_iterator_object_type) < 0) return -1; =20 - for (i =3D 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; }