Commit 833e55bb authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Thomas Gleixner

x86/vdso/vdso2c: Convert iterators to unsigned

`i` and `j` are used everywhere with unsigned types.

Convert `i` to unsigned long in order to avoid signed to unsigned
comparisons.  Convert `k` to unsigned int with the same purpose.
Also, drop `j` as `i` could be used in place of it.
Introduce syms_nr for readability.
Co-developed-by: default avatarAndrei Vagin <avagin@openvz.org>
Signed-off-by: default avatarAndrei Vagin <avagin@openvz.org>
Signed-off-by: default avatarDmitry Safonov <dima@arista.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20200420183256.660371-4-dima@arista.com
parent 089ef557
...@@ -13,8 +13,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ...@@ -13,8 +13,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
unsigned long load_size = -1; /* Work around bogus warning */ unsigned long load_size = -1; /* Work around bogus warning */
unsigned long mapping_size; unsigned long mapping_size;
ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr; ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
int i; unsigned long i, syms_nr;
unsigned long j;
ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr, ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
*alt_sec = NULL; *alt_sec = NULL;
ELF(Dyn) *dyn = 0, *dyn_end = 0; ELF(Dyn) *dyn = 0, *dyn_end = 0;
...@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ...@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) + strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link); GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link);
syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
/* Walk the symbol table */ /* Walk the symbol table */
for (i = 0; for (i = 0; i < syms_nr; i++) {
i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize); unsigned int k;
i++) {
int k;
ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) + ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
GET_LE(&symtab_hdr->sh_entsize) * i; GET_LE(&symtab_hdr->sh_entsize) * i;
const char *sym_name = raw_addr + const char *sym_name = raw_addr +
...@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ...@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
fprintf(outfile, fprintf(outfile,
"static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {", "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
mapping_size); mapping_size);
for (j = 0; j < stripped_len; j++) { for (i = 0; i < stripped_len; i++) {
if (j % 10 == 0) if (i % 10 == 0)
fprintf(outfile, "\n\t"); fprintf(outfile, "\n\t");
fprintf(outfile, "0x%02X, ", fprintf(outfile, "0x%02X, ",
(int)((unsigned char *)stripped_addr)[j]); (int)((unsigned char *)stripped_addr)[i]);
} }
fprintf(outfile, "\n};\n\n"); fprintf(outfile, "\n};\n\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment