retvm_if(!curl, -EIO, "Failed to init curl");
curl_ret_code = curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
- retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_HTTPGET : ret_code[%d]", curl_ret_code);
+ retvmf_if(CURLE_OK != curl_ret_code, -EIO, curl_easy_cleanup(curl),
+ "Failed to curl_easy_setopt with CURLOPT_HTTPGET : ret_code[%d]", curl_ret_code);
tmp_header = g_strconcat("X-IOT-UID: ", uid, NULL);
header = curl_slist_append(header, tmp_header);
g_free(tmp_header);
curl_ret_code = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
- retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_HTTPHEADER : ret_code[%d]", curl_ret_code);
+ retvmf_if(CURLE_OK != curl_ret_code, -EIO, curl_easy_cleanup(curl),
+ "Failed to curl_easy_setopt with CURLOPT_HTTPHEADER : ret_code[%d]", curl_ret_code);
snprintf(query, sizeof(query), "?deviceType=%s¤tVersion=%s", device_type, current_version);
req_url = g_strconcat(STDM_URL, query, NULL);
#define retvm_if(expr, val, fmt, arg...) \
do { if (expr) { _E(fmt, ##arg); return (val); } } while (0)
+#define retvmf_if(expr, val, func, fmt, arg...) \
+ do { if (expr) { _E(fmt, ##arg); func; return (val); } } while (0)
+
#ifdef __cplusplus
}
#endif