mmcli: don't assume that mm_object_peek_modem or mm_object_get_modem return non null
This very peculiar case can happen when an intermediate initiliazition step of a modem fails. The ModemManager daemon should always expose the modem interface but let not assume that in mmcli and protect these calls. Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
This commit is contained in:

committed by
Aleksander Morgado

parent
2f53a08e5f
commit
18b72a046e
@@ -205,7 +205,9 @@ find_modem (MMManager *manager,
|
||||
MMModem *modem;
|
||||
|
||||
obj = MM_OBJECT (l->data);
|
||||
modem = MM_MODEM (mm_object_get_modem (obj));
|
||||
modem = mm_object_get_modem (obj);
|
||||
if (!modem)
|
||||
continue;
|
||||
|
||||
if (modem_any ||
|
||||
(modem_path && g_str_equal (mm_object_get_path (obj), modem_path)) ||
|
||||
|
@@ -332,9 +332,14 @@ output_modem_info (MMObject *obj,
|
||||
gchar *extra;
|
||||
const gchar *manufacturer;
|
||||
const gchar *model;
|
||||
MMModem *modem;
|
||||
|
||||
manufacturer = mm_modem_get_manufacturer (mm_object_peek_modem (obj));
|
||||
model = mm_modem_get_model (mm_object_peek_modem (obj));
|
||||
modem = mm_object_peek_modem (obj);
|
||||
if (!modem)
|
||||
return;
|
||||
|
||||
manufacturer = mm_modem_get_manufacturer (modem);
|
||||
model = mm_modem_get_model (modem);
|
||||
extra = g_strdup_printf ("[%s] %s",
|
||||
manufacturer ? manufacturer : "manufacturer unknown",
|
||||
model ? model : "model unknown");
|
||||
|
Reference in New Issue
Block a user