Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't do important things inside an assert()

Change-Id: Ic408165d58d767a816f97ad3a2b6624e44ecdec0
Reviewed-on: http://review.northscale.com/1308
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
commit d27c3d9606e201e86a1d54c491e01f8bdb74e622 1 parent c448066
@steveyen steveyen authored
Showing with 21 additions and 8 deletions.
  1. +21 −8 rest.c
View
29 rest.c
@@ -158,20 +158,29 @@ static void setup_handle(CURL *handle, char *user, char *pass, char *uri,
if (url != NULL) {
snprintf(url,buff_size,"%s%s",uri,uri_suffix);
- assert(curl_easy_setopt(handle,CURLOPT_WRITEDATA,chandle) == CURLE_OK);
- assert(curl_easy_setopt(handle,CURLOPT_WRITEFUNCTION,handle_response) == CURLE_OK);
- assert(curl_easy_setopt(handle,CURLOPT_URL,url) == CURLE_OK);
+ CURLcode c;
+
+ c = curl_easy_setopt(handle,CURLOPT_WRITEDATA,chandle);
+ assert(c == CURLE_OK);
+ c = curl_easy_setopt(handle,CURLOPT_WRITEFUNCTION,handle_response);
+ assert(c == CURLE_OK);
+ c = curl_easy_setopt(handle,CURLOPT_URL,url);
+ assert(c == CURLE_OK);
if (user) {
buff_size = strlen(user) + strlen(pass) + 2;
char *userpasswd = (char *) malloc(buff_size);
assert(userpasswd);
snprintf(userpasswd,buff_size,"%s:%s",user,pass);
- assert(curl_easy_setopt(handle,CURLOPT_HTTPAUTH,CURLAUTH_BASIC) == CURLE_OK);
- assert(curl_easy_setopt(handle,CURLOPT_USERPWD,userpasswd) == CURLE_OK);
- free (userpasswd);
+ c = curl_easy_setopt(handle,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
+ assert(c == CURLE_OK);
+ c = curl_easy_setopt(handle,CURLOPT_USERPWD,userpasswd);
+ assert(c == CURLE_OK);
+ free(userpasswd);
}
- assert(curl_easy_setopt(handle,CURLOPT_HTTPGET,1) == CURLE_OK);
+
+ c = curl_easy_setopt(handle,CURLOPT_HTTPGET,1);
+ assert(c == CURLE_OK);
free(url);
}
@@ -192,7 +201,11 @@ void* run_rest_conflate(void *arg) {
}
/* init curl */
- assert(curl_global_init(curl_init_flags) == CURLE_OK);
+ CURLcode c;
+
+ c = curl_global_init(curl_init_flags);
+ assert(c == CURLE_OK);
+
CURL *curl_handle = curl_easy_init();
assert(curl_handle);
Please sign in to comment.
Something went wrong with that request. Please try again.