summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-06-01 19:22:13 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-06-01 19:22:13 +0100
commitd38794635a763174d62790cf350ee5665737c6ef (patch)
tree77068c5eca225e658baea54ff2a833b05f7c9ece /config.c
parentc3f421e4046faf8b5f39cd1ad36bc4869405fcc9 (diff)
Use errno to handle getconfint() failing.
Diffstat (limited to 'config.c')
-rw-r--r--config.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/config.c b/config.c
index 41f07d6..ad7e31c 100644
--- a/config.c
+++ b/config.c
@@ -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