mirror of
https://github.com/curl/curl.git
synced 2026-07-11 00:17:16 +03:00
tool: return code variable consistency
- ParameterError variables are named 'err' - CURLcode variables are named 'result' For naming consistency across functions Closes #20426
This commit is contained in:
parent
4e5908306a
commit
d0dc6e2ec0
8 changed files with 301 additions and 293 deletions
|
|
@ -61,7 +61,7 @@ CURLcode tool_ssls_load(struct OperationConfig *config,
|
|||
unsigned char *shmac = NULL, *sdata = NULL;
|
||||
char *c, *line, *end;
|
||||
size_t shmac_len, sdata_len;
|
||||
CURLcode r = CURLE_OK;
|
||||
CURLcode result = CURLE_OK;
|
||||
int i, imported;
|
||||
bool error = FALSE;
|
||||
|
||||
|
|
@ -72,8 +72,8 @@ CURLcode tool_ssls_load(struct OperationConfig *config,
|
|||
goto out;
|
||||
}
|
||||
|
||||
r = tool_ssls_easy(config, share, &easy);
|
||||
if(r)
|
||||
result = tool_ssls_easy(config, share, &easy);
|
||||
if(result)
|
||||
goto out;
|
||||
|
||||
i = imported = 0;
|
||||
|
|
@ -89,8 +89,8 @@ CURLcode tool_ssls_load(struct OperationConfig *config,
|
|||
continue;
|
||||
}
|
||||
*c = '\0';
|
||||
r = curlx_base64_decode(line, &shmac, &shmac_len);
|
||||
if(r) {
|
||||
result = curlx_base64_decode(line, &shmac, &shmac_len);
|
||||
if(result) {
|
||||
warnf("invalid shmax base64 encoding in line %d", i);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -100,23 +100,24 @@ CURLcode tool_ssls_load(struct OperationConfig *config,
|
|||
*end = '\0';
|
||||
--end;
|
||||
}
|
||||
r = curlx_base64_decode(line, &sdata, &sdata_len);
|
||||
if(r) {
|
||||
result = curlx_base64_decode(line, &sdata, &sdata_len);
|
||||
if(result) {
|
||||
warnf("invalid sdata base64 encoding in line %d: %s", i, line);
|
||||
continue;
|
||||
}
|
||||
|
||||
r = curl_easy_ssls_import(easy, NULL, shmac, shmac_len, sdata, sdata_len);
|
||||
if(r) {
|
||||
warnf("import of session from line %d rejected(%d)", i, r);
|
||||
result = curl_easy_ssls_import(easy, NULL, shmac, shmac_len, sdata,
|
||||
sdata_len);
|
||||
if(result) {
|
||||
warnf("import of session from line %d rejected(%d)", i, result);
|
||||
continue;
|
||||
}
|
||||
++imported;
|
||||
}
|
||||
if(error)
|
||||
r = CURLE_FAILED_INIT;
|
||||
result = CURLE_FAILED_INIT;
|
||||
else
|
||||
r = CURLE_OK;
|
||||
result = CURLE_OK;
|
||||
|
||||
out:
|
||||
if(easy)
|
||||
|
|
@ -126,7 +127,7 @@ out:
|
|||
curlx_dyn_free(&buf);
|
||||
curlx_free(shmac);
|
||||
curlx_free(sdata);
|
||||
return r;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct tool_ssls_ctx {
|
||||
|
|
@ -144,7 +145,7 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr,
|
|||
struct tool_ssls_ctx *ctx = userptr;
|
||||
char *enc = NULL;
|
||||
size_t enc_len;
|
||||
CURLcode r;
|
||||
CURLcode result;
|
||||
|
||||
(void)easy;
|
||||
(void)valid_until;
|
||||
|
|
@ -156,30 +157,31 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr,
|
|||
"# This file was generated by libcurl! Edit at your own risk.\n",
|
||||
ctx->fp);
|
||||
|
||||
r = curlx_base64_encode(shmac, shmac_len, &enc, &enc_len);
|
||||
if(r)
|
||||
result = curlx_base64_encode(shmac, shmac_len, &enc, &enc_len);
|
||||
if(result)
|
||||
goto out;
|
||||
r = CURLE_WRITE_ERROR;
|
||||
result = CURLE_WRITE_ERROR;
|
||||
if(enc_len != fwrite(enc, 1, enc_len, ctx->fp))
|
||||
goto out;
|
||||
if(EOF == fputc(':', ctx->fp))
|
||||
goto out;
|
||||
tool_safefree(enc);
|
||||
r = curlx_base64_encode(sdata, sdata_len, &enc, &enc_len);
|
||||
if(r)
|
||||
result = curlx_base64_encode(sdata, sdata_len, &enc, &enc_len);
|
||||
if(result)
|
||||
goto out;
|
||||
r = CURLE_WRITE_ERROR;
|
||||
result = CURLE_WRITE_ERROR;
|
||||
if(enc_len != fwrite(enc, 1, enc_len, ctx->fp))
|
||||
goto out;
|
||||
if(EOF == fputc('\n', ctx->fp))
|
||||
goto out;
|
||||
r = CURLE_OK;
|
||||
result = CURLE_OK;
|
||||
ctx->exported++;
|
||||
out:
|
||||
if(r)
|
||||
warnf("Warning: error saving SSL session for '%s': %d", session_key, r);
|
||||
if(result)
|
||||
warnf("Warning: error saving SSL session for '%s': %d", session_key,
|
||||
result);
|
||||
curlx_free(enc);
|
||||
return r;
|
||||
return result;
|
||||
}
|
||||
|
||||
CURLcode tool_ssls_save(struct OperationConfig *config,
|
||||
|
|
@ -187,7 +189,7 @@ CURLcode tool_ssls_save(struct OperationConfig *config,
|
|||
{
|
||||
struct tool_ssls_ctx ctx;
|
||||
CURL *easy = NULL;
|
||||
CURLcode r = CURLE_OK;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
ctx.exported = 0;
|
||||
ctx.fp = curlx_fopen(filename, FOPEN_WRITETEXT);
|
||||
|
|
@ -196,16 +198,16 @@ CURLcode tool_ssls_save(struct OperationConfig *config,
|
|||
goto out;
|
||||
}
|
||||
|
||||
r = tool_ssls_easy(config, share, &easy);
|
||||
if(r)
|
||||
result = tool_ssls_easy(config, share, &easy);
|
||||
if(result)
|
||||
goto out;
|
||||
|
||||
r = curl_easy_ssls_export(easy, tool_ssls_exp, &ctx);
|
||||
result = curl_easy_ssls_export(easy, tool_ssls_exp, &ctx);
|
||||
|
||||
out:
|
||||
if(easy)
|
||||
curl_easy_cleanup(easy);
|
||||
if(ctx.fp)
|
||||
curlx_fclose(ctx.fp);
|
||||
return r;
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue