From: Daniel Stenberg Date: Mon, 6 Apr 2026 20:21:12 +0000 (+0200) Subject: lib: reserve 'result' for CURLcode X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f5d1a38d15fa0812865e620c1911a02b18c8e67;p=thirdparty%2Fcurl.git lib: reserve 'result' for CURLcode For consistency, whereever we use a local variable named 'result' that is a CURLcode type. Make other types use other names. Closes #21244 --- diff --git a/lib/conncache.c b/lib/conncache.c index 39e4d71666..76817a9283 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -375,7 +375,7 @@ int Curl_cpool_check_limits(struct Curl_easy *data, size_t dest_limit = 0; size_t total_limit = 0; size_t shutdowns; - int result = CPOOL_LIMIT_OK; + int res = CPOOL_LIMIT_OK; if(!cpool) return CPOOL_LIMIT_OK; @@ -425,7 +425,7 @@ int Curl_cpool_check_limits(struct Curl_easy *data, shutdowns = Curl_cshutdn_dest_count(cpool->idata, conn->destination); } if((live + shutdowns) >= dest_limit) { - result = CPOOL_LIMIT_DEST; + res = CPOOL_LIMIT_DEST; goto out; } } @@ -453,14 +453,14 @@ int Curl_cpool_check_limits(struct Curl_easy *data, shutdowns = Curl_cshutdn_count(cpool->idata); } if((cpool->num_conn + shutdowns) >= total_limit) { - result = CPOOL_LIMIT_TOTAL; + res = CPOOL_LIMIT_TOTAL; goto out; } } out: CPOOL_UNLOCK(cpool, cpool->idata); - return result; + return res; } CURLcode Curl_cpool_add(struct Curl_easy *data, @@ -626,7 +626,7 @@ bool Curl_cpool_find(struct Curl_easy *data, } if(done_cb) { - result = done_cb(result, userdata); + result = done_cb(userdata); } CPOOL_UNLOCK(cpool, data); return result; diff --git a/lib/conncache.h b/lib/conncache.h index 139633d3ae..7cee4d4729 100644 --- a/lib/conncache.h +++ b/lib/conncache.h @@ -98,7 +98,7 @@ typedef bool Curl_cpool_conn_match_cb(struct connectdata *conn, void *userdata); /* Act on the result of the find, may override it. */ -typedef bool Curl_cpool_done_match_cb(bool result, void *userdata); +typedef bool Curl_cpool_done_match_cb(void *userdata); /** * Find a connection in the pool matching `destination`. diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index 25552c7b9a..6733010468 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -296,7 +296,7 @@ HANDLE curlx_CreateFile(const char *filename, int curlx_win32_open(const char *filename, int oflag, ...) { int pmode = 0; - int result = -1; + int res = -1; TCHAR *fixed = NULL; const TCHAR *target = NULL; @@ -316,7 +316,7 @@ int curlx_win32_open(const char *filename, int oflag, ...) target = fixed; else target = filename_w; - errno = _wsopen_s(&result, target, oflag, _SH_DENYNO, pmode); + errno = _wsopen_s(&res, target, oflag, _SH_DENYNO, pmode); CURLX_FREE(filename_w); } else @@ -327,16 +327,16 @@ int curlx_win32_open(const char *filename, int oflag, ...) target = fixed; else target = filename; - errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode); + errno = _sopen_s(&res, target, oflag, _SH_DENYNO, pmode); #endif CURLX_FREE(fixed); - return result; + return res; } FILE *curlx_win32_fopen(const char *filename, const char *mode) { - FILE *result = NULL; + FILE *file = NULL; TCHAR *fixed = NULL; const TCHAR *target = NULL; @@ -348,7 +348,7 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) target = fixed; else target = filename_w; - result = _wfsopen(target, mode_w, _SH_DENYNO); + file = _wfsopen(target, mode_w, _SH_DENYNO); } else /* !checksrc! disable ERRNOVAR 1 */ @@ -360,11 +360,11 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) target = fixed; else target = filename; - result = _fsopen(target, mode, _SH_DENYNO); + file = _fsopen(target, mode, _SH_DENYNO); #endif CURLX_FREE(fixed); - return result; + return file; } #if defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR < 5) @@ -374,7 +374,7 @@ _CRTIMP errno_t __cdecl freopen_s(FILE **file, const char *filename, FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) { - FILE *result = NULL; + FILE *file = NULL; TCHAR *fixed = NULL; const TCHAR *target = NULL; @@ -386,7 +386,7 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) target = fixed; else target = filename_w; - errno = _wfreopen_s(&result, target, mode_w, fp); + errno = _wfreopen_s(&file, target, mode_w, fp); } else /* !checksrc! disable ERRNOVAR 1 */ @@ -398,16 +398,16 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) target = fixed; else target = filename; - errno = freopen_s(&result, target, mode, fp); + errno = freopen_s(&file, target, mode, fp); #endif CURLX_FREE(fixed); - return result; + return file; } int curlx_win32_stat(const char *path, curlx_struct_stat *buffer) { - int result = -1; + int res = -1; TCHAR *fixed = NULL; const TCHAR *target = NULL; @@ -418,7 +418,7 @@ int curlx_win32_stat(const char *path, curlx_struct_stat *buffer) target = fixed; else target = path_w; - result = _wstati64(target, buffer); + res = _wstati64(target, buffer); curlx_free(path_w); } else @@ -429,11 +429,11 @@ int curlx_win32_stat(const char *path, curlx_struct_stat *buffer) target = fixed; else target = path; - result = _stati64(target, buffer); + res = _stati64(target, buffer); #endif CURLX_FREE(fixed); - return result; + return res; } #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_COOKIES) || \ diff --git a/lib/fake_addrinfo.c b/lib/fake_addrinfo.c index d8b139830b..5a89202064 100644 --- a/lib/fake_addrinfo.c +++ b/lib/fake_addrinfo.c @@ -41,16 +41,16 @@ void r_freeaddrinfo(struct addrinfo *cahead) } struct context { - struct ares_addrinfo *result; + struct ares_addrinfo *addr; }; static void async_addrinfo_cb(void *userp, int status, int timeouts, - struct ares_addrinfo *result) + struct ares_addrinfo *addr) { struct context *ctx = (struct context *)userp; (void)timeouts; if(ARES_SUCCESS == status) { - ctx->result = result; + ctx->addr = addr; } } @@ -184,11 +184,11 @@ int r_getaddrinfo(const char *node, /* Wait until no more requests are left to be processed */ ares_queue_wait_empty(channel, -1); - if(ctx.result) { + if(ctx.addr) { /* convert the c-ares version */ - *res = mk_getaddrinfo(ctx.result); + *res = mk_getaddrinfo(ctx.addr); /* free the old */ - ares_freeaddrinfo(ctx.result); + ares_freeaddrinfo(ctx.addr); } else rc = EAI_NONAME; /* got nothing */ diff --git a/lib/mime.c b/lib/mime.c index f4be1d6332..93210d2613 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -162,19 +162,20 @@ static curl_off_t VmsSpecialSize(const char *name, static FILE *vmsfopenread(const char *file, const char *mode) { curlx_struct_stat statbuf; - int result; - - result = curlx_stat(file, &statbuf); - - switch(statbuf.st_fab_rfm) { - case FAB$C_VAR: - case FAB$C_VFC: - case FAB$C_STMCR: - return curlx_fopen(file, FOPEN_READTEXT); /* VMS */ - break; - default: - return curlx_fopen(file, FOPEN_READTEXT, "rfm=stmlf", "ctx=stm"); + int res = curlx_stat(file, &statbuf); + + if(res != -1) { + switch(statbuf.st_fab_rfm) { + case FAB$C_VAR: + case FAB$C_VFC: + case FAB$C_STMCR: + return curlx_fopen(file, FOPEN_READTEXT); /* VMS */ + break; + default: + return curlx_fopen(file, FOPEN_READTEXT, "rfm=stmlf", "ctx=stm"); + } } + return NULL; } #define fopen_read vmsfopenread @@ -1001,7 +1002,7 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence) { curl_mime *mime = (curl_mime *)instream; curl_mimepart *part; - int result = CURL_SEEKFUNC_OK; + int rc = CURL_SEEKFUNC_OK; if(whence != SEEK_SET || offset) return CURL_SEEKFUNC_CANTSEEK; /* Only support full rewind. */ @@ -1012,13 +1013,13 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence) for(part = mime->firstpart; part; part = part->nextpart) { int res = mime_part_rewind(part); if(res != CURL_SEEKFUNC_OK) - result = res; + rc = res; } - if(result == CURL_SEEKFUNC_OK) + if(rc == CURL_SEEKFUNC_OK) mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL); - return result; + return rc; } /* Release part content. */ diff --git a/lib/progress.c b/lib/progress.c index aa0eeb327c..230000939d 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -632,18 +632,18 @@ static void progress_meter(struct Curl_easy *data) static CURLcode pgrsupdate(struct Curl_easy *data, bool showprogress) { if(!data->progress.hide) { + int rc; if(data->set.fxferinfo) { - int result; /* There is a callback set, call that */ Curl_set_in_callback(data, TRUE); - result = data->set.fxferinfo(data->set.progress_client, - data->progress.dl.total_size, - data->progress.dl.cur_size, - data->progress.ul.total_size, - data->progress.ul.cur_size); + rc = data->set.fxferinfo(data->set.progress_client, + data->progress.dl.total_size, + data->progress.dl.cur_size, + data->progress.ul.total_size, + data->progress.ul.cur_size); Curl_set_in_callback(data, FALSE); - if(result != CURL_PROGRESSFUNC_CONTINUE) { - if(result) { + if(rc != CURL_PROGRESSFUNC_CONTINUE) { + if(rc) { failf(data, "Callback aborted"); return CURLE_ABORTED_BY_CALLBACK; } @@ -651,17 +651,16 @@ static CURLcode pgrsupdate(struct Curl_easy *data, bool showprogress) } } else if(data->set.fprogress) { - int result; /* The older deprecated callback is set, call that */ Curl_set_in_callback(data, TRUE); - result = data->set.fprogress(data->set.progress_client, - (double)data->progress.dl.total_size, - (double)data->progress.dl.cur_size, - (double)data->progress.ul.total_size, - (double)data->progress.ul.cur_size); + rc = data->set.fprogress(data->set.progress_client, + (double)data->progress.dl.total_size, + (double)data->progress.dl.cur_size, + (double)data->progress.ul.total_size, + (double)data->progress.ul.cur_size); Curl_set_in_callback(data, FALSE); - if(result != CURL_PROGRESSFUNC_CONTINUE) { - if(result) { + if(rc != CURL_PROGRESSFUNC_CONTINUE) { + if(rc) { failf(data, "Callback aborted"); return CURLE_ABORTED_BY_CALLBACK; } diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index b94471b622..7158487555 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -106,7 +106,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, CURLcode code; size_t actualread; size_t nwritten; - int result; + CURLcode result; OM_uint32 gss_major_status, gss_minor_status, gss_status; OM_uint32 gss_ret_flags; int gss_conf_state, gss_enc; diff --git a/lib/url.c b/lib/url.c index d5078c4bf4..23ab8a9e4c 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1267,10 +1267,9 @@ static bool url_match_conn(struct connectdata *conn, void *userdata) return TRUE; } -static bool url_match_result(bool result, void *userdata) +static bool url_match_result(void *userdata) { struct url_conn_match *match = userdata; - (void)result; if(match->found) { /* Attach it now while still under lock, so the connection does * no longer appear idle and can be reaped. */ diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index ec3bb015ec..430c840f05 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -1135,7 +1135,7 @@ static CURLcode cr_connect(struct Curl_cfilter *cf, struct Curl_easy *data, (struct rustls_ssl_backend_data *)connssl->backend; const struct rustls_connection *rconn = NULL; CURLcode tmperr = CURLE_OK; - int result; + CURLcode result; bool wants_read; bool wants_write; @@ -1155,12 +1155,12 @@ static CURLcode cr_connect(struct Curl_cfilter *cf, struct Curl_easy *data, #endif /* USE_ECH */ if(!backend->conn) { - result = cr_init_backend(cf, data, - (struct rustls_ssl_backend_data *)connssl->backend); + result = + cr_init_backend(cf, data, + (struct rustls_ssl_backend_data *)connssl->backend); CURL_TRC_CF(data, cf, "cr_connect, init backend -> %d", result); - if(result != CURLE_OK) { + if(result) return result; - } connssl->state = ssl_connection_negotiating; } rconn = backend->conn;