@@ -700,7 +700,6 @@ static int btf_elf__write(const char *filename, struct btf *btf)
{
GElf_Ehdr ehdr;
Elf_Data *btf_data = NULL;
- Elf_Scn *scn = NULL;
Elf *elf = NULL;
const void *raw_btf_data;
uint32_t raw_btf_size;
@@ -748,7 +747,7 @@ static int btf_elf__write(const char *filename, struct btf *btf)
*/
elf_getshdrstrndx(elf, &strndx);
- while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ for (Elf_Scn *scn = elf_nextscn(elf, NULL); scn; scn = elf_nextscn(elf, scn)) {
GElf_Shdr shdr;
if (!gelf_getshdr(scn, &shdr))
continue;
The pointer (iterator) scn can be made local to the loop and a more general while-loop is not needed. Signed-off-by: Giuliano Procida <gprocida@google.com> --- libbtf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)