@@ -377,6 +377,7 @@ void init_menu_system_values(){
377377 volume_percentage = 50 ; // /wrong value: setting default to 50
378378 }
379379 else {
380+ pclose (fp);
380381 fgets (res, sizeof (res)-1 , fp);
381382
382383 // / Check if Volume is a number (at least the first char)
@@ -397,6 +398,7 @@ void init_menu_system_values(){
397398 brightness_percentage = 50 ; // /wrong value: setting default to 50
398399 }
399400 else {
401+ pclose (fp);
400402 fgets (res, sizeof (res)-1 , fp);
401403
402404 // / Check if brightness is a number (at least the first char)
@@ -640,7 +642,10 @@ void run_menu_loop()
640642 RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof (u16 ));
641643
642644 /* Stop Ampli */
643- popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
645+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
646+ if (fp != NULL ) {
647+ pclose (fp);
648+ }
644649
645650 // / -------- Main loop ---------
646651 while (!stop_menu_loop)
@@ -718,7 +723,9 @@ void run_menu_loop()
718723 fp = popen (shell_cmd, " r" );
719724 if (fp == NULL ) {
720725 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
721- }
726+ } else {
727+ pclose (fp);
728+ }
722729
723730 // / ------ Refresh screen ------
724731 screen_refresh = 1 ;
@@ -734,6 +741,8 @@ void run_menu_loop()
734741 fp = popen (shell_cmd, " r" );
735742 if (fp == NULL ) {
736743 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
744+ } else {
745+ pclose (fp);
737746 }
738747 // / ------ Refresh screen ------
739748 screen_refresh = 1 ;
@@ -790,6 +799,8 @@ void run_menu_loop()
790799 fp = popen (shell_cmd, " r" );
791800 if (fp == NULL ) {
792801 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
802+ } else {
803+ pclose (fp);
793804 }
794805 // / ------ Refresh screen ------
795806 screen_refresh = 1 ;
@@ -805,6 +816,8 @@ void run_menu_loop()
805816 fp = popen (shell_cmd, " r" );
806817 if (fp == NULL ) {
807818 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
819+ } else {
820+ pclose (fp);
808821 }
809822 // / ------ Refresh screen ------
810823 screen_refresh = 1 ;
@@ -865,6 +878,8 @@ void run_menu_loop()
865878 fp = popen (shell_cmd, " r" );
866879 if (fp == NULL ) {
867880 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
881+ } else {
882+ pclose (fp);
868883 }
869884
870885 stop_menu_loop = 1 ;
@@ -903,6 +918,8 @@ void run_menu_loop()
903918 fp = popen (shell_cmd, " r" );
904919 if (fp == NULL ) {
905920 MENU_ERROR_PRINTF (" Failed to run command %s\n " , shell_cmd);
921+ } else {
922+ pclose (fp);
906923 }
907924
908925 stop_menu_loop = 1 ;
@@ -998,7 +1015,10 @@ void run_menu_loop()
9981015 }
9991016
10001017 /* Start Ampli */
1001- popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1018+ fp = popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1019+ if (fp != NULL ) {
1020+ pclose (fp);
1021+ }
10021022}
10031023
10041024
@@ -1020,10 +1040,14 @@ int launch_resume_menu_loop()
10201040 stop_menu_loop = 0 ;
10211041 uint8_t screen_refresh = 1 ;
10221042 uint8_t menu_confirmation = 0 ;
1023- int option_idx=RESUME_YES;
1043+ int option_idx=RESUME_YES;
1044+ FILE *fp;
10241045
10251046 /* Stop Ampli */
1026- popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
1047+ fp = popen (SHELL_CMD_TURN_AMPLI_OFF, " r" );
1048+ if (fp != NULL ) {
1049+ pclose (fp);
1050+ }
10271051
10281052 /* Save prev key repeat params and set new Key repeat */
10291053 SDL_GetKeyRepeat (&backup_key_repeat_delay, &backup_key_repeat_interval);
@@ -1188,7 +1212,10 @@ int launch_resume_menu_loop()
11881212 }
11891213
11901214 /* Start Ampli */
1191- popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1215+ fp = popen (SHELL_CMD_TURN_AMPLI_ON, " r" );
1216+ if (fp != NULL ) {
1217+ pclose (fp);
1218+ }
11921219
11931220 return option_idx;
11941221}
0 commit comments