From 87f3c50f48029dac686c692d94a4daf87bec8fe7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 17 May 2019 17:46:57 +0200 Subject: [PATCH] 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. --- src/devices/wwan/nm-modem-broadband.c | 9 +++++---- 1 file 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; } /*****************************************************************************/