yajl_val code = yajl_tree_get(root, (char const *[]){"error", "code", NULL},
yajl_t_number);
- if (code != NULL) {
+ if (YAJL_IS_INTEGER(code)) {
err->code = YAJL_GET_INTEGER(code);
}
yajl_val message = yajl_tree_get(
root, (char const *[]){"error", "message", NULL}, yajl_t_string);
- if (message != NULL) {
- err->message = strdup(YAJL_GET_STRING(message));
+ if (YAJL_IS_STRING(message)) {
+ char const *m = YAJL_GET_STRING(message);
+ if (m != NULL) {
+ err->message = strdup(m);
+ }
}
return err;
if (status != CURLE_OK) {
ERROR("write_stackdriver plugin: POST %s failed: %s", url, cb->curl_errbuf);
- sfree(ret_content->memory);
- ret_content->size = 0;
+ if (ret_content != NULL) {
+ sfree(ret_content->memory);
+ ret_content->size = 0;
+ }
return -1;
}
curl_easy_getinfo(cb->curl, CURLINFO_RESPONSE_CODE, &http_code);
if (ret_content != NULL) {
- if ((status >= 400) && (status < 500)) {
+ if ((http_code >= 400) && (http_code < 500)) {
ERROR("write_stackdriver plugin: POST %s: %s", url,
API_ERROR_STRING(parse_api_error(ret_content->memory)));
- } else if (status >= 500) {
+ } else if (http_code >= 500) {
WARNING("write_stackdriver plugin: POST %s: %s", url,
ret_content->memory);
}
char *payload = sd_output_reset(cb->formatter);
int status = wg_call_timeseries_write(cb, payload);
- if (status != 0) {
- ERROR("write_stackdriver plugin: Sending buffer failed with status %d.",
- status);
- }
-
wg_reset_buffer(cb);
return status;
} /* }}} wg_flush_nolock */