From 53ea3e8733d34ebd3477f36c4b4265934b981e7d Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 13 Nov 2010 07:24:08 +0900 Subject: [PATCH] Don't take reference count based on if result To make the code more readable turn the failure into a clear error case and only take the reference count later in the code flow. --- plugins/portal.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/portal.c b/plugins/portal.c index d0d2383..f1d5ce3 100644 --- a/plugins/portal.c +++ b/plugins/portal.c @@ -106,6 +106,7 @@ static int location_detect(struct connman_location *location) struct server_data *data; enum connman_service_type service_type; const char *interface; + int err; DBG("location %p", location); @@ -150,9 +151,12 @@ static int location_detect(struct connman_location *location) g_web_set_user_agent(data->web, "ConnMan/%s", VERSION); g_web_set_close_connection(data->web, TRUE); - if (connman_proxy_lookup(interface, STATUS_URL, - proxy_callback, location) > 0) - connman_location_ref(location); + err = connman_proxy_lookup(interface, STATUS_URL, + proxy_callback, location); + if (err < 0) + return err; + + connman_location_ref(location); return 0; } -- 2.7.4