SDL: improve error msg for unwritable config #105

Following up on 1ba2eef which fixed a crash caused by trying to write to
a NULL FILE* due to fopen() failure: write the error message to stderr
instead of trace.log and show the OS error using strerror_r().
This commit is contained in:
Rafael Kitover 2017-04-27 08:46:03 -07:00
parent cab6f0f026
commit 02a1e38e6c
1 changed files with 3 additions and 1 deletions

View File

@ -759,7 +759,9 @@ void SaveConfigFile()
{
FILE *f = fopen(configFile, "w");
if (f == NULL) {
log("Configuration file could not be opened %s\n", optarg);
char err_buf[4096];
char* err_msg = strerror_r(errno, err_buf, 4096);
fprintf(stderr, "Configuration file '%s' could not be written to: %s\n", configFile, err_msg);
return;
}
// Needs mixed case version of the option name to add new options into the ini