tidy-up: make per-file ARRAYSIZE macros global as CURL_ARRAYSIZE
Closes #16111
This commit is contained in:
parent
9da9a0226d
commit
13b2ea68f0
@ -42,11 +42,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CF_HC_INIT,
|
||||
CF_HC_CONNECT,
|
||||
@ -592,8 +587,8 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
|
||||
|
||||
DEBUGASSERT(alpnids);
|
||||
DEBUGASSERT(alpn_count);
|
||||
DEBUGASSERT(alpn_count <= ARRAYSIZE(ctx->ballers));
|
||||
if(!alpn_count || (alpn_count > ARRAYSIZE(ctx->ballers))) {
|
||||
DEBUGASSERT(alpn_count <= CURL_ARRAYSIZE(ctx->ballers));
|
||||
if(!alpn_count || (alpn_count > CURL_ARRAYSIZE(ctx->ballers))) {
|
||||
failf(data, "https-connect filter create with unsupported %zu ALPN ids",
|
||||
alpn_count);
|
||||
return CURLE_FAILED_INIT;
|
||||
@ -607,7 +602,7 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf,
|
||||
ctx->remotehost = remotehost;
|
||||
for(i = 0; i < alpn_count; ++i)
|
||||
cf_hc_baller_assign(&ctx->ballers[i], alpnids[i]);
|
||||
for(; i < ARRAYSIZE(ctx->ballers); ++i)
|
||||
for(; i < CURL_ARRAYSIZE(ctx->ballers); ++i)
|
||||
ctx->ballers[i].alpn_id = ALPN_none;
|
||||
ctx->baller_count = alpn_count;
|
||||
|
||||
@ -663,8 +658,8 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data,
|
||||
if(conn->dns_entry && conn->dns_entry->hinfo &&
|
||||
!conn->dns_entry->hinfo->no_def_alpn) {
|
||||
size_t i, j;
|
||||
for(i = 0; i < ARRAYSIZE(conn->dns_entry->hinfo->alpns) &&
|
||||
alpn_count < ARRAYSIZE(alpn_ids); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(conn->dns_entry->hinfo->alpns) &&
|
||||
alpn_count < CURL_ARRAYSIZE(alpn_ids); ++i) {
|
||||
bool present = FALSE;
|
||||
enum alpnid alpn = conn->dns_entry->hinfo->alpns[i];
|
||||
for(j = 0; j < alpn_count; ++j) {
|
||||
|
||||
@ -41,10 +41,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
static void cf_cntrl_update_info(struct Curl_easy *data,
|
||||
struct connectdata *conn);
|
||||
|
||||
@ -724,7 +720,7 @@ static CURLcode cf_cntrl_all(struct connectdata *conn,
|
||||
CURLcode result = CURLE_OK;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(conn->cfilter); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(conn->cfilter); ++i) {
|
||||
result = Curl_conn_cf_cntrl(conn->cfilter[i], data, ignore_result,
|
||||
event, arg1, arg2);
|
||||
if(!ignore_result && result)
|
||||
|
||||
@ -85,10 +85,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
#if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR)
|
||||
|
||||
enum alpnid Curl_alpn2alpnid(char *name, size_t len)
|
||||
@ -644,7 +640,7 @@ evaluate:
|
||||
*connected = FALSE; /* a negative world view is best */
|
||||
now = Curl_now();
|
||||
ongoing = not_started = 0;
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
|
||||
if(!baller || baller->is_done)
|
||||
@ -705,7 +701,7 @@ evaluate:
|
||||
if(not_started > 0) {
|
||||
int added = 0;
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
|
||||
if(!baller || baller->has_started)
|
||||
@ -739,7 +735,7 @@ evaluate:
|
||||
/* all ballers have failed to connect. */
|
||||
CURL_TRC_CF(data, cf, "all eyeballers failed");
|
||||
result = CURLE_COULDNT_CONNECT;
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
if(!baller)
|
||||
continue;
|
||||
@ -884,7 +880,7 @@ static void cf_he_ctx_clear(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
|
||||
DEBUGASSERT(ctx);
|
||||
DEBUGASSERT(data);
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
baller_free(ctx->baller[i], data);
|
||||
ctx->baller[i] = NULL;
|
||||
}
|
||||
@ -907,7 +903,7 @@ static CURLcode cf_he_shutdown(struct Curl_cfilter *cf,
|
||||
|
||||
/* shutdown all ballers that have not done so already. If one fails,
|
||||
* continue shutting down others until all are shutdown. */
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
bool bdone = FALSE;
|
||||
if(!baller || !baller->cf || baller->shutdown)
|
||||
@ -918,12 +914,12 @@ static CURLcode cf_he_shutdown(struct Curl_cfilter *cf,
|
||||
}
|
||||
|
||||
*done = TRUE;
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
if(ctx->baller[i] && !ctx->baller[i]->shutdown)
|
||||
*done = FALSE;
|
||||
}
|
||||
if(*done) {
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
if(ctx->baller[i] && ctx->baller[i]->result)
|
||||
result = ctx->baller[i]->result;
|
||||
}
|
||||
@ -940,7 +936,7 @@ static void cf_he_adjust_pollset(struct Curl_cfilter *cf,
|
||||
size_t i;
|
||||
|
||||
if(!cf->connected) {
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
if(!baller || !baller->cf)
|
||||
continue;
|
||||
@ -1037,7 +1033,7 @@ static bool cf_he_data_pending(struct Curl_cfilter *cf,
|
||||
if(cf->connected)
|
||||
return cf->next->cft->has_data_pending(cf->next, data);
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
if(!baller || !baller->cf)
|
||||
continue;
|
||||
@ -1056,7 +1052,7 @@ static struct curltime get_max_baller_time(struct Curl_cfilter *cf,
|
||||
size_t i;
|
||||
|
||||
memset(&tmax, 0, sizeof(tmax));
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
@ -1081,7 +1077,7 @@ static CURLcode cf_he_query(struct Curl_cfilter *cf,
|
||||
int reply_ms = -1;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(ctx->baller); i++) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(ctx->baller); i++) {
|
||||
struct eyeballer *baller = ctx->baller[i];
|
||||
int breply_ms;
|
||||
|
||||
@ -1215,7 +1211,7 @@ struct transport_provider transport_providers[] = {
|
||||
static cf_ip_connect_create *get_cf_create(int transport)
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0; i < ARRAYSIZE(transport_providers); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(transport_providers); ++i) {
|
||||
if(transport == transport_providers[i].transport)
|
||||
return transport_providers[i].cf_create;
|
||||
}
|
||||
@ -1469,7 +1465,7 @@ void Curl_debug_set_transport_provider(int transport,
|
||||
cf_ip_connect_create *cf_create)
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0; i < ARRAYSIZE(transport_providers); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(transport_providers); ++i) {
|
||||
if(transport == transport_providers[i].transport) {
|
||||
transport_providers[i].cf_create = cf_create;
|
||||
return;
|
||||
|
||||
@ -933,6 +933,8 @@ endings either CRLF or LF so 't' is appropriate.
|
||||
as their argument */
|
||||
#define STRCONST(x) x,sizeof(x)-1
|
||||
|
||||
#define CURL_ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
|
||||
/* Some versions of the Android NDK is missing the declaration */
|
||||
#if defined(HAVE_GETPWUID_R) && \
|
||||
defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
|
||||
|
||||
@ -53,10 +53,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
void Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
char *ptr, size_t size)
|
||||
{
|
||||
@ -349,13 +345,13 @@ static void trc_apply_level_by_name(const char * const token, int lvl)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(trc_cfts); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(trc_cfts); ++i) {
|
||||
if(strcasecompare(token, trc_cfts[i].cft->name)) {
|
||||
trc_cfts[i].cft->log_level = lvl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < ARRAYSIZE(trc_feats); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(trc_feats); ++i) {
|
||||
if(strcasecompare(token, trc_feats[i].feat->name)) {
|
||||
trc_feats[i].feat->log_level = lvl;
|
||||
break;
|
||||
@ -367,11 +363,11 @@ static void trc_apply_level_by_category(int category, int lvl)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(trc_cfts); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(trc_cfts); ++i) {
|
||||
if(!category || (trc_cfts[i].category & category))
|
||||
trc_cfts[i].cft->log_level = lvl;
|
||||
}
|
||||
for(i = 0; i < ARRAYSIZE(trc_feats); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(trc_feats); ++i) {
|
||||
if(!category || (trc_feats[i].category & category))
|
||||
trc_feats[i].feat->log_level = lvl;
|
||||
}
|
||||
|
||||
@ -83,10 +83,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
/* Local API functions */
|
||||
static CURLcode pop3_regular_transfer(struct Curl_easy *data, bool *done);
|
||||
static CURLcode pop3_do(struct Curl_easy *data, bool *done);
|
||||
@ -226,7 +222,7 @@ static const struct pop3_cmd pop3cmds[] = {
|
||||
static bool pop3_is_multiline(const char *cmdline)
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0; i < ARRAYSIZE(pop3cmds); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(pop3cmds); ++i) {
|
||||
if(strncasecompare(pop3cmds[i].name, cmdline, pop3cmds[i].nlen)) {
|
||||
if(!cmdline[pop3cmds[i].nlen])
|
||||
return pop3cmds[i].multiline;
|
||||
|
||||
@ -125,10 +125,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
#ifdef USE_NGHTTP2
|
||||
static void data_priority_cleanup(struct Curl_easy *data);
|
||||
#else
|
||||
@ -566,7 +562,7 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn)
|
||||
|
||||
DEBUGASSERT(conn);
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(conn->cfilter); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(conn->cfilter); ++i) {
|
||||
Curl_conn_cf_discard_all(data, conn, (int)i);
|
||||
}
|
||||
|
||||
@ -3106,7 +3102,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
|
||||
DEBUGF(infof(data, "check Alt-Svc for host %s", host));
|
||||
if(srcalpnid == ALPN_none) {
|
||||
/* scan all alt-svc protocol ids in order or relevance */
|
||||
for(i = 0; !hit && (i < ARRAYSIZE(alpn_ids)); ++i) {
|
||||
for(i = 0; !hit && (i < CURL_ARRAYSIZE(alpn_ids)); ++i) {
|
||||
srcalpnid = alpn_ids[i];
|
||||
hit = Curl_altsvc_lookup(data->asi,
|
||||
srcalpnid, host, conn->remote_port, /* from */
|
||||
|
||||
@ -82,10 +82,6 @@
|
||||
#define H3_STREAM_SEND_CHUNKS \
|
||||
(H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE)
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC)
|
||||
typedef uint32_t sslerr_t;
|
||||
#else
|
||||
@ -458,7 +454,7 @@ static CURLcode cf_osslq_h3conn_add_stream(struct cf_osslq_h3conn *h3,
|
||||
struct cf_osslq_ctx *ctx = cf->ctx;
|
||||
curl_int64_t stream_id = (curl_int64_t)SSL_get_stream_id(stream_ssl);
|
||||
|
||||
if(h3->remote_ctrl_n >= ARRAYSIZE(h3->remote_ctrl)) {
|
||||
if(h3->remote_ctrl_n >= CURL_ARRAYSIZE(h3->remote_ctrl)) {
|
||||
/* rejected, we are full */
|
||||
CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] rejecting remote stream",
|
||||
stream_id);
|
||||
@ -1564,7 +1560,7 @@ static CURLcode h3_send_streams(struct Curl_cfilter *cf,
|
||||
bool blocked = FALSE, eos_written = FALSE;
|
||||
|
||||
n = nghttp3_conn_writev_stream(ctx->h3.conn, &stream_id, &eos,
|
||||
vec, ARRAYSIZE(vec));
|
||||
vec, CURL_ARRAYSIZE(vec));
|
||||
if(n < 0) {
|
||||
failf(data, "nghttp3_conn_writev_stream returned error: %s",
|
||||
nghttp3_strerror((int)n));
|
||||
|
||||
@ -58,10 +58,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
#if defined(USE_WOLFSSL)
|
||||
|
||||
#define QUIC_CIPHERS \
|
||||
|
||||
@ -63,10 +63,6 @@
|
||||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
#define QUIC_PRIORITY \
|
||||
"NORMAL:-VERS-ALL:+VERS-TLS1.3:-CIPHER-ALL:+AES-128-GCM:+AES-256-GCM:" \
|
||||
"+CHACHA20-POLY1305:+AES-128-CCM:-GROUP-ALL:+GROUP-SECP256R1:" \
|
||||
@ -1223,7 +1219,7 @@ CURLcode Curl_gtls_ctx_init(struct gtls_ctx *gctx,
|
||||
size_t i, alen = alpn_len;
|
||||
unsigned char *salpn = (unsigned char *)alpn;
|
||||
unsigned char slen;
|
||||
for(i = 0; (i < ARRAYSIZE(gtls_alpns)) && alen; ++i) {
|
||||
for(i = 0; (i < CURL_ARRAYSIZE(gtls_alpns)) && alen; ++i) {
|
||||
slen = salpn[0];
|
||||
if(slen >= alen)
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
@ -116,10 +116,6 @@
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
/* Uncomment the ALLOW_RENEG line to a real #define if you want to allow TLS
|
||||
renegotiations when built with BoringSSL. Renegotiating is non-compliant
|
||||
with HTTP/2 and "an extremely dangerous protocol feature". Beware.
|
||||
@ -3359,7 +3355,7 @@ static CURLcode ossl_populate_x509_store(struct Curl_cfilter *cf,
|
||||
"CA" /* Intermediate Certification Authorities */
|
||||
};
|
||||
size_t i;
|
||||
for(i = 0; i < ARRAYSIZE(storeNames); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(storeNames); ++i) {
|
||||
bool imported = FALSE;
|
||||
result = import_windows_cert_store(data, storeNames[i], store,
|
||||
&imported);
|
||||
|
||||
@ -36,10 +36,6 @@
|
||||
|
||||
#include "memdebug.h" /* keep this as LAST include */
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
struct category_descriptors {
|
||||
const char *opt;
|
||||
const char *desc;
|
||||
@ -113,7 +109,7 @@ static void print_category(unsigned int category, unsigned int cols)
|
||||
static int get_category_content(const char *category, unsigned int cols)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < ARRAYSIZE(categories); ++i)
|
||||
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i)
|
||||
if(curl_strequal(categories[i].opt, category)) {
|
||||
printf("%s: %s\n", categories[i].opt, categories[i].desc);
|
||||
print_category(categories[i].category, cols);
|
||||
@ -126,7 +122,7 @@ static int get_category_content(const char *category, unsigned int cols)
|
||||
static void get_categories(void)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < ARRAYSIZE(categories); ++i)
|
||||
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i)
|
||||
printf(" %-11s %s\n", categories[i].opt, categories[i].desc);
|
||||
}
|
||||
|
||||
@ -135,9 +131,9 @@ static void get_categories_list(unsigned int width)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t col = 0;
|
||||
for(i = 0; i < ARRAYSIZE(categories); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(categories); ++i) {
|
||||
size_t len = strlen(categories[i].opt);
|
||||
if(i == ARRAYSIZE(categories) - 1) {
|
||||
if(i == CURL_ARRAYSIZE(categories) - 1) {
|
||||
/* final category */
|
||||
if(col + len + 1 < width)
|
||||
printf("%s.\n", categories[i].opt);
|
||||
|
||||
@ -38,10 +38,6 @@ static void unit_stop(void)
|
||||
#if defined(USE_GNUTLS) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \
|
||||
defined(USE_MBEDTLS)
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
struct test_spec {
|
||||
const char *input;
|
||||
const char *exp_output;
|
||||
@ -111,7 +107,7 @@ UNITTEST_START
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
}
|
||||
|
||||
for(i = 0; i < ARRAYSIZE(test_specs); ++i) {
|
||||
for(i = 0; i < CURL_ARRAYSIZE(test_specs); ++i) {
|
||||
if(!do_test(&test_specs[i], i, &dbuf))
|
||||
all_ok = FALSE;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user