diff --git a/kpatch-build/Makefile b/kpatch-build/Makefile index 7a63cb4..5354f2d 100644 --- a/kpatch-build/Makefile +++ b/kpatch-build/Makefile @@ -1,6 +1,6 @@ include ../Makefile.inc -CFLAGS += -I../kmod/core +CFLAGS += -I../kmod/core -Wall LDFLAGS = -lelf TARGETS = create-diff-object add-patches-section link-vmlinux-syms diff --git a/kpatch-build/add-patches-section.c b/kpatch-build/add-patches-section.c index 45c6e07..9a22996 100644 --- a/kpatch-build/add-patches-section.c +++ b/kpatch-build/add-patches-section.c @@ -141,7 +141,7 @@ static void find_section_by_name(struct elf *elf, char *name, struct section *se GElf_Shdr sh; char *secname; - while (scn = elf_nextscn(elf->elf, scn)) { + while ((scn = elf_nextscn(elf->elf, scn))) { if (!gelf_getshdr(scn, &sh)) ERROR("gelf_getshdr"); @@ -207,7 +207,6 @@ int main(int argc, char **argv) struct symlist symlist, symlistv; struct sym *cur, *vsym; struct elf elf, elfv; - char name[255]; void *buf; struct kpatch_patch *patches_data; GElf_Rela *relas_data; @@ -252,7 +251,7 @@ int main(int argc, char **argv) cur->vm_addr = vsym->sym.st_value; cur->vm_len = vsym->sym.st_size; cur->action = PATCH; - printf("original function at address %016lx (length %d)\n", + printf("original function at address %016lx (length %zu)\n", cur->vm_addr, cur->vm_len); patches_nr++; } diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 0a0acde..4fbebd6 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -428,7 +428,6 @@ struct kpatch_elf *kpatch_elf_open(const char *name) void kpatch_compare_correlated_nonrela_section(struct section *sec) { struct section *sec1 = sec, *sec2 = sec->twin; - enum status status; /* Compare section headers (must match or fatal) */ if (sec1->sh.sh_type != sec2->sh.sh_type || @@ -666,8 +665,7 @@ void kpatch_correlate_elfs(struct kpatch_elf *kelf1, struct kpatch_elf *kelf2) void kpatch_compare_correlated_elements(struct kpatch_elf *kelf) { struct section *sec; - struct rela *rela; - int i, j; + int i; /* tables are already correlated at this point */ kpatch_compare_correlated_nonrela_sections(&kelf->sections); @@ -715,7 +713,7 @@ void kpatch_dump_kelf(struct kpatch_elf *kelf) printf(", base-> %s\n", sec->base->name); printf("rela section expansion\n"); for_each_rela(j, rela, &sec->relas) { - printf("sym %d, offset %d, type %d, %s %s %d %s\n", + printf("sym %lu, offset %d, type %d, %s %s %d %s\n", GELF_R_SYM(rela->rela.r_info), rela->offset, rela->type, rela->sym->name, @@ -1158,7 +1156,7 @@ void kpatch_create_symtab(struct kpatch_elf *kelf) void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile) { - int fd, i, index = 0; + int fd, i; struct section *sec; Elf *elfout; GElf_Ehdr eh, ehout; diff --git a/kpatch-build/link-vmlinux-syms.c b/kpatch-build/link-vmlinux-syms.c index 0ae30fa..81716d8 100644 --- a/kpatch-build/link-vmlinux-syms.c +++ b/kpatch-build/link-vmlinux-syms.c @@ -138,7 +138,7 @@ static void find_section_by_name(struct elf *elf, char *name, struct section *se GElf_Shdr sh; char *secname; - while (scn = elf_nextscn(elf->elf, scn)) { + while ((scn = elf_nextscn(elf->elf, scn))) { if (!gelf_getshdr(scn, &sh)) ERROR("gelf_getshdr"); @@ -205,17 +205,9 @@ int main(int argc, char **argv) struct sym *cur, *vsym; struct elf elf, elfv; char name[255]; - void *buf; - struct kpatch_patch *patches_data; - GElf_Rela *relas_data; - int patches_nr = 0, i, patches_size, relas_size, len; - int patches_offset, relas_offset, patches_index, relas_index; struct section symtab; Elf_Scn *scn; Elf_Data *data; - GElf_Shdr sh, *shp; - GElf_Ehdr eh; - GElf_Sym sym; /* set elf version (required by libelf) */ if (elf_version(EV_CURRENT) == EV_NONE) @@ -280,7 +272,7 @@ int main(int argc, char **argv) cur->vm_addr = vsym->sym.st_value; cur->vm_len = vsym->sym.st_size; cur->action = LINK; - printf("original symbol at address %016lx (length %d)\n", + printf("original symbol at address %016lx (length %zu)\n", cur->vm_addr, cur->vm_len); } @@ -360,7 +352,6 @@ int main(int argc, char **argv) #endif find_section_by_name(&elf, ".symtab", &symtab); scn = symtab.scn; - shp = &symtab.sh; data = elf_getdata(scn, NULL); if (!data)