Skip to content

Commit 2c7655e

Browse files
committed
added pclose
1 parent bea9bff commit 2c7655e

File tree

3 files changed

+60
-19
lines changed

3 files changed

+60
-19
lines changed

configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ sound_driver_list="oss alsa sdl"
3737
sound_drivers="sdl"
3838
have_armv5=""
3939
have_armv6=""
40-
have_armv7="yes"
40+
have_armv7=""
4141
have_arm_neon="yes"
4242
have_libavcodec=""
4343
need_sdl="yes"
4444
need_xlib="no"
4545
# these are for known platforms
4646
optimize_cortexa8="no"
47-
optimize_cortexa7="yes"
47+
optimize_cortexa7="no"
4848
optimize_arm1176jzf="no"
4949
optimize_arm926ej="no"
5050
optimize_arm920="no"

platform/common/emu.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,9 @@ static void run_events_ui(unsigned int which)
11861186
fp = popen(shell_cmd, "r");
11871187
if (fp == NULL) {
11881188
printf("Failed to run command %s\n", shell_cmd);
1189-
}
1189+
}else {
1190+
pclose(fp);
1191+
}
11901192
}
11911193
if (which & PEV_VOL_UP)
11921194
{
@@ -1203,7 +1205,9 @@ static void run_events_ui(unsigned int which)
12031205
fp = popen(shell_cmd, "r");
12041206
if (fp == NULL) {
12051207
printf("Failed to run command %s\n", shell_cmd);
1206-
}
1208+
}else {
1209+
pclose(fp);
1210+
}
12071211
}
12081212
if (which & PEV_BRIGHT_UP)
12091213
{
@@ -1220,7 +1224,9 @@ static void run_events_ui(unsigned int which)
12201224
fp = popen(shell_cmd, "r");
12211225
if (fp == NULL) {
12221226
printf("Failed to run command %s\n", shell_cmd);
1223-
}
1227+
}else {
1228+
pclose(fp);
1229+
}
12241230
}
12251231
if (which & PEV_BRIGHT_DOWN)
12261232
{
@@ -1237,7 +1243,9 @@ static void run_events_ui(unsigned int which)
12371243
fp = popen(shell_cmd, "r");
12381244
if (fp == NULL) {
12391245
printf("Failed to run command %s\n", shell_cmd);
1240-
}
1246+
}else {
1247+
pclose(fp);
1248+
}
12411249
}
12421250
if (which & PEV_AR_FACT_UP)
12431251
{
@@ -1261,7 +1269,9 @@ static void run_events_ui(unsigned int which)
12611269
fp = popen(shell_cmd, "r");
12621270
if (fp == NULL) {
12631271
printf("Failed to run command %s\n", shell_cmd);
1264-
}
1272+
}else {
1273+
pclose(fp);
1274+
}
12651275

12661276
// Save config file
12671277
configfile_save(cfg_file_rom);
@@ -1287,11 +1297,13 @@ static void run_events_ui(unsigned int which)
12871297
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, aspect_ratio_factor_percent);
12881298
fp = popen(shell_cmd, "r");
12891299
if (fp == NULL) {
1290-
printf("Failed to run command %s\n", shell_cmd);
1300+
printf("Failed to run command %s\n", shell_cmd);
1301+
}else {
1302+
pclose(fp);
1303+
}
12911304

12921305
// Save config file
12931306
configfile_save(cfg_file_rom);
1294-
}
12951307

12961308
}
12971309
if (which & PEV_DISPMODE)
@@ -1314,8 +1326,10 @@ static void run_events_ui(unsigned int which)
13141326
//plat_status_msg_busy_first(txt);
13151327
fp = popen(shell_cmd, "r");
13161328
if (fp == NULL) {
1317-
printf("Failed to run command %s\n", shell_cmd);
1318-
}
1329+
printf("Failed to run command %s\n", shell_cmd);
1330+
} else {
1331+
pclose(fp);
1332+
}
13191333

13201334
// Save config file
13211335
configfile_save(cfg_file_rom);
@@ -1433,12 +1447,12 @@ void quick_save_and_poweroff()
14331447
if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
14341448
{
14351449
/* Countdown is still ticking, so better do nothing
1436-
than start writing and get interrupted!
1437-
*/
1450+
than start writing and get interrupted!
1451+
*/
14381452
printf("Failed to cancel scheduled shutdown\n");
1439-
exit(0);
1453+
exit(0);
14401454
}
1441-
1455+
14421456
/* Save */
14431457
emu_save_load_game_from_file(0, quick_save_file);
14441458

