wwan: minor cleanup for owns_port() to return early

I find

    for (i = 0; i < n_ports && !owns; i++)
        owns = ...

hard to read.

If the condition is satisfied, we can just return the result right
away.
This commit is contained in:
Thomas Haller 2019-05-17 17:46:57 +02:00
parent 4a10feec16
commit 87f3c50f48

View file

@ -213,12 +213,13 @@ owns_port (NMModem *_self, const char *iface)
NMModemBroadband *self = NM_MODEM_BROADBAND (_self);
const MMModemPortInfo *ports = NULL;
guint n_ports = 0, i;
gboolean owns = FALSE;
mm_modem_peek_ports (self->_priv.modem_iface, &ports, &n_ports);
for (i = 0; i < n_ports && !owns; i++)
owns = (g_strcmp0 (iface, ports[i].name) == 0);
return owns;
for (i = 0; i < n_ports; i++) {
if (nm_streq0 (iface, ports[i].name))
return TRUE;
}
return FALSE;
}
/*****************************************************************************/