diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-08-20 13:53:17 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2018-08-20 14:12:27 +0200 |
commit | b9d5a8c37da02ccac5821b7599f4c9cd4461a662 (patch) | |
tree | 86ea64f7db456131aebdfe3cd7f2f9ee4ff84593 /interface.c | |
parent | de394b30b895acc7b4cd4d5ddc78e4710747e613 (diff) |
interface: extend interface error messages in interface_set_up()
Don't return an error code in interface_set_up as it's ignored anyway by the
calling functions; but rather add more interface error messages so the actual
problem is visible for the user by doing ifstatus <interface>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'interface.c')
-rw-r--r-- | interface.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/interface.c b/interface.c index 6be10e2..e143095 100644 --- a/interface.c +++ b/interface.c @@ -1047,31 +1047,35 @@ out: return ret; } -int +void interface_set_up(struct interface *iface) { int ret; + const char *error = NULL; iface->autostart = true; if (iface->state != IFS_DOWN) - return 0; + return; interface_clear_errors(iface); - if (!iface->available) { - interface_add_error(iface, "interface", "NO_DEVICE", NULL, 0); - return -1; - } - - if (iface->main_dev.dev) { - ret = device_claim(&iface->main_dev); - if (!ret) - interface_check_state(iface); - } - else - ret = __interface_set_up(iface); + if (iface->available) { + if (iface->main_dev.dev) { + ret = device_claim(&iface->main_dev); + if (!ret) + interface_check_state(iface); + else + error = "DEVICE_CLAIM_FAILED"; + } else { + ret = __interface_set_up(iface); + if (ret) + error = "SETUP_FAILED"; + } + } else + error = "NO_DEVICE"; - return ret; + if (error) + interface_add_error(iface, "interface", error, NULL, 0); } int |