daemon: print warning only if val couldn't be parsed

We don't want to print a warning if the setting is missing from the
config file. That's totally normal (e.g. the config we ship has all its
configs commented out). We *do* want to print a warning if the config is
provided, but it couldn't be parsed as a proper `uint64`.

Closes: #1215
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-01-18 17:39:19 +00:00 committed by Atomic Bot
parent 9e24e9c793
commit 183cb952e3

View File

@ -323,8 +323,9 @@ get_config_uint64 (GKeyFile *keyfile,
guint64 r = g_key_file_get_uint64 (keyfile, DAEMON_CONFIG_GROUP, key, &local_error);
if (!local_error)
return r;
sd_journal_print (LOG_WARNING, "Bad value for key '%s': %s; using compiled defaults",
key, local_error->message);
if (g_error_matches (local_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE))
sd_journal_print (LOG_WARNING, "Bad uint64 for '%s': %s; using compiled defaults",
key, local_error->message);
}
return default_val;
}