x86/vdso/vdso2c: Convert iterators to unsigned
authorDmitry Safonov <dima@arista.com>
Mon, 20 Apr 2020 18:32:55 +0000 (19:32 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 21 Apr 2020 18:33:16 +0000 (20:33 +0200)
`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 <avagin@openvz.org>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20200420183256.660371-4-dima@arista.com
arch/x86/entry/vdso/vdso2c.h

index a20b134de2a891d52aa9b88b59d4e78fbc13fc6b..6f46e11ce5390248c4f08d1260fdde7ef74b5b2b 100644 (file)
@@ -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 mapping_size;
        ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
-       int i;
-       unsigned long j;
+       unsigned long i, syms_nr;
        ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
                *alt_sec = NULL;
        ELF(Dyn) *dyn = 0, *dyn_end = 0;
@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
        strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
                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 */
-       for (i = 0;
-            i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
-            i++) {
-               int k;
+       for (i = 0; i < syms_nr; i++) {
+               unsigned int k;
                ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
                        GET_LE(&symtab_hdr->sh_entsize) * i;
                const char *sym_name = raw_addr +
@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
        fprintf(outfile,
                "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
                mapping_size);
-       for (j = 0; j < stripped_len; j++) {
-               if (j % 10 == 0)
+       for (i = 0; i < stripped_len; i++) {
+               if (i % 10 == 0)
                        fprintf(outfile, "\n\t");
                fprintf(outfile, "0x%02X, ",
-                       (int)((unsigned char *)stripped_addr)[j]);
+                       (int)((unsigned char *)stripped_addr)[i]);
        }
        fprintf(outfile, "\n};\n\n");