config: suppress error if no wireless config present (FS#1030)
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 6 Oct 2017 14:56:42 +0000 (16:56 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 6 Oct 2017 15:31:21 +0000 (17:31 +0200)
Wireless config is optional as not all targets have a wireless interface;
therefore don't report an error if the wireless config is missing so
network reload is not reporting an error to the user.
While at it use netifd_log_message to print an error if the config cannot
be loaded.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
config.c

index a7112f042a677426ab27baff8b8131e0bb4e3d40..21791afa685fe63c7f9bcbc6bb4056d59ebc3941 100644 (file)
--- a/config.c
+++ b/config.c
@@ -412,16 +412,23 @@ int
 config_init_all(void)
 {
        int ret = 0;
+       char *err;
 
        uci_network = config_init_package("network");
        if (!uci_network) {
-               fprintf(stderr, "Failed to load network config\n");
+               uci_get_errorstr(uci_ctx, &err, NULL);
+               netifd_log_message(L_CRIT, "Failed to load network config (%s)\n", err);
+               free(err);
                return -1;
        }
 
        uci_wireless = config_init_package("wireless");
-       if (!uci_wireless)
+       if (!uci_wireless && uci_ctx->err != UCI_ERR_NOTFOUND) {
+               uci_get_errorstr(uci_ctx, &err, NULL);
+               netifd_log_message(L_CRIT, "Failed to load wireless config (%s)\n", err);
+               free(err);
                ret = -1;
+       }
 
        vlist_update(&interfaces);
        config_init = true;