Merge branch 'collectd-5.6' into collectd-5.7
[collectd.git] / src / write_http.c
index 6127c04..4688928 100644 (file)
@@ -114,6 +114,7 @@ static int wh_post_nolock(wh_callback_t *cb, char const *data) /* {{{ */
 {
   int status = 0;
 
+  curl_easy_setopt(cb->curl, CURLOPT_URL, cb->location);
   curl_easy_setopt(cb->curl, CURLOPT_POSTFIELDS, data);
   status = curl_easy_perform(cb->curl);
 
@@ -163,7 +164,6 @@ static int wh_callback_init(wh_callback_t *cb) /* {{{ */
   curl_easy_setopt(cb->curl, CURLOPT_HTTPHEADER, cb->headers);
 
   curl_easy_setopt(cb->curl, CURLOPT_ERRORBUFFER, cb->curl_errbuf);
-  curl_easy_setopt(cb->curl, CURLOPT_URL, cb->location);
   curl_easy_setopt(cb->curl, CURLOPT_FOLLOWLOCATION, 1L);
   curl_easy_setopt(cb->curl, CURLOPT_MAXREDIRS, 50L);
 
@@ -390,6 +390,9 @@ static int wh_write_command(const data_set_t *ds,
   }
   assert(command_len < cb->send_buffer_free);
 
+  /* Make scan-build happy. */
+  assert(cb->send_buffer != NULL);
+
   /* `command_len + 1' because `command_len' does not include the
    * trailing null byte. Neither does `send_buffer_fill'. */
   memcpy(cb->send_buffer + cb->send_buffer_fill, command, command_len + 1);