diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2014-09-30 23:10:33 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2014-09-30 23:45:21 -0400 |
commit | e47f5a979764c17d59432f2b7b35a89798b1d2ed (patch) | |
tree | 0b1f1b2d9c2ec698ed90e8584e84e0d4e64b1776 | |
parent | ba40241d2238e46021f7f9080911e4c286b7626d (diff) | |
download | gupnp-igd-e47f5a979764c17d59432f2b7b35a89798b1d2ed.tar.gz |
Move pre-conditions to the synchronous functions
-rw-r--r-- | libgupnp-igd/gupnp-simple-igd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libgupnp-igd/gupnp-simple-igd.c b/libgupnp-igd/gupnp-simple-igd.c index efc231a..775c4d3 100644 --- a/libgupnp-igd/gupnp-simple-igd.c +++ b/libgupnp-igd/gupnp-simple-igd.c @@ -923,6 +923,9 @@ gupnp_simple_igd_add_port (GUPnPSimpleIgd *self, GUPnPSimpleIgdClass *klass = GUPNP_SIMPLE_IGD_GET_CLASS (self); g_return_if_fail (klass->add_port); + g_return_if_fail (protocol && local_ip); + g_return_if_fail (local_port > 0); + g_return_if_fail (!strcmp (protocol, "UDP") || !strcmp (protocol, "TCP")); klass->add_port (self, protocol, external_port, local_ip, local_port, lease_duration, description); @@ -936,8 +939,6 @@ gupnp_simple_igd_remove_port_real (GUPnPSimpleIgd *self, struct Mapping *mapping = NULL; guint i; - g_return_if_fail (protocol); - for (i = 0; i < self->priv->mappings->len; i++) { struct Mapping *tmpmapping = g_ptr_array_index (self->priv->mappings, i); @@ -976,6 +977,9 @@ gupnp_simple_igd_remove_port (GUPnPSimpleIgd *self, { GUPnPSimpleIgdClass *klass = GUPNP_SIMPLE_IGD_GET_CLASS (self); + g_return_if_fail (protocol); + g_return_if_fail (external_port <= 65535); + g_return_if_fail (klass->remove_port); klass->remove_port (self, protocol, external_port); |