libnm: fix return value for nm_wireguard_peer_append_allowed_ip()

According to documentation, this returns a boolean indicating whether
the value is valid. Previously, it was indicating whether the instance
was modified.

Together with the @accept_invalid argument, both behaviors make some
sense. Change it, because that is also how the other setters behave.

(cherry picked from commit f3ac8c6fe8)
This commit is contained in:
Thomas Haller
2019-03-02 15:38:01 +01:00
parent f617d5e8b4
commit 506a59b62e

View File

@@ -647,6 +647,7 @@ _peer_append_allowed_ip (NMWireGuardPeer *self,
int prefix;
NMIPAddr addrbin;
char *str;
gboolean is_valid = TRUE;
nm_assert (NM_IS_WIREGUARD_PEER (self, FALSE));
nm_assert (allowed_ip);
@@ -662,6 +663,7 @@ _peer_append_allowed_ip (NMWireGuardPeer *self,
return FALSE;
/* mark the entry as invalid by having a "X" prefix. */
str = g_strconcat (ALLOWED_IP_INVALID_X_STR, allowed_ip, NULL);
is_valid = FALSE;
} else {
char addrstr[NM_UTILS_INET_ADDRSTRLEN];
@@ -679,7 +681,7 @@ _peer_append_allowed_ip (NMWireGuardPeer *self,
self->allowed_ips = g_ptr_array_new_with_free_func (g_free);
g_ptr_array_add (self->allowed_ips, str);
return TRUE;
return is_valid;
}
/**