summaryrefslogtreecommitdiff
path: root/elfutils/libelf/elf32_getphdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'elfutils/libelf/elf32_getphdr.c')
-rw-r--r--elfutils/libelf/elf32_getphdr.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/elfutils/libelf/elf32_getphdr.c b/elfutils/libelf/elf32_getphdr.c
index 9a7b883c..25693687 100644
--- a/elfutils/libelf/elf32_getphdr.c
+++ b/elfutils/libelf/elf32_getphdr.c
@@ -1,5 +1,5 @@
/* Get ELF program header table.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
This program is free software; you can redistribute it and/or modify
@@ -67,18 +67,16 @@ elfw2(LIBELFBITS,getphdr) (elf)
{
/* Read the section header table. */
ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr;
- size_t phnum;
- size_t size;
/* If no program header exists return NULL. */
- phnum = ehdr->e_phnum;
+ size_t phnum = ehdr->e_phnum;
if (phnum == 0)
{
__libelf_seterrno (ELF_E_NO_PHDR);
goto out;
}
- size = phnum * sizeof (ElfW2(LIBELFBITS,Phdr));
+ size_t size = phnum * sizeof (ElfW2(LIBELFBITS,Phdr));
if (elf->map_address != NULL)
{
@@ -92,7 +90,6 @@ elfw2(LIBELFBITS,getphdr) (elf)
((char *) elf->map_address + elf->start_offset + ehdr->e_phoff);
else
{
- size_t cnt;
ElfW2(LIBELFBITS,Phdr) *notcvt;
ElfW2(LIBELFBITS,Phdr) *phdr;
@@ -124,7 +121,7 @@ elfw2(LIBELFBITS,getphdr) (elf)
size);
}
- for (cnt = 0; cnt < phnum; ++cnt)
+ for (size_t cnt = 0; cnt < phnum; ++cnt)
{
CONVERT_TO (phdr[cnt].p_type, notcvt[cnt].p_type);
CONVERT_TO (phdr[cnt].p_offset, notcvt[cnt].p_offset);
@@ -166,11 +163,10 @@ elfw2(LIBELFBITS,getphdr) (elf)
of the host convert the data now. */
if (ehdr->e_ident[EI_DATA] != MY_ELFDATA)
{
- ElfW2(LIBELFBITS,Phdr) *phdr;
- size_t cnt;
+ ElfW2(LIBELFBITS,Phdr) *phdr
+ = elf->state.ELFW(elf,LIBELFBITS).phdr;
- phdr = elf->state.ELFW(elf,LIBELFBITS).phdr;
- for (cnt = 0; cnt < phnum; ++cnt)
+ for (size_t cnt = 0; cnt < phnum; ++cnt)
{
CONVERT (phdr[cnt].p_type);
CONVERT (phdr[cnt].p_offset);