diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-06-01 19:22:13 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-06-01 19:22:13 +0100 |
commit | d38794635a763174d62790cf350ee5665737c6ef (patch) | |
tree | 77068c5eca225e658baea54ff2a833b05f7c9ece /config.c | |
parent | c3f421e4046faf8b5f39cd1ad36bc4869405fcc9 (diff) |
Use errno to handle getconfint() failing.
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -91,11 +91,13 @@ int getconfstr(char *confname, char *filename, char* dest) { // Returns the value of the configuration option with name // 'confname' from configuration file 'filename'. +// Sets errno to 0 on success, or ECONFINT if it fails, in which case the return value is undefined. int getconfint(char *confname, char *filename) { + errno = 0; char result[MAXCHAR]; if (!getconfstr(confname, filename, result)) { - printf("getconfint(): error getting configuration option '%s' from configuration file '%s'.\n", confname, filename); debugprint(DEBUG_CRIT, "getconfint(): error getting configuration option '%s' from configuration file '%s'.\n", confname, filename); + errno = ECONFINT; } return strtol(result, NULL, 10); // Convert resulting string to an integer, base 10 |