Add noreturn attributes and remove unreachable code.

* grub-core/bus/cs5536.c (grub_cs5536_smbus_wait): Remove unreachable
	code.
	* grub-core/commands/halt.c (grub_cmd_halt): Remove unreachable
	code. Mark as noreturn.
	* grub-core/commands/minicmd.c (grub_mini_cmd_exit): Likewise.
	* grub-core/commands/reboot.c (grub_cmd_reboot): Likewise.
	* grub-core/disk/efi/efidisk.c (grub_efidisk_get_device_name): Remove
	unreachable code.
	* grub-core/kern/main.c (grub_main): Mark as noreturn.
	* grub-core/kern/rescue_reader.c (grub_rescue_run): Likewise.
	* grub-core/lib/posix_wrap/stdlib.h (abort): Likewise.
	* grub-core/normal/menu.c (run_menu): Remove unreachable code.
	* include/grub/kernel.h (grub_main): Mark as noreturn.
	* include/grub/reader.h (grub_rescue_run): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-13 15:13:51 +01:00
parent 2019d09ef0
commit 02a2bf8384
12 changed files with 28 additions and 16 deletions

View file

@ -1,3 +1,22 @@
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
Add noreturn attributes and remove unreachable code.
* grub-core/bus/cs5536.c (grub_cs5536_smbus_wait): Remove unreachable
code.
* grub-core/commands/halt.c (grub_cmd_halt): Remove unreachable
code. Mark as noreturn.
* grub-core/commands/minicmd.c (grub_mini_cmd_exit): Likewise.
* grub-core/commands/reboot.c (grub_cmd_reboot): Likewise.
* grub-core/disk/efi/efidisk.c (grub_efidisk_get_device_name): Remove
unreachable code.
* grub-core/kern/main.c (grub_main): Mark as noreturn.
* grub-core/kern/rescue_reader.c (grub_rescue_run): Likewise.
* grub-core/lib/posix_wrap/stdlib.h (abort): Likewise.
* grub-core/normal/menu.c (run_menu): Remove unreachable code.
* include/grub/kernel.h (grub_main): Mark as noreturn.
* include/grub/reader.h (grub_rescue_run): Likewise.
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com> 2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/i386/qemu/memory.h (grub_machine_mmap_init): Remove * include/grub/i386/qemu/memory.h (grub_machine_mmap_init): Remove

View file

@ -97,8 +97,6 @@ grub_cs5536_smbus_wait (grub_port_t smbbase)
if (grub_get_time_ms () > start + 40) if (grub_get_time_ms () > start + 40)
return grub_error (GRUB_ERR_IO, "SM stalled"); return grub_error (GRUB_ERR_IO, "SM stalled");
} }
return GRUB_ERR_NONE;
} }
grub_err_t grub_err_t

View file

@ -24,13 +24,12 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t static grub_err_t __attribute__ ((noreturn))
grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)), grub_cmd_halt (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),
char **args __attribute__ ((unused))) char **args __attribute__ ((unused)))
{ {
grub_halt (); grub_halt ();
return 0;
} }
static grub_command_t cmd; static grub_command_t cmd;

View file

@ -165,13 +165,13 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
} }
/* exit */ /* exit */
static grub_err_t static grub_err_t __attribute__ ((noreturn))
grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused))) char *argv[] __attribute__ ((unused)))
{ {
grub_exit (); grub_exit ();
return 0; /* Not reached. */
} }
static grub_command_t cmd_cat, cmd_help; static grub_command_t cmd_cat, cmd_help;

View file

@ -24,13 +24,12 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t static grub_err_t __attribute__ ((noreturn))
grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)), grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),
char **args __attribute__ ((unused))) char **args __attribute__ ((unused)))
{ {
grub_reboot (); grub_reboot ();
return 0;
} }
static grub_command_t cmd; static grub_command_t cmd;

View file

@ -791,6 +791,4 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
grub_disk_close (parent); grub_disk_close (parent);
return device_name; return device_name;
} }
return 0;
} }

View file

@ -190,7 +190,7 @@ grub_load_normal_mode (void)
} }
/* The main routine. */ /* The main routine. */
void void __attribute__ ((noreturn))
grub_main (void) grub_main (void)
{ {
/* First of all, initialize the machine. */ /* First of all, initialize the machine. */

View file

@ -74,7 +74,7 @@ grub_rescue_read_line (char **line, int cont)
return 0; return 0;
} }
void void __attribute__ ((noreturn))
grub_rescue_run (void) grub_rescue_run (void)
{ {
grub_printf ("Entering rescue mode...\n"); grub_printf ("Entering rescue mode...\n");

View file

@ -46,7 +46,7 @@ realloc (void *ptr, grub_size_t size)
return grub_realloc (ptr, size); return grub_realloc (ptr, size);
} }
static inline void static inline void __attribute__ ((noreturn))
abort (void) abort (void)
{ {
grub_abort (); grub_abort ();

View file

@ -666,7 +666,6 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
} }
/* Never reach here. */ /* Never reach here. */
return -1;
} }
/* Callback invoked immediately before a menu entry is executed. */ /* Callback invoked immediately before a menu entry is executed. */

View file

@ -82,7 +82,7 @@ extern grub_addr_t EXPORT_VAR (grub_modbase);
grub_addr_t grub_modules_get_end (void); grub_addr_t grub_modules_get_end (void);
/* The start point of the C code. */ /* The start point of the C code. */
void grub_main (void); void grub_main (void) __attribute__ ((noreturn));
/* The machine-specific initialization. This must initialize memory. */ /* The machine-specific initialization. This must initialize memory. */
void grub_machine_init (void); void grub_machine_init (void);

View file

@ -24,6 +24,6 @@
typedef grub_err_t (*grub_reader_getline_t) (char **, int); typedef grub_err_t (*grub_reader_getline_t) (char **, int);
void grub_rescue_run (void); void grub_rescue_run (void) __attribute__ ((noreturn));
#endif /* ! GRUB_READER_HEADER */ #endif /* ! GRUB_READER_HEADER */