cli: fix an bug when reporting an error

$ nmcli dev wifi rescan ifname eteee

(process:21211): libnm-CRITICAL **: nm_device_get_device_type: assertion 'NM_IS_DEVICE (self)' failed
Error: Device 'eteee' is not a Wi-Fi device.

Fixes: 823df334ed
This commit is contained in:
Jiří Klimeš
2015-08-13 09:48:12 +02:00
parent b339d4e5d6
commit bccc1af51b

View File

@@ -2533,15 +2533,9 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv)
device = find_wifi_device_by_iface (devices, ifname, &devices_idx);
if (!device) {
if (ifname) {
const char *err_msg;
if ( nm_device_get_device_type (device) == NM_DEVICE_TYPE_GENERIC
&& g_strcmp0 (nm_device_get_type_description (device), "wifi") == 0)
err_msg = _("Error: Device '%s' was not recognized as a Wi-Fi device, check NetworkManager Wi-Fi plugin.");
else
err_msg = _("Error: Device '%s' is not a Wi-Fi device.");
g_string_printf (nmc->return_text, err_msg, ifname);
} else
if (ifname)
g_string_printf (nmc->return_text, _("Error: Device '%s' is not a Wi-Fi device."), ifname);
else
g_string_printf (nmc->return_text, _("Error: No Wi-Fi device found."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto error;