fp = fopen(download_path, "wb");
curl_ret_code = curl_easy_setopt(curl, CURLOPT_URL, download_url);
- retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_URL : ret_code[%d]", curl_ret_code);
+ if (CURLE_OK != curl_ret_code) {
+ _E("Failed to curl_easy_setopt with CURLOPT_URL : ret_code[%d]", curl_ret_code);
+ goto clean;
+ }
curl_ret_code = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
- retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_WRITEFUNCTION : ret_code[%d]", curl_ret_code);
+ if (CURLE_OK != curl_ret_code) {
+ _E("Failed to curl_easy_setopt with CURLOPT_WRITEFUNCTION : ret_code[%d]", curl_ret_code);
+ goto clean;
+ }
curl_ret_code = curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
- retvm_if(CURLE_OK != curl_ret_code, -EIO, "Failed to curl_easy_setopt with CURLOPT_WRITEDATA : ret_code[%d]", curl_ret_code);
+ if (CURLE_OK != curl_ret_code) {
+ _E("Failed to curl_easy_setopt with CURLOPT_WRITEDATA : ret_code[%d]", curl_ret_code);
+ goto clean;
+ }
err = curl_easy_perform(curl);
+clean:
curl_easy_cleanup(curl);
fclose(fp);
+ if (CURLE_OK != curl_ret_code) {
+ return -EIO;
+ }
+
#ifdef DOWNLOAD_MONITORING
int status;
pthread_join(p_thread, (void **)&status);