summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-09 18:04:37 +0100
committerThomas Haller <thaller@redhat.com>2018-02-09 21:17:54 +0100
commit5f1c2e16c9cac48de7fa490df08de06080bd7a0c (patch)
tree68b3de19e5c098c783aca1fa1ac5d184730380ee
parent88416394f8e0a51dae9f40a31ca0c8077f08808a (diff)
downloadNetworkManager-5f1c2e16c9cac48de7fa490df08de06080bd7a0c.tar.gz
connectivity: cleanup conditions in curl_check_connectivity()
Refactor the nested ifs to if-else-if-else.
-rw-r--r--src/nm-connectivity.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c
index d29de2d867..bdaba91fd9 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -155,28 +155,29 @@ curl_check_connectivity (CURLM *mhandle, CURLMcode ret)
}
if (cb_data) {
+ NMConnectivityState c;
+
/* If cb_data is still there this message hasn't been
* taken care of. Do so now. */
- if (msg->data.result == CURLE_OK) {
+ if (msg->data.result != CURLE_OK) {
+ _LOG2D ("check failed (%d)", msg->data.result);
+ c = NM_CONNECTIVITY_LIMITED;
+ } else if ( !cb_data->response[0]
+ && (curl_easy_getinfo (msg->easy_handle, CURLINFO_RESPONSE_CODE, &response_code) == CURLE_OK)
+ && response_code == 204) {
/* If we got a 204 error (No content) and we actually requested no content,
* report full connectivity. */
- if (!cb_data->response[0] &&
- (curl_easy_getinfo (msg->easy_handle, CURLINFO_RESPONSE_CODE, &response_code) == CURLE_OK) &&
- response_code == 204) {
- _LOG2D ("response with no content received, check successful");
- finish_cb_data (cb_data, NM_CONNECTIVITY_FULL);
- }
+ _LOG2D ("response with no content received, check successful");
+ c = NM_CONNECTIVITY_FULL;
+ } else {
/* If we get here, it means that easy_write_cb() didn't read enough
* bytes to be able to do a match. */
- else {
- _LOG2I ("response shorter than expected '%s'; assuming captive portal.",
- cb_data->response);
- finish_cb_data (cb_data, NM_CONNECTIVITY_PORTAL);
- }
- } else {
- _LOG2D ("check failed (%d)", msg->data.result);
- finish_cb_data (cb_data, NM_CONNECTIVITY_LIMITED);
+ _LOG2I ("response shorter than expected '%s'; assuming captive portal.",
+ cb_data->response);
+ c = NM_CONNECTIVITY_PORTAL;
}
+
+ finish_cb_data (cb_data, c);
}
curl_multi_remove_handle (mhandle, msg->easy_handle);