From: Jeremy Harris Date: Sat, 11 Jan 2020 20:48:38 +0000 (+0000) Subject: tidying: CCSS macro X-Git-Url: https://git.exim.org/users/jgh/exim.git/commitdiff_plain/3d2e82c5729148f3f88fbb7de7e6dcbc20d0c867?ds=sidebyside;hp=163144aab02a47427340d0ecc75e2abde675f4c9 tidying: CCSS macro --- diff --git a/src/exim_monitor/em_init.c b/src/exim_monitor/em_init.c index c9ef66a7e..b834d9a2b 100644 --- a/src/exim_monitor/em_init.c +++ b/src/exim_monitor/em_init.c @@ -70,9 +70,8 @@ for (i = 0; i <= 1; i++) { int offset; const uschar *error; - stripchart_regex[indx] = pcre_compile(CS buffer, PCRE_COPT, - (const char **)&error, &offset, NULL); - if (stripchart_regex[indx] == NULL) + if (!(stripchart_regex[indx] = pcre_compile(CS buffer, PCRE_COPT, + CCSS &error, &offset, NULL))) { printf("regular expression error: %s at offset %d " "while compiling %s\n", error, offset, buffer); @@ -231,7 +230,7 @@ queue_stripchart_name = (s != NULL)? string_copy(s) : US"queue"; /* Compile the regex for matching yyyy-mm-dd at the start of a string. */ yyyymmdd_regex = pcre_compile("^\\d{4}-\\d\\d-\\d\\d\\s", PCRE_COPT, - (const char **)&error, &erroroffset, NULL); + CCSS &error, &erroroffset, NULL); } /* End of em_init.c */ diff --git a/src/src/auths/call_pwcheck.c b/src/src/auths/call_pwcheck.c index 089f501a7..cf21a18c0 100644 --- a/src/src/auths/call_pwcheck.c +++ b/src/src/auths/call_pwcheck.c @@ -49,7 +49,7 @@ if (pw == NULL) DEBUG(D_auth) debug_printf("Running pwcheck authentication for user \"%s\"\n", s); -switch (pwcheck_verify_password(CS s, CS pw, (const char **)(&reply))) +switch (pwcheck_verify_password(CS s, CS pw, CCSS &reply)) { case PWCHECK_OK: DEBUG(D_auth) debug_printf("pwcheck: success (%s)\n", reply); diff --git a/src/src/auths/cyrus_sasl.c b/src/src/auths/cyrus_sasl.c index 4b4f45b94..37e78989f 100644 --- a/src/src/auths/cyrus_sasl.c +++ b/src/src/auths/cyrus_sasl.c @@ -151,7 +151,7 @@ if ((rc = sasl_server_new(CS ob->server_service, CS expanded_hostname, log_write(0, LOG_PANIC_DIE|LOG_CONFIG_FOR, "%s authenticator: " "couldn't initialise Cyrus SASL server connection.", ablock->name); -if ((rc = sasl_listmech(conn, NULL, "", ":", "", (const char **)&list, &len, &i)) != SASL_OK) +if ((rc = sasl_listmech(conn, NULL, "", ":", "", CCSS &list, &len, &i)) != SASL_OK) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_FOR, "%s authenticator: " "couldn't get Cyrus SASL mechanism list.", ablock->name); @@ -326,8 +326,8 @@ for (rc = SASL_CONTINUE; rc == SASL_CONTINUE; ) { firsttime = 0; HDEBUG(D_auth) debug_printf("Calling sasl_server_start(%s,\"%s\")\n", ob->server_mech, debug); - rc = sasl_server_start(conn, CS ob->server_mech, inlen?CS input:NULL, inlen, - (const char **)(&output), &outlen); + rc = sasl_server_start(conn, CS ob->server_mech, inlen ? CS input : NULL, inlen, + CCSS &output, &outlen); } else { @@ -358,7 +358,7 @@ for (rc = SASL_CONTINUE; rc == SASL_CONTINUE; ) } HDEBUG(D_auth) debug_printf("Calling sasl_server_step(\"%s\")\n", debug); - rc = sasl_server_step(conn, CS input, inlen, (const char **)(&output), &outlen); + rc = sasl_server_step(conn, CS input, inlen, CCSS &output, &outlen); } if (rc == SASL_BADPROT) diff --git a/src/src/exim.c b/src/src/exim.c index 92f5623d2..3be3bf039 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -110,7 +110,7 @@ if (use_malloc) pcre_free = function_store_free; } if (caseless) options |= PCRE_CASELESS; -yield = pcre_compile(CCS pattern, options, (const char **)&error, &offset, NULL); +yield = pcre_compile(CCS pattern, options, CCSS &error, &offset, NULL); pcre_malloc = function_store_get; pcre_free = function_dummy_free; if (yield == NULL) diff --git a/src/src/expand.c b/src/src/expand.c index be6cd6162..cec6efd54 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -2893,7 +2893,7 @@ switch(cond_type = identify_operator(&s, &opname)) break; case ECOND_MATCH: /* Regular expression match */ - if (!(re = pcre_compile(CS sub[1], PCRE_COPT, (const char **)&rerror, + if (!(re = pcre_compile(CS sub[1], PCRE_COPT, CCSS &rerror, &roffset, NULL))) { expand_string_message = string_sprintf("regular expression error in " @@ -5834,7 +5834,7 @@ while (*s != 0) /* Compile the regular expression */ - if (!(re = pcre_compile(CS sub[1], PCRE_COPT, (const char **)&rerror, + if (!(re = pcre_compile(CS sub[1], PCRE_COPT, CCSS &rerror, &roffset, NULL))) { expand_string_message = string_sprintf("regular expression error in " diff --git a/src/src/filter.c b/src/src/filter.c index 3da616700..98b6bc3e8 100644 --- a/src/src/filter.c +++ b/src/src/filter.c @@ -1595,11 +1595,9 @@ switch (c->type) debug_printf_indent(" Pattern = %s\n", exp[1]); } - re = pcre_compile(CS exp[1], + if (!(re = pcre_compile(CS exp[1], PCRE_COPT | ((c->type == cond_matches)? PCRE_CASELESS : 0), - (const char **)®comp_error, ®comp_error_offset, NULL); - - if (re == NULL) + CCSS ®comp_error, ®comp_error_offset, NULL))) { *error_pointer = string_sprintf("error while compiling " "regular expression \"%s\": %s at offset %d", diff --git a/src/src/lookups/redis.c b/src/src/lookups/redis.c index 1b53eed69..53bd8d53d 100644 --- a/src/src/lookups/redis.c +++ b/src/src/lookups/redis.c @@ -227,8 +227,7 @@ if(sdata[1]) /* Run the command. We use the argv form rather than plain as that parses into args by whitespace yet has no escaping mechanism. */ - redis_reply = redisCommandArgv(redis_handle, i, (const char **) argv, NULL); - if (!redis_reply) + if (!(redis_reply = redisCommandArgv(redis_handle, i, CCSS argv, NULL))) { *errmsg = string_sprintf("REDIS: query failed: %s\n", redis_handle->errstr); *defer_break = FALSE; diff --git a/src/src/malware.c b/src/src/malware.c index 481b46acc..ef27daf37 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -302,8 +302,7 @@ const uschar * rerror; int roffset; const pcre * cre; -cre = pcre_compile(CS re, PCRE_COPT, (const char **)&rerror, &roffset, NULL); -if (!cre) +if (!(cre = pcre_compile(CS re, PCRE_COPT, CCSS &rerror, &roffset, NULL))) *errstr= string_sprintf("regular expression error in '%s': %s at offset %d", re, rerror, roffset); return cre; @@ -317,7 +316,7 @@ int i = pcre_exec(cre, NULL, CS text, Ustrlen(text), 0, 0, ovector, nelem(ovector)); uschar * substr = NULL; if (i >= 2) /* Got it */ - pcre_get_substring(CS text, ovector, i, 1, (const char **) &substr); + pcre_get_substring(CS text, ovector, i, 1, CCSS &substr); return substr; } diff --git a/src/src/mytypes.h b/src/src/mytypes.h index fd33168f7..eba3f7e9d 100644 --- a/src/src/mytypes.h +++ b/src/src/mytypes.h @@ -77,6 +77,7 @@ almost always literal strings. */ #define CUS (const unsigned char *) #define USS (unsigned char **) #define CUSS (const unsigned char **) +#define CCSS (const char **) /* The C library string functions expect "char *" arguments. Use macros to avoid having to write a cast each time. We do this for string and file diff --git a/src/src/tls-gnu.c b/src/src/tls-gnu.c index 34ebc0903..028d06219 100644 --- a/src/src/tls-gnu.c +++ b/src/src/tls-gnu.c @@ -1939,7 +1939,7 @@ else const char ** dd; int * ddl; - for(nrec = 0; state->dane_data_len[nrec]; ) nrec++; + for (nrec = 0; state->dane_data_len[nrec]; ) nrec++; nrec++; dd = store_get(nrec * sizeof(uschar *), FALSE); diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index 8f26c71ba..561ee0262 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -2395,9 +2395,8 @@ else { int check_path_len = Ustrlen(check_path); - dir_regex = pcre_compile(CS ob->maildir_dir_regex, PCRE_COPT, - (const char **)&error, &offset, NULL); - if (dir_regex == NULL) + if (!(dir_regex = pcre_compile(CS ob->maildir_dir_regex, PCRE_COPT, + CCSS &error, &offset, NULL))) { addr->message = string_sprintf("appendfile: regular expression " "error: %s at offset %d while compiling %s", error, offset, diff --git a/src/src/transports/tf_maildir.c b/src/src/transports/tf_maildir.c index 611895e06..4d5c0c1a9 100644 --- a/src/src/transports/tf_maildir.c +++ b/src/src/transports/tf_maildir.c @@ -147,10 +147,8 @@ if (maildirfolder_create_regex != NULL) DEBUG(D_transport) debug_printf("checking for maildirfolder requirement\n"); - regex = pcre_compile(CS maildirfolder_create_regex, PCRE_COPT, - (const char **)&error, &offset, NULL); - - if (regex == NULL) + if (!(regex = pcre_compile(CS maildirfolder_create_regex, PCRE_COPT, + CCSS &error, &offset, NULL))) { addr->message = string_sprintf("appendfile: regular expression " "error: %s at offset %d while compiling %s", error, offset,