platform/common/menu_pico.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ void init_menu_system_values(){
431431
}
432432
else{
433433
fgets(res, sizeof(res)-1, fp);
434+
pclose(fp);
434435

435436
/// Check if Volume is a number (at least the first char)
436437
if(res[0] < '0' || res[0] > '9'){
@@ -451,6 +452,7 @@ void init_menu_system_values(){
451452
}
452453
else{
453454
fgets(res, sizeof(res)-1, fp);
455+
pclose(fp);
454456

455457
/// Check if brightness is a number (at least the first char)
456458
if(res[0] < '0' || res[0] > '9'){
@@ -694,7 +696,10 @@ void run_menu_loop()
694696
RES_HW_SCREEN_HORIZONTAL * RES_HW_SCREEN_VERTICAL * sizeof(uint16_t));
695697

696698
/* Stop Ampli */
697-
popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
699+
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
700+
if (fp != NULL) {
701+
pclose(fp);
702+
}
698703

699704
/// ------ Wait for menu UP key event ------
700705
int actions[IN_BINDTYPE_COUNT] = { 0, };
@@ -787,6 +792,8 @@ void run_menu_loop()
787792
fp = popen(shell_cmd, "r");
788793
if (fp == NULL) {
789794
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
795+
} else {
796+
pclose(fp);
790797
}
791798

792799
/// ------ Refresh screen ------
@@ -803,6 +810,8 @@ void run_menu_loop()
803810
fp = popen(shell_cmd, "r");
804811
if (fp == NULL) {
805812
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
813+
} else {
814+
pclose(fp);
806815
}
807816
/// ------ Refresh screen ------
808817
screen_refresh = 1;
@@ -859,6 +868,8 @@ void run_menu_loop()
859868
fp = popen(shell_cmd, "r");
860869
if (fp == NULL) {
861870
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
871+
} else {
872+
pclose(fp);
862873
}
863874
/// ------ Refresh screen ------
864875
screen_refresh = 1;
@@ -874,6 +885,8 @@ void run_menu_loop()
874885
fp = popen(shell_cmd, "r");
875886
if (fp == NULL) {
876887
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
888+
} else {
889+
pclose(fp);
877890
}
878891
/// ------ Refresh screen ------
879892
screen_refresh = 1;
@@ -940,6 +953,8 @@ void run_menu_loop()
940953
fp = popen(shell_cmd, "r");
941954
if (fp == NULL) {
942955
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
956+
} else {
957+
pclose(fp);
943958
}
944959

945960
stop_menu_loop = 1;
@@ -985,6 +1000,8 @@ void run_menu_loop()
9851000
fp = popen(shell_cmd, "r");
9861001
if (fp == NULL) {
9871002
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1003+
} else {
1004+
pclose(fp);
9881005
}
9891006

9901007
/*snprintf(hud_msg, sizeof(hud_msg), ret == 0 ? "LOADED" : "FAIL!");
@@ -1082,7 +1099,10 @@ void run_menu_loop()
10821099
}
10831100

10841101
/* Start Ampli */
1085-
popen(SHELL_CMD_TURN_AMPLI_ON, "r");
1102+
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
1103+
if (fp != NULL) {
1104+
pclose(fp);
1105+
}
10861106

10871107
/// ------ Reset last screen ------
10881108
SDL_BlitSurface(backup_hw_screen, NULL, hw_screen, NULL);
@@ -1109,12 +1129,16 @@ int launch_resume_menu_loop()
11091129
uint32_t prev_ms = SDL_GetTicks();
11101130
uint32_t cur_ms = SDL_GetTicks();
11111131
stop_menu_loop = 0;
1132+
FILE *fp;
11121133
uint8_t screen_refresh = 1;
11131134
uint8_t menu_confirmation = 0;
11141135
int option_idx=RESUME_YES;
11151136

11161137
/* Stop Ampli */
1117-
popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
1138+
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
1139+
if (fp != NULL) {
1140+
pclose(fp);
1141+
}
11181142

11191143
/* Save prev key repeat params and set new Key repeat */
11201144
SDL_GetKeyRepeat(&backup_key_repeat_delay, &backup_key_repeat_interval);
@@ -1283,7 +1307,10 @@ int launch_resume_menu_loop()
12831307
}
12841308

12851309
/* Start Ampli */
1286-
popen(SHELL_CMD_TURN_AMPLI_ON, "r");
1310+
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
1311+
if (fp != NULL) {
1312+
pclose(fp);
1313+
}
12871314

12881315
return option_idx;
12891316
}

0 commit comments

Comments
 (0)