diff options
Diffstat (limited to 'src/src/lookups')
-rw-r--r-- | src/src/lookups/cdb.c | 16 | ||||
-rw-r--r-- | src/src/lookups/dnsdb.c | 6 | ||||
-rw-r--r-- | src/src/lookups/ibase.c | 16 | ||||
-rw-r--r-- | src/src/lookups/ldap.c | 19 | ||||
-rw-r--r-- | src/src/lookups/lf_check_file.c | 5 | ||||
-rw-r--r-- | src/src/lookups/lf_quote.c | 3 | ||||
-rw-r--r-- | src/src/lookups/mysql.c | 4 | ||||
-rw-r--r-- | src/src/lookups/nisplus.c | 6 | ||||
-rw-r--r-- | src/src/lookups/oracle.c | 8 | ||||
-rw-r--r-- | src/src/lookups/pgsql.c | 10 | ||||
-rw-r--r-- | src/src/lookups/redis.c | 9 | ||||
-rw-r--r-- | src/src/lookups/sqlite.c | 3 |
12 files changed, 40 insertions, 65 deletions
diff --git a/src/src/lookups/cdb.c b/src/src/lookups/cdb.c index 153fcf24f..7c738eb7e 100644 --- a/src/src/lookups/cdb.c +++ b/src/src/lookups/cdb.c @@ -293,7 +293,6 @@ hash_offset_entry, hash_offset, hash_offlen, hash_slotnm; -int loop; /* Keep picky compilers happy */ do_cache = do_cache; @@ -335,7 +334,7 @@ if (cdbp->cdb_map != NULL) uschar * cur_pos = cur_offset + cdbp->cdb_map; uschar * end_pos = end_offset + cdbp->cdb_map; - for (loop = 0; (loop < hash_offlen); ++loop) + for (int loop = 0; (loop < hash_offlen); ++loop) { item_hash = cdb_unpack(cur_pos); cur_pos += 4; @@ -386,7 +385,7 @@ if (cdbp->cdb_map != NULL) #endif /* HAVE_MMAP */ -for (loop = 0; (loop < hash_offlen); ++loop) +for (int loop = 0; (loop < hash_offlen); ++loop) { uschar packbuf[8]; @@ -462,14 +461,15 @@ cdb_close(void *handle) struct cdb_state * cdbp = handle; #ifdef HAVE_MMAP - if (cdbp->cdb_map) { - munmap(CS cdbp->cdb_map, cdbp->filelen); - if (cdbp->cdb_map == cdbp->cdb_offsets) +if (cdbp->cdb_map) + { + munmap(CS cdbp->cdb_map, cdbp->filelen); + if (cdbp->cdb_map == cdbp->cdb_offsets) cdbp->cdb_offsets = NULL; - } + } #endif /* HAVE_MMAP */ - (void)close(cdbp->fileno); +(void)close(cdbp->fileno); } diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c index e75bd1edd..aea2eba72 100644 --- a/src/src/lookups/dnsdb.c +++ b/src/src/lookups/dnsdb.c @@ -150,7 +150,6 @@ store as possible later, so we preallocate the result here */ gstring * yield = string_get(256); -dns_record * rr; dns_answer dnsa; dns_scan dnss; @@ -378,7 +377,7 @@ while ((domain = string_nextinlist(&keystring, &sep, NULL, 0))) /* Search the returned records */ - for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); rr; + for (dns_record * rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); rr; rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT)) if (rr->type == searchtype) { if (*do_cache > rr->ttl) @@ -386,8 +385,7 @@ while ((domain = string_nextinlist(&keystring, &sep, NULL, 0))) if (type == T_A || type == T_AAAA || type == T_ADDRESSES) { - dns_address *da; - for (da = dns_address_from_rr(&dnsa, rr); da; da = da->next) + for (dns_address * da = dns_address_from_rr(&dnsa, rr); da; da = da->next) { if (yield->ptr) yield = string_catn(yield, outsep, 1); yield = string_cat(yield, da->address); diff --git a/src/src/lookups/ibase.c b/src/src/lookups/ibase.c index e52ca27a0..5ae966611 100644 --- a/src/src/lookups/ibase.c +++ b/src/src/lookups/ibase.c @@ -112,12 +112,12 @@ perform_ibase_search(uschar * query, uschar * server, uschar ** resultptr, isc_stmt_handle stmth = NULL; XSQLDA *out_sqlda; XSQLVAR *var; +int i; char buffer[256]; ISC_STATUS status[20], *statusp = status; gstring * result; -int i; int yield = DEFER; ibase_connection *cn; uschar *server_copy = NULL; @@ -128,7 +128,7 @@ database, user, password. We can write to the string, since it is in a nextinlist temporary buffer. The copy of the string that is used for caching has the password removed. This copy is also used for debugging output. */ -for (i = 2; i > 0; i--) +for (int i = 2; i > 0; i--) { uschar *pp = Ustrrchr(server, '|'); @@ -189,7 +189,7 @@ else if (cn->dbh == NULL || cn->transh == NULL) { - char *dpb, *p; + char *dpb; short dpb_length; static char trans_options[] = { isc_tpb_version3, isc_tpb_read, isc_tpb_read_committed, @@ -201,11 +201,11 @@ if (cn->dbh == NULL || cn->transh == NULL) *dpb++ = isc_dpb_version1; *dpb++ = isc_dpb_user_name; *dpb++ = strlen(sdata[1]); - for (p = sdata[1]; *p;) + for (char * p = sdata[1]; *p;) *dpb++ = *p++; *dpb++ = isc_dpb_password; *dpb++ = strlen(sdata[2]); - for (p = sdata[2]; *p;) + for (char * p = sdata[2]; *p;) *dpb++ = *p++; dpb_length = dpb - buffer; @@ -373,7 +373,7 @@ while (isc_dsql_fetch(status, &stmth, out_sqlda->version, out_sqlda) != 100L) } else - for (i = 0; i < out_sqlda->sqld; i++) + for (int i = 0; i < out_sqlda->sqld; i++) { int len = fetch_field(buffer, sizeof(buffer), &out_sqlda->sqlvar[i]); @@ -388,10 +388,8 @@ while (isc_dsql_fetch(status, &stmth, out_sqlda->version, out_sqlda) != 100L) else if (buffer[0] == 0 || Ustrchr(buffer, ' ') != NULL) { - int j; - result = string_catn(result, US "\"", 1); - for (j = 0; j < len; j++) + for (int j = 0; j < len; j++) { if (buffer[j] == '\"' || buffer[j] == '\\') result = string_cat(result, US "\\", 1); diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c index 63c0edf79..f77318626 100644 --- a/src/src/lookups/ldap.c +++ b/src/src/lookups/ldap.c @@ -143,8 +143,6 @@ LDAP_CONNECTION *lcp; struct timeval timeout; struct timeval *timeoutptr = NULL; -uschar *attr; -uschar **attrp; gstring * data = NULL; uschar *dn = NULL; uschar *host; @@ -245,7 +243,7 @@ if (host) /* Count the attributes; we need this later to tell us how to format results */ -for (attrp = USS ludp->lud_attrs; attrp && *attrp; attrp++) +for (uschar ** attrp = USS ludp->lud_attrs; attrp && *attrp; attrp++) attrs_requested++; /* See if we can find a cached connection to this host. The port is not @@ -730,7 +728,7 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr, &result)) == sequence of name=value pairs, separated by (space), with the value always in quotes. If there are multiple values, they are given within the quotes, comma separated. */ - else for (attr = US ldap_first_attribute(lcp->ld, e, &ber); + else for (uschar * attr = US ldap_first_attribute(lcp->ld, e, &ber); attr; attr = US ldap_next_attribute(lcp->ld, e, ber)) { DEBUG(D_lookup) debug_printf("LDAP attr loop\n"); @@ -776,9 +774,7 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr, &result)) == internal quotes, backslashes, newlines, and must double commas. */ if (attrs_requested != 1) - { - int j; - for (j = 0; j < len; j++) + for (int j = 0; j < len; j++) { if (value[j] == '\n') data = string_catn(data, US"\\n", 2); @@ -791,19 +787,15 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr, &result)) == data = string_catn(data, value+j, 1); } } - } /* For single attributes, just double commas */ else - { - int j; - for (j = 0; j < len; j++) + for (int j = 0; j < len; j++) if (value[j] == ',') data = string_catn(data, US",,", 2); else data = string_catn(data, value+j, 1); - } /* Move on to the next value */ @@ -1205,9 +1197,8 @@ far too complicated. */ if (user != NULL) { - uschar *s; uschar *t = user; - for (s = user; *s != 0; s++) + for (uschar * s = user; *s != 0; s++) { int c, d; if (*s == '%' && isxdigit(c=s[1]) && isxdigit(d=s[2])) diff --git a/src/src/lookups/lf_check_file.c b/src/src/lookups/lf_check_file.c index 43198a817..8b1140876 100644 --- a/src/src/lookups/lf_check_file.c +++ b/src/src/lookups/lf_check_file.c @@ -41,7 +41,6 @@ int lf_check_file(int fd, uschar *filename, int s_type, int modemask, uid_t *owners, gid_t *owngroups, const char *type, uschar **errmsg) { -int i; struct stat statbuf; if ((fd >= 0 && fstat(fd, &statbuf) != 0) || @@ -82,7 +81,7 @@ if ((statbuf.st_mode & modemask) != 0) if (owners != NULL) { BOOL uid_ok = FALSE; - for (i = 1; i <= (int)owners[0]; i++) + for (int i = 1; i <= (int)owners[0]; i++) if (owners[i] == statbuf.st_uid) { uid_ok = TRUE; break; } if (!uid_ok) { @@ -96,7 +95,7 @@ if (owners != NULL) if (owngroups != NULL) { BOOL gid_ok = FALSE; - for (i = 1; i <= (int)owngroups[0]; i++) + for (int i = 1; i <= (int)owngroups[0]; i++) if (owngroups[i] == statbuf.st_gid) { gid_ok = TRUE; break; } if (!gid_ok) { diff --git a/src/src/lookups/lf_quote.c b/src/src/lookups/lf_quote.c index 8916fdc4d..6f4143d9f 100644 --- a/src/src/lookups/lf_quote.c +++ b/src/src/lookups/lf_quote.c @@ -45,9 +45,8 @@ character. */ if (value[0] == 0 || Ustrpbrk(value, " \t\n\r") != NULL || value[0] == '\"') { - int j; result = string_catn(result, US"\"", 1); - for (j = 0; j < vlength; j++) + for (int j = 0; j < vlength; j++) { if (value[j] == '\"' || value[j] == '\\') result = string_catn(result, US"\\", 1); diff --git a/src/src/lookups/mysql.c b/src/src/lookups/mysql.c index 77027fc4b..ba8ecba11 100644 --- a/src/src/lookups/mysql.c +++ b/src/src/lookups/mysql.c @@ -152,7 +152,7 @@ database, user, password. We can write to the string, since it is in a nextinlist temporary buffer. The copy of the string that is used for caching has the password removed. This copy is also used for debugging output. */ -for (i = 3; i > 0; i--) +for (int i = 3; i > 0; i--) { uschar *pp = Ustrrchr(server, '/'); if (pp == NULL) @@ -315,7 +315,7 @@ while ((mysql_row_data = mysql_fetch_row(mysql_result))) result = string_catn(result, US"\n", 1); if (num_fields != 1) - for (i = 0; i < num_fields; i++) + for (int i = 0; i < num_fields; i++) result = lf_quote(US fields[i].name, US mysql_row_data[i], lengths[i], result); diff --git a/src/src/lookups/nisplus.c b/src/src/lookups/nisplus.c index e2115a520..61cc70184 100644 --- a/src/src/lookups/nisplus.c +++ b/src/src/lookups/nisplus.c @@ -45,7 +45,6 @@ static int nisplus_find(void *handle, uschar *filename, const uschar *query, int length, uschar **result, uschar **errmsg, uint *do_cache) { -int i; int error_error = FAIL; const uschar * field_name = NULL; nis_result *nrt = NULL; @@ -138,7 +137,7 @@ was given, look for that field; otherwise concatenate all the fields with their names. */ eo = &(eno->zo_data.objdata_u.en_data); -for (i = 0; i < eo->en_cols.en_cols_len; i++) +for (int i = 0; i < eo->en_cols.en_cols_len; i++) { table_col *tc = ta->ta_cols.ta_cols_val + i; entry_col *ec = eo->en_cols.en_cols_val + i; @@ -164,9 +163,8 @@ for (i = 0; i < eo->en_cols.en_cols_len; i++) if (value[0] == 0 || Ustrchr(value, ' ') != NULL) { - int j; yield = string_catn(yield, US"\"", 1); - for (j = 0; j < len; j++) + for (int j = 0; j < len; j++) { if (value[j] == '\"' || value[j] == '\\') yield = string_catn(yield, US"\\", 1); diff --git a/src/src/lookups/oracle.c b/src/src/lookups/oracle.c index 1b21e6a6c..d57314580 100644 --- a/src/src/lookups/oracle.c +++ b/src/src/lookups/oracle.c @@ -254,7 +254,6 @@ Ora_Describe *desc = NULL; Ora_Define *def = NULL; void *hda = NULL; -int i; int yield = DEFER; unsigned int num_fields = 0; gstring * result = NULL; @@ -267,7 +266,7 @@ database, user, password. We can write to the string, since it is in a nextinlist temporary buffer. The copy of the string that is used for caching has the password removed. This copy is also used for debugging output. */ -for (i = 3; i > 0; i--) +for (int i = 3; i > 0; i--) { uschar *pp = Ustrrchr(server, '/'); if (pp == NULL) @@ -404,7 +403,7 @@ while (cda->rc != NO_DATA_FOUND) /* Loop for each row */ /* Multiple fields - precede by file name, removing {lead,trail}ing WS */ - else for (i = 0; i < num_fields; i++) + else for (int i = 0; i < num_fields; i++) { int slen; uschar *s = US desc[i].buf; @@ -421,9 +420,8 @@ while (cda->rc != NO_DATA_FOUND) /* Loop for each row */ if (desc[i].dbtype != INT_TYPE && desc[i].dbtype != FLOAT_TYPE && (def[i].buf[0] == 0 || strchr(def[i].buf, ' ') != NULL)) { - int j; result = string_catn(result, "\"", 1); - for (j = 0; j < def[i].col_retlen; j++) + for (int j = 0; j < def[i].col_retlen; j++) { if (def[i].buf[j] == '\"' || def[i].buf[j] == '\\') result = string_catn(result, "\\", 1); diff --git a/src/src/lookups/pgsql.c b/src/src/lookups/pgsql.c index 697285ab9..cc12e40d7 100644 --- a/src/src/lookups/pgsql.c +++ b/src/src/lookups/pgsql.c @@ -124,7 +124,6 @@ perform_pgsql_search(const uschar *query, uschar *server, uschar **resultptr, PGconn *pg_conn = NULL; PGresult *pg_result = NULL; -int i; gstring * result = NULL; int yield = DEFER; unsigned int num_fields, num_tuples; @@ -137,7 +136,7 @@ path, database, user, password. We can write to the string, since it is in a nextinlist temporary buffer. The copy of the string that is used for caching has the password removed. This copy is also used for debugging output. */ -for (i = 2; i >= 0; i--) +for (int i = 2; i >= 0; i--) { uschar *pp = Ustrrchr(server, '/'); if (!pp) @@ -320,7 +319,7 @@ num_tuples = PQntuples(pg_result); /* Get the fields and construct the result string. If there is more than one row, we insert '\n' between them. */ -for (i = 0; i < num_tuples; i++) +for (int i = 0; i < num_tuples; i++) { if (result) result = string_catn(result, US"\n", 1); @@ -329,14 +328,11 @@ for (i = 0; i < num_tuples; i++) result = string_catn(result, US PQgetvalue(pg_result, i, 0), PQgetlength(pg_result, i, 0)); else - { - int j; - for (j = 0; j < num_fields; j++) + for (int j = 0; j < num_fields; j++) { uschar *tmp = US PQgetvalue(pg_result, i, j); result = lf_quote(US PQfname(pg_result, j), tmp, Ustrlen(tmp), result); } - } } /* If result is NULL then no data has been found and so we return FAIL. */ diff --git a/src/src/lookups/redis.c b/src/src/lookups/redis.c index a4b672a5e..e84f76675 100644 --- a/src/src/lookups/redis.c +++ b/src/src/lookups/redis.c @@ -92,7 +92,7 @@ We can write to the string, since it is in a nextinlist temporary buffer. This copy is also used for debugging output. */ memset(sdata, 0, sizeof(sdata)) /* Set all to NULL */; -for (i = 2; i > 0; i--) +for (int i = 2; i > 0; i--) { uschar *pp = Ustrrchr(server, '/'); @@ -205,9 +205,8 @@ if(sdata[1]) /* split string on whitespace into argv */ { uschar * argv[32]; - int i; const uschar * s = command; - int siz, ptr; + int siz, ptr, i; uschar c; while (isspace(*s)) s++; @@ -281,7 +280,7 @@ switch (redis_reply->type) /* NOTE: For now support 1 nested array result. If needed a limitless result can be parsed */ - for (i = 0; i < redis_reply->elements; i++) + for (int i = 0; i < redis_reply->elements; i++) { entry = redis_reply->element[i]; @@ -297,7 +296,7 @@ switch (redis_reply->type) result = string_catn(result, US entry->str, entry->len); break; case REDIS_REPLY_ARRAY: - for (j = 0; j < entry->elements; j++) + for (int j = 0; j < entry->elements; j++) { tentry = entry->element[j]; diff --git a/src/src/lookups/sqlite.c b/src/src/lookups/sqlite.c index 1619429e5..4bf616052 100644 --- a/src/src/lookups/sqlite.c +++ b/src/src/lookups/sqlite.c @@ -45,7 +45,6 @@ static int sqlite_callback(void *arg, int argc, char **argv, char **azColName) { gstring * res = *(gstring **)arg; -int i; /* For second and subsequent results, insert \n */ @@ -55,7 +54,7 @@ if (res) if (argc > 1) { /* For multiple fields, include the field name too */ - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { uschar *value = US((argv[i] != NULL)? argv[i]:"<NULL>"); res = lf_quote(US azColName[i], value, Ustrlen(value), res); |