Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: remove unreachable code after fatal()

Now compilers can recognize fatal() never returns.

While GCC 4.5 dropped support for -Wunreachable-code, Clang is capable
of detecting the unreachable code.

$ make HOSTCC=clang HOSTCFLAGS=-Wunreachable-code-return
[snip]
HOSTCC scripts/mod/modpost.o
scripts/mod/modpost.c:520:11: warning: 'return' will never be executed [-Wunreachable-code-return]
return 0;
^
scripts/mod/modpost.c:477:10: warning: 'return' will never be executed [-Wunreachable-code-return]
return 0;
^
2 warnings generated.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>

+3 -6
+3 -6
scripts/mod/modpost.c
··· 476 476 fatal("%s: not relocatable object.", filename); 477 477 478 478 /* Check if file offset is correct */ 479 - if (hdr->e_shoff > info->size) { 479 + if (hdr->e_shoff > info->size) 480 480 fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n", 481 481 (unsigned long)hdr->e_shoff, filename, info->size); 482 - return 0; 483 - } 484 482 485 483 if (hdr->e_shnum == SHN_UNDEF) { 486 484 /* ··· 516 518 const char *secname; 517 519 int nobits = sechdrs[i].sh_type == SHT_NOBITS; 518 520 519 - if (!nobits && sechdrs[i].sh_offset > info->size) { 521 + if (!nobits && sechdrs[i].sh_offset > info->size) 520 522 fatal("%s is truncated. sechdrs[i].sh_offset=%lu > sizeof(*hrd)=%zu\n", 521 523 filename, (unsigned long)sechdrs[i].sh_offset, 522 524 sizeof(*hdr)); 523 - return 0; 524 - } 525 + 525 526 secname = secstrings + sechdrs[i].sh_name; 526 527 if (strcmp(secname, ".modinfo") == 0) { 527 528 if (nobits)