3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 13:59:24 +01:00

storage: provide proper feedback on failures

network_settings_load expects NULL value to be returned
on failed attempts to read the settings files inside of
storage_network_open. At the same time storage_network_open
used to always return an initialized l_settings
structure despite the outcome of the read operations,
indicating a success.
This commit is contained in:
Tim Kourt 2017-10-31 15:02:58 -07:00 committed by Denis Kenzior
parent f6ae59e48e
commit e7d1b779e7

View File

@ -253,15 +253,29 @@ const char *storage_network_ssid_from_path(const char *path,
struct l_settings *storage_network_open(const char *type, const char *ssid)
{
struct l_settings *settings;
struct stat st;
char *path;
if (ssid == NULL || type == NULL)
return NULL;
path = get_network_file_path(type, ssid);
if (lstat(path, &st) < 0) {
l_free(path);
return NULL;
}
settings = l_settings_new();
l_settings_load_from_file(settings, path);
if (!l_settings_load_from_file(settings, path)) {
l_free(path);
l_settings_free(settings);
return NULL;
}
l_free(path);
return settings;