Skip to content

Commit 833e55b

Browse files
0x7f454c46KAGA-KOKO
authored andcommitted
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: Andrei Vagin <[email protected]> Signed-off-by: Andrei Vagin <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 089ef55 commit 833e55b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

arch/x86/entry/vdso/vdso2c.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
1313
unsigned long load_size = -1; /* Work around bogus warning */
1414
unsigned long mapping_size;
1515
ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
16-
int i;
17-
unsigned long j;
16+
unsigned long i, syms_nr;
1817
ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
1918
*alt_sec = NULL;
2019
ELF(Dyn) *dyn = 0, *dyn_end = 0;
@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
8685
strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
8786
GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link);
8887

88+
syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
8989
/* Walk the symbol table */
90-
for (i = 0;
91-
i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
92-
i++) {
93-
int k;
90+
for (i = 0; i < syms_nr; i++) {
91+
unsigned int k;
9492
ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
9593
GET_LE(&symtab_hdr->sh_entsize) * i;
9694
const char *sym_name = raw_addr +
@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
150148
fprintf(outfile,
151149
"static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
152150
mapping_size);
153-
for (j = 0; j < stripped_len; j++) {
154-
if (j % 10 == 0)
151+
for (i = 0; i < stripped_len; i++) {
152+
if (i % 10 == 0)
155153
fprintf(outfile, "\n\t");
156154
fprintf(outfile, "0x%02X, ",
157-
(int)((unsigned char *)stripped_addr)[j]);
155+
(int)((unsigned char *)stripped_addr)[i]);
158156
}
159157
fprintf(outfile, "\n};\n\n");
160158

0 commit comments

Comments
 (0)