From: Hans de Goede Date: Mon, 25 Feb 2019 14:45:26 +0000 (+0100) Subject: main: Remove private ply_mode_t X-Git-Tag: 0.9.5~71^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2eceea2ce790007f77af8bf4f5c9af73f89c94c8;p=thirdparty%2Fplymouth.git main: Remove private ply_mode_t Remove the private ply_mode_t from main.c, this is a 1:1 mirror of ply_boot_splash_mode_t, so use ply_boot_splash_mode_t directly, leading to a nice cleanup. Signed-off-by: Hans de Goede --- diff --git a/src/main.c b/src/main.c index 9adff3a0..e406382b 100644 --- a/src/main.c +++ b/src/main.c @@ -58,13 +58,6 @@ #define BOOT_DURATION_FILE PLYMOUTH_TIME_DIRECTORY "/boot-duration" #define SHUTDOWN_DURATION_FILE PLYMOUTH_TIME_DIRECTORY "/shutdown-duration" -typedef enum -{ - PLY_MODE_BOOT, - PLY_MODE_SHUTDOWN, - PLY_MODE_UPDATES -} ply_mode_t; - typedef struct { const char *keys; @@ -93,7 +86,7 @@ typedef struct ply_buffer_t *entry_buffer; ply_list_t *messages; ply_command_parser_t *command_parser; - ply_mode_t mode; + ply_boot_splash_mode_t mode; ply_terminal_t *local_console_terminal; ply_device_manager_t *device_manager; @@ -149,7 +142,7 @@ static void toggle_between_splash_and_details (state_t *state); static void tell_systemd_to_print_details (state_t *state); static void tell_systemd_to_stop_printing_details (state_t *state); #endif -static const char *get_cache_file_for_mode (ply_mode_t mode); +static const char *get_cache_file_for_mode (ply_boot_splash_mode_t mode); static void on_escape_pressed (state_t *state); static void on_enter (state_t *state, const char *line); @@ -163,30 +156,6 @@ static void on_quit (state_t *state, static bool sh_is_init (state_t *state); static void cancel_pending_delayed_show (state_t *state); -static ply_boot_splash_mode_t -get_splash_mode_from_mode (ply_mode_t mode) -{ - ply_boot_splash_mode_t splash_mode; - switch (mode) { - case PLY_MODE_BOOT: - splash_mode = PLY_BOOT_SPLASH_MODE_BOOT_UP; - break; - case PLY_MODE_SHUTDOWN: - splash_mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN; - break; - case PLY_MODE_UPDATES: - splash_mode = PLY_BOOT_SPLASH_MODE_UPDATES; - break; - default: - splash_mode = PLY_BOOT_SPLASH_MODE_INVALID; - break; - } - - assert (splash_mode != PLY_BOOT_SPLASH_MODE_INVALID); - - return splash_mode; -} - static void on_session_output (state_t *state, const char *output, @@ -220,8 +189,6 @@ static void on_change_mode (state_t *state, const char *mode) { - ply_boot_splash_mode_t splash_mode; - if (state->boot_splash == NULL) { ply_trace ("no splash set"); return; @@ -229,17 +196,15 @@ on_change_mode (state_t *state, ply_trace ("updating mode to '%s'", mode); if (strcmp (mode, "boot-up") == 0) - state->mode = PLY_MODE_BOOT; + state->mode = PLY_BOOT_SPLASH_MODE_BOOT_UP; else if (strcmp (mode, "shutdown") == 0) - state->mode = PLY_MODE_SHUTDOWN; + state->mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN; else if (strcmp (mode, "updates") == 0) - state->mode = PLY_MODE_UPDATES; + state->mode = PLY_BOOT_SPLASH_MODE_UPDATES; else return; - splash_mode = get_splash_mode_from_mode (state->mode); - - if (!ply_boot_splash_show (state->boot_splash, splash_mode)) { + if (!ply_boot_splash_show (state->boot_splash, state->mode)) { ply_trace ("failed to update splash"); return; } @@ -689,20 +654,21 @@ on_newroot (state_t *state, } static const char * -get_cache_file_for_mode (ply_mode_t mode) +get_cache_file_for_mode (ply_boot_splash_mode_t mode) { const char *filename; - switch ((int) mode) { - case PLY_MODE_BOOT: + switch (mode) { + case PLY_BOOT_SPLASH_MODE_BOOT_UP: filename = BOOT_DURATION_FILE; break; - case PLY_MODE_SHUTDOWN: + case PLY_BOOT_SPLASH_MODE_SHUTDOWN: filename = SHUTDOWN_DURATION_FILE; break; - case PLY_MODE_UPDATES: + case PLY_BOOT_SPLASH_MODE_UPDATES: filename = NULL; break; + case PLY_BOOT_SPLASH_MODE_INVALID: default: ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__); abort (); @@ -718,17 +684,18 @@ get_log_file_for_state (state_t *state) { const char *filename; - switch ((int) state->mode) { - case PLY_MODE_BOOT: + switch (state->mode) { + case PLY_BOOT_SPLASH_MODE_BOOT_UP: if (state->no_boot_log) filename = NULL; else filename = PLYMOUTH_LOG_DIRECTORY "/boot.log"; break; - case PLY_MODE_SHUTDOWN: - case PLY_MODE_UPDATES: + case PLY_BOOT_SPLASH_MODE_SHUTDOWN: + case PLY_BOOT_SPLASH_MODE_UPDATES: filename = _PATH_DEVNULL; break; + case PLY_BOOT_SPLASH_MODE_INVALID: default: ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__); abort (); @@ -740,18 +707,19 @@ get_log_file_for_state (state_t *state) } static const char * -get_log_spool_file_for_mode (ply_mode_t mode) +get_log_spool_file_for_mode (ply_boot_splash_mode_t mode) { const char *filename; - switch ((int) mode) { - case PLY_MODE_BOOT: + switch (mode) { + case PLY_BOOT_SPLASH_MODE_BOOT_UP: filename = PLYMOUTH_SPOOL_DIRECTORY "/boot.log"; break; - case PLY_MODE_SHUTDOWN: - case PLY_MODE_UPDATES: + case PLY_BOOT_SPLASH_MODE_SHUTDOWN: + case PLY_BOOT_SPLASH_MODE_UPDATES: filename = NULL; break; + case PLY_BOOT_SPLASH_MODE_INVALID: default: ply_error ("Unhandled case in %s line %d\n", __FILE__, __LINE__); abort (); @@ -841,7 +809,7 @@ static bool plymouth_should_ignore_show_splash_calls (state_t *state) { ply_trace ("checking if plymouth should be running"); - if (state->mode != PLY_MODE_BOOT || ply_kernel_command_line_has_argument ("plymouth.force-splash")) + if (state->mode != PLY_BOOT_SPLASH_MODE_BOOT_UP || ply_kernel_command_line_has_argument ("plymouth.force-splash")) return false; if (ply_kernel_command_line_has_argument ("plymouth.ignore-show-splash")) @@ -1213,7 +1181,7 @@ quit_program (state_t *state) #ifdef PLY_ENABLE_DEPRECATED_GDM_TRANSITION if (state->should_retain_splash && - state->mode == PLY_MODE_BOOT) + state->mode == PLY_BOOT_SPLASH_MODE_BOOT_UP) tell_gdm_to_transition (); #endif @@ -1737,7 +1705,6 @@ static ply_boot_splash_t * show_theme (state_t *state, const char *theme_path) { - ply_boot_splash_mode_t splash_mode; ply_boot_splash_t *splash; if (theme_path != NULL) @@ -1752,9 +1719,7 @@ show_theme (state_t *state, if (ply_boot_splash_uses_pixel_displays (splash)) ply_device_manager_activate_renderers (state->device_manager); - splash_mode = get_splash_mode_from_mode (state->mode); - - if (!ply_boot_splash_show (splash, splash_mode)) { + if (!ply_boot_splash_show (splash, state->mode)) { ply_save_errno (); ply_boot_splash_free (splash); ply_restore_errno (); @@ -1985,7 +1950,7 @@ initialize_environment (state_t *state) if (getenv ("DISPLAY") != NULL && access (PLYMOUTH_PLUGIN_PATH "renderers/x11.so", F_OK) == 0) state->default_tty = "/dev/tty"; if (!state->default_tty) { - if (state->mode == PLY_MODE_SHUTDOWN) + if (state->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN) state->default_tty = SHUTDOWN_TTY; else state->default_tty = BOOT_TTY; @@ -2181,11 +2146,11 @@ main (int argc, if (mode_string != NULL) { if (strcmp (mode_string, "shutdown") == 0) - state.mode = PLY_MODE_SHUTDOWN; + state.mode = PLY_BOOT_SPLASH_MODE_SHUTDOWN; else if (strcmp (mode_string, "updates") == 0) - state.mode = PLY_MODE_UPDATES; + state.mode = PLY_BOOT_SPLASH_MODE_UPDATES; else - state.mode = PLY_MODE_BOOT; + state.mode = PLY_BOOT_SPLASH_MODE_BOOT_UP; free (mode_string); }