diff options
author | Thomas Haller <thaller@redhat.com> | 2019-05-17 17:46:57 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-05-17 17:50:16 +0200 |
commit | 87f3c50f48029dac686c692d94a4daf87bec8fe7 (patch) | |
tree | 49dc2f49ba1888de6d4200ef09d0824e988025ac | |
parent | 4a10feec16a143b4ccdb57b3e7567b6e5bd59511 (diff) | |
download | NetworkManager-87f3c50f48029dac686c692d94a4daf87bec8fe7.tar.gz |
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.
-rw-r--r-- | src/devices/wwan/nm-modem-broadband.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index b63440c2e8..7af43d0790 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -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; } /*****************************************************************************/ |