diff --git a/frontend/main.c b/frontend/main.c index 807852af3..7c9c7e854 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -74,10 +74,12 @@ static char *cfg_file_extension = "fkcfg"; /* Quick save and turn off the console */ void quick_save_and_poweroff() { + FILE *fp; printf("Save Instant Play file\n"); /* Send command to cancel any previously scheduled powerdown */ - if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL) + fp = popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r"); + if (fp == NULL) { /* Countdown is still ticking, so better do nothing than start writing and get interrupted! @@ -85,6 +87,7 @@ void quick_save_and_poweroff() printf("Failed to cancel scheduled shutdown\n"); exit(0); } + pclose(fp); /* Save */ if(SaveState(quick_save_file)){ @@ -252,6 +255,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } break; case SACTION_PRE_SAVE_STATE: @@ -262,6 +267,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } emu_action_future = SACTION_SAVE_STATE; @@ -275,6 +282,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } break; #ifndef NO_FRONTEND @@ -328,6 +337,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } // Save config file @@ -349,6 +360,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } // Save config file @@ -371,6 +384,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } // Save config file @@ -429,6 +444,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } break; case SACTION_VOLUME_UP: @@ -442,6 +459,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } break; case SACTION_BRIGHTNESS_DOWN: @@ -455,6 +474,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } break; case SACTION_BRIGHTNESS_UP: @@ -468,6 +489,8 @@ void do_emu_action(void) fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } break; case SACTION_MINIMIZE: diff --git a/frontend/menu.c b/frontend/menu.c index 322342c38..d89202482 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -488,6 +488,7 @@ void init_menu_system_values(){ volume_percentage = 50; ///wrong value: setting default to 50 } else{ + pclose(fp); fgets(res, sizeof(res)-1, fp); /// Check if Volume is a number (at least the first char) @@ -508,6 +509,7 @@ void init_menu_system_values(){ brightness_percentage = 50; ///wrong value: setting default to 50 } else{ + pclose(fp); fgets(res, sizeof(res)-1, fp); /// Check if brightness is a number (at least the first char) @@ -767,7 +769,10 @@ void run_menu_loop() RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof(u16)); /* Stop Ampli */ - popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + if (fp != NULL) { + pclose(fp); + } /// ------ Wait for menu UP key event ------ while(event.type != SDL_KEYUP || event.key.keysym.sym != SDLK_q){ @@ -860,6 +865,8 @@ void run_menu_loop() fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ @@ -876,6 +883,8 @@ void run_menu_loop() fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ screen_refresh = 1; @@ -932,6 +941,8 @@ void run_menu_loop() fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ screen_refresh = 1; @@ -947,6 +958,8 @@ void run_menu_loop() fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } /// ------ Refresh screen ------ screen_refresh = 1; @@ -1013,6 +1026,8 @@ void run_menu_loop() fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } stop_menu_loop = 1; @@ -1058,6 +1073,8 @@ void run_menu_loop() fp = popen(shell_cmd, "r"); if (fp == NULL) { MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd); + } else { + pclose(fp); } stop_menu_loop = 1; @@ -1161,7 +1178,10 @@ void run_menu_loop() } /* Start Ampli */ - popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + if (fp != NULL) { + pclose(fp); + } /// ------ Reset last screen ------ if(reset_last_scren_on_exit){ @@ -1191,9 +1211,13 @@ int launch_resume_menu_loop() uint8_t screen_refresh = 1; uint8_t menu_confirmation = 0; int option_idx=RESUME_YES; + FILE *fp; /* Stop Ampli */ - popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r"); + if (fp != NULL) { + pclose(fp); + } /* Save prev key repeat params and set new Key repeat */ SDL_GetKeyRepeat(&backup_key_repeat_delay, &backup_key_repeat_interval); @@ -1361,7 +1385,10 @@ int launch_resume_menu_loop() } /* Start Ampli */ - popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r"); + if (fp != NULL) { + pclose(fp); + } return option_idx; } @@ -3193,6 +3220,8 @@ static void menu_bios_warn(void) FILE *fp = popen(shell_cmd, "r"); if (fp == NULL) { printf("In %s, Failed to run command %s\n", __func__, shell_cmd); + } else { + pclose(fp); } /// ------ Wait for key press ------ @@ -3206,6 +3235,8 @@ static void menu_bios_warn(void) fp = popen(SHELL_CMD_NOTIF_CLEAR, "r"); if (fp == NULL) { printf("In %s, Failed to run command %s\n", __func__, SHELL_CMD_NOTIF_CLEAR); + } else { + pclose(fp); } }