perf(cli): correct error handling

This commit is contained in:
Masahiko AMANO 2022-12-26 11:53:21 +03:00
parent 600b71ebf9
commit 4f57a32c77

View File

@ -334,9 +334,8 @@ int cli(int argc, char **argv) {
if (status == 0) { if (status == 0) {
config = freopen(NULL, "w", config); config = freopen(NULL, "w", config);
if (config == NULL) { if (config == NULL) {
fprintf(stderr, ERROR("Failed to write to config file. " fprintf(stderr, ERROR("Failed to update config file. "
"Try again with 'sudo' or check your permissions\n")); "Try again with 'sudo' or check your permissions\n"));
return 1;
} }
fputs(abspath, config); fputs(abspath, config);
fclose(config); fclose(config);
@ -354,7 +353,7 @@ int cli(int argc, char **argv) {
if (tanabata_open(&tanabata, abspath) == 0) { if (tanabata_open(&tanabata, abspath) == 0) {
config = freopen(NULL, "w", config); config = freopen(NULL, "w", config);
if (config == NULL) { if (config == NULL) {
fprintf(stderr, ERROR("Failed to write to config file. " fprintf(stderr, ERROR("Failed to update config file. "
"Try again with 'sudo' or check your permissions\n")); "Try again with 'sudo' or check your permissions\n"));
return 1; return 1;
} }