From 1ba28e2b955b005ce4825fec792df17f75a8de1e Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Tue, 22 Mar 2011 05:36:24 -0400 Subject: [PATCH] Compiler masochism compliance. Be able to build most of Exim with: -Werror -Wwrite-strings -Wunused-function -Waddress -Wpointer-sign -Wformat -Wuninitialized -Winit-self Skipped a change to auth-spa which I was uncertain of. That is not the most readable of code. Temporarily gave up on src/src/pdkim/pdkim.c, as header_name_match() treats the second param as const or not depending on the third param. (I hacked the build-*/pdkim/Makefile to continue past this) Much of this change is const propagation. --- src/src/buildconfig.c | 15 +++++------ src/src/debug.c | 4 +-- src/src/directory.c | 8 +++--- src/src/drtables.c | 2 +- src/src/exim.c | 22 ++++++++------- src/src/exim_dbmbuild.c | 2 +- src/src/exim_lock.c | 3 ++- src/src/expand.c | 12 ++++----- src/src/filter.c | 16 +++++------ src/src/functions.h | 30 ++++++++++----------- src/src/globals.c | 4 +-- src/src/globals.h | 4 +-- src/src/header.c | 13 ++++----- src/src/local_scan.h | 26 +++++++++--------- src/src/log.c | 2 +- src/src/lookups/dnsdb.c | 2 +- src/src/lookups/lf_check_file.c | 2 +- src/src/lookups/lf_functions.h | 4 +-- src/src/malware.c | 8 +++--- src/src/mime.c | 4 +-- src/src/moan.c | 6 ++--- src/src/os.c | 8 +++--- src/src/osfunctions.h | 10 +++---- src/src/pdkim/bignum.c | 2 +- src/src/pdkim/bignum.h | 2 +- src/src/pdkim/pdkim.c | 48 ++++++++++++++++----------------- src/src/rewrite.c | 26 +++++++++--------- src/src/smtp_in.c | 6 ++--- src/src/smtp_out.c | 2 +- src/src/string.c | 18 ++++++------- src/src/transport.c | 2 +- src/src/transports/appendfile.c | 2 +- src/src/transports/lmtp.c | 2 +- src/src/transports/tf_maildir.c | 8 +++--- src/src/verify.c | 2 +- 35 files changed, 167 insertions(+), 160 deletions(-) diff --git a/src/src/buildconfig.c b/src/src/buildconfig.c index 49d8c411a..c012fb7d4 100644 --- a/src/src/buildconfig.c +++ b/src/src/buildconfig.c @@ -42,16 +42,16 @@ normally called independently. */ #include typedef struct { - char *name; + const char *name; int *flag; } have_item; typedef struct { - char *name; + const char *name; char *data; } save_item; -static char *db_opts[] = { "", "USE_DB", "USE_GDBM", "USE_TDB" }; +static const char *db_opts[] = { "", "USE_DB", "USE_GDBM", "USE_TDB" }; static int have_ipv6 = 0; static int have_iconv = 0; @@ -557,9 +557,9 @@ while (fgets(buffer, sizeof(buffer), base) != NULL) int isgroup = name[10] == 'G'; uid_t uid = 0; gid_t gid = 0; - char *s; - char *username = NULL; - char *user = getenv(name); + const char *s; + const char *username = NULL; + const char *user = getenv(name); if (user == NULL) user = ""; while (isspace((unsigned char)(*user))) user++; @@ -600,8 +600,7 @@ while (fgets(buffer, sizeof(buffer), base) != NULL) while (isspace(*user)) user++; username = user; } - - else if (isgroup) +else if (isgroup) { struct group *gr = getgrnam(user); if (gr == NULL) diff --git a/src/src/debug.c b/src/src/debug.c index 71e8c420d..4b08f654c 100644 --- a/src/src/debug.c +++ b/src/src/debug.c @@ -148,7 +148,7 @@ get interleaved. Since some calls to debug_printf() don't end with newline, we save up the text until we do get the newline. */ void -debug_printf(char *format, ...) +debug_printf(const char *format, ...) { va_list ap; va_start(ap, format); @@ -157,7 +157,7 @@ va_end(ap); } void -debug_vprintf(char *format, va_list ap) +debug_vprintf(const char *format, va_list ap) { if (debug_file == NULL) return; diff --git a/src/src/directory.c b/src/src/directory.c index 7aa137c8a..d6cac2cb8 100644 --- a/src/src/directory.c +++ b/src/src/directory.c @@ -36,10 +36,12 @@ Returns: panic on failure if panic is set; otherwise return FALSE; */ BOOL -directory_make(uschar *parent, uschar *name, int mode, BOOL panic) +directory_make(const uschar *parent, const uschar *name, + int mode, BOOL panic) { BOOL use_chown = parent == spool_directory && geteuid() == root_uid; -uschar *p, *slash; +uschar *p; +const uschar *slash; int c = 1; struct stat statbuf; uschar buffer[256]; @@ -47,7 +49,7 @@ uschar buffer[256]; if (parent == NULL) { p = buffer + 1; - slash = parent = US""; + slash = parent = CUS""; } else { diff --git a/src/src/drtables.c b/src/src/drtables.c index 183edf321..85b6efb2f 100644 --- a/src/src/drtables.c +++ b/src/src/drtables.c @@ -544,7 +544,7 @@ void init_lookup_list(void) int pathnamelen = len + (int)strlen(LOOKUP_MODULE_DIR) + 2; void *dl; struct lookup_module_info *info; - char *errormsg; + const char *errormsg; /* SRH: am I being paranoid here or what? */ if (pathnamelen > big_buffer_size) { diff --git a/src/src/exim.c b/src/src/exim.c index c368e5906..f086a00e8 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -360,7 +360,7 @@ Returns: nothing */ void -set_process_info(char *format, ...) +set_process_info(const char *format, ...) { int len; va_list ap; @@ -397,7 +397,7 @@ Returns: the fopened FILE or NULL */ FILE * -modefopen(uschar *filename, char *options, mode_t mode) +modefopen(const uschar *filename, const char *options, mode_t mode) { mode_t saved_umask = umask(0777); FILE *f = Ufopen(filename, options); @@ -1038,8 +1038,8 @@ Returns: the dlopen handle or NULL on failure */ static void * -set_readline(char * (**fn_readline_ptr)(char *), - char * (**fn_addhist_ptr)(char *)) +set_readline(char * (**fn_readline_ptr)(const char *), + void (**fn_addhist_ptr)(const char *)) { void *dlhandle; void *dlhandle_curses = dlopen("libcurses.so", RTLD_GLOBAL|RTLD_LAZY); @@ -1049,8 +1049,12 @@ if (dlhandle_curses != NULL) dlclose(dlhandle_curses); if (dlhandle != NULL) { - *fn_readline_ptr = (char *(*)(char*))dlsym(dlhandle, "readline"); - *fn_addhist_ptr = (char *(*)(char*))dlsym(dlhandle, "add_history"); + /* Checked manual pages; at least in GNU Readline 6.1, the prototypes are: + * char * readline (const char *prompt); + * void add_history (const char *string); + */ + *fn_readline_ptr = (char *(*)(const char*))dlsym(dlhandle, "readline"); + *fn_addhist_ptr = (void(*)(const char*))dlsym(dlhandle, "add_history"); } else { @@ -1080,7 +1084,7 @@ Returns: pointer to dynamic memory, or NULL at end of file */ static uschar * -get_stdinput(char *(*fn_readline)(char *), char *(*fn_addhist)(char *)) +get_stdinput(char *(*fn_readline)(const char *), void(*fn_addhist)(const char *)) { int i; int size = 0; @@ -4555,8 +4559,8 @@ if (expansion_test) else { - char *(*fn_readline)(char *) = NULL; - char *(*fn_addhist)(char *) = NULL; + char *(*fn_readline)(const char *) = NULL; + void (*fn_addhist)(const char *) = NULL; #ifdef USE_READLINE void *dlhandle = set_readline(&fn_readline, &fn_addhist); diff --git a/src/src/exim_dbmbuild.c b/src/src/exim_dbmbuild.c index 4ff724cdc..386c9b4a4 100644 --- a/src/src/exim_dbmbuild.c +++ b/src/src/exim_dbmbuild.c @@ -39,7 +39,7 @@ characters. */ /* This is global because it's defined in the headers and compilers grumble if it is made static. */ -uschar *hex_digits = US"0123456789abcdef"; +const uschar *hex_digits = CUS"0123456789abcdef"; #ifdef STRERROR_FROM_ERRLIST diff --git a/src/src/exim_lock.c b/src/src/exim_lock.c index 0c60ce107..f783a2bcf 100644 --- a/src/src/exim_lock.c +++ b/src/src/exim_lock.c @@ -183,7 +183,8 @@ BOOL quiet = FALSE; BOOL restore_times = FALSE; char *filename; char *lockname = NULL, *hitchname = NULL; -char *primary_hostname, *command; +char *primary_hostname; +const char *command; struct utsname s; char buffer[256]; char tempname[256]; diff --git a/src/src/expand.c b/src/src/expand.c index 1fd4335da..bf425ae81 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -328,9 +328,9 @@ enum { /* Type for main variable table */ typedef struct { - char *name; - int type; - void *value; + const char *name; + int type; + void *value; } var_entry; /* Type for entries pointing to address/length pairs. Not currently @@ -632,9 +632,9 @@ static BOOL malformed_header; /* For textual hashes */ -static char *hashcodes = "abcdefghijklmnopqrtsuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; +static const char *hashcodes = "abcdefghijklmnopqrtsuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"; enum { HMAC_MD5, HMAC_SHA1 }; diff --git a/src/src/filter.c b/src/src/filter.c index b1fcd40b0..fd2f7ced1 100644 --- a/src/src/filter.c +++ b/src/src/filter.c @@ -76,8 +76,8 @@ permitted to include \n followed by white space) first, and then the body text one (it can have \n anywhere). Then the file names and once_repeat, which may not contain \n. */ -static char *mailargs[] = { /* "to" must be first, and */ - "to", /* "cc" and "bcc" must follow */ +static const char *mailargs[] = { /* "to" must be first, and */ + "to", /* "cc" and "bcc" must follow */ "cc", "bcc", "from", @@ -146,14 +146,14 @@ enum { cond_and, cond_or, cond_personal, cond_begins, cond_BEGINS, cond_above, cond_below, cond_errormsg, cond_firsttime, cond_manualthaw, cond_foranyaddress }; -static char *cond_names[] = { +static const char *cond_names[] = { "and", "or", "personal", "begins", "BEGINS", "ends", "ENDS", "is", "IS", "matches", "MATCHES", "contains", "CONTAINS", "delivered", "above", "below", "error_message", "first_delivery", "manually_thawed", "foranyaddress" }; -static char *cond_not_names[] = { +static const char *cond_not_names[] = { "", "", "not personal", "does not begin", "does not BEGIN", "does not end", "does not END", @@ -165,7 +165,7 @@ static char *cond_not_names[] = { /* Tables of binary condition words and their corresponding types. Not easy to amalgamate with the above because of the different variants. */ -static char *cond_words[] = { +static const char *cond_words[] = { "BEGIN", "BEGINS", "CONTAIN", @@ -203,7 +203,7 @@ enum { add_command, defer_command, deliver_command, elif_command, else_command, mail_command, noerror_command, pipe_command, save_command, seen_command, testprint_command, unseen_command, vacation_command }; -static char *command_list[] = { +static const char *command_list[] = { "add", "defer", "deliver", "elif", "else", "endif", "finish", "fail", "freeze", "headers", "if", "logfile", "logwrite", "mail", "noerror", "pipe", "save", "seen", "testprint", "unseen", "vacation" @@ -777,7 +777,7 @@ Returns: nothing static void print_condition(condition_block *c, BOOL toplevel) { -char *name = (c->testfor)? cond_names[c->type] : cond_not_names[c->type]; +const char *name = (c->testfor)? cond_names[c->type] : cond_not_names[c->type]; switch(c->type) { case cond_personal: @@ -800,7 +800,7 @@ switch(c->type) case cond_ENDS: case cond_above: case cond_below: - debug_printf("%s %s %s", c->left.u, (char *)name, c->right.u); + debug_printf("%s %s %s", c->left.u, name, c->right.u); break; case cond_and: diff --git a/src/src/functions.h b/src/src/functions.h index 24088727a..079e8ad14 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -77,7 +77,7 @@ extern void debug_print_argv(uschar **); extern void debug_print_ids(uschar *); extern void debug_print_string(uschar *); extern void debug_print_tree(tree_node *); -extern void debug_vprintf(char *, va_list); +extern void debug_vprintf(const char *, va_list); extern void decode_bits(unsigned int *, unsigned int *, int, int, uschar *, bit_table *, int, uschar *, int); extern address_item *deliver_make_addr(uschar *, BOOL); @@ -89,7 +89,7 @@ extern void deliver_succeeded(address_item *); #ifdef WITH_OLD_DEMIME extern int demime(uschar **); #endif -extern BOOL directory_make(uschar *, uschar *, int, BOOL); +extern BOOL directory_make(const uschar *, const uschar *, int, BOOL); #ifndef DISABLE_DKIM extern BOOL dkim_transport_write_message(address_item *, int, int, int, uschar *, uschar *, uschar *, uschar *, rewrite_rule *, @@ -121,7 +121,7 @@ extern BOOL filter_personal(string_item *, BOOL); extern BOOL filter_runtest(int, uschar *, BOOL, BOOL); extern BOOL filter_system_interpret(address_item **, uschar **); -extern void header_add(int, char *, ...); +extern void header_add(int, const char *, ...); extern int header_checkname(header_line *, BOOL); extern BOOL header_match(uschar *, BOOL, BOOL, string_item *, int, ...); extern int host_address_extract_port(uschar *); @@ -181,12 +181,12 @@ extern int mime_regex(uschar **); extern uschar *moan_check_errorcopy(uschar *); extern BOOL moan_skipped_syntax_errors(uschar *, error_block *, uschar *, BOOL, uschar *); -extern void moan_smtp_batch(uschar *, char *, ...); -extern void moan_tell_someone(uschar *, address_item *, uschar *, char *, - ...); +extern void moan_smtp_batch(uschar *, const char *, ...); +extern void moan_tell_someone(uschar *, address_item *, + const uschar *, const char *, ...); extern BOOL moan_to_sender(int, error_block *, header_line *, FILE *, BOOL); extern void moan_write_from(FILE *); -extern FILE *modefopen(uschar *, char *, mode_t); +extern FILE *modefopen(const uschar *, const char *, mode_t); extern uschar *parse_extract_address(uschar *, uschar **, int *, int *, int *, BOOL); @@ -271,7 +271,7 @@ extern int search_findtype_partial(uschar *, int *, uschar **, int *, int *); extern void *search_open(uschar *, int, int, uid_t *, gid_t *); extern void search_tidyup(void); -extern void set_process_info(char *, ...); +extern void set_process_info(const char *, ...); extern void sha1_end(sha1 *, const uschar *, int, uschar *); extern void sha1_mid(sha1 *, const uschar *); extern void sha1_start(sha1 *); @@ -299,7 +299,7 @@ extern int smtp_setup_msg(void); extern BOOL smtp_start_session(void); extern int smtp_ungetc(int); extern BOOL smtp_verify_helo(void); -extern int smtp_write_command(smtp_outblock *, BOOL, char *, ...); +extern int smtp_write_command(smtp_outblock *, BOOL, const char *, ...); #ifdef WITH_CONTENT_SCAN extern int spam(uschar **); extern FILE *spool_mbox(unsigned long *, uschar *); @@ -321,18 +321,18 @@ extern uschar *string_copy_malloc(uschar *); extern uschar *string_copylc(uschar *); extern uschar *string_copynlc(uschar *, int); extern uschar *string_dequote(uschar **); -extern BOOL string_format(uschar *, int, char *, ...); +extern BOOL string_format(uschar *, int, const char *, ...); extern uschar *string_format_size(int, uschar *); extern int string_interpret_escape(uschar **); extern int string_is_ip_address(uschar *, int *); extern uschar *string_log_address(address_item *, BOOL, BOOL); extern uschar *string_nextinlist(uschar **, int *, uschar *, int); -extern uschar *string_open_failed(int, char *, ...); +extern uschar *string_open_failed(int, const char *, ...); extern uschar *string_printing2(uschar *, BOOL); extern uschar *string_split_message(uschar *); -extern BOOL string_vformat(uschar *, int, char *, va_list); -extern int strcmpic(uschar *, uschar *); -extern int strncmpic(uschar *, uschar *, int); +extern BOOL string_vformat(uschar *, int, const char *, va_list); +extern int strcmpic(const uschar *, const uschar *); +extern int strncmpic(const uschar *, const uschar *, int); extern uschar *strstric(uschar *, uschar *, BOOL); extern uschar *tod_stamp(int); @@ -346,7 +346,7 @@ extern BOOL transport_set_up_command(uschar ***, uschar *, BOOL, int, address_item *, uschar *, uschar **); extern void transport_update_waiting(host_item *, uschar *); extern BOOL transport_write_block(int, uschar *, int); -extern BOOL transport_write_string(int, char *, ...); +extern BOOL transport_write_string(int, const char *, ...); extern BOOL transport_write_message(address_item *, int, int, int, uschar *, uschar *, uschar *, uschar *, rewrite_rule *, int); extern void tree_add_duplicate(uschar *, address_item *); diff --git a/src/src/globals.c b/src/src/globals.c index fe3a2eeb5..7b5a52554 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -633,7 +633,7 @@ uschar *helo_try_verify_hosts = NULL; BOOL helo_verified = FALSE; BOOL helo_verify_failed = FALSE; uschar *helo_verify_hosts = NULL; -uschar *hex_digits = US"0123456789abcdef"; +const uschar *hex_digits = CUS"0123456789abcdef"; uschar *hold_domains = NULL; BOOL host_checking = FALSE; BOOL host_checking_callout = FALSE; @@ -787,7 +787,7 @@ uschar *message_reference = NULL; /* MIME ACL expandables */ #ifdef WITH_CONTENT_SCAN int mime_anomaly_level = 0; -uschar *mime_anomaly_text = NULL; +const uschar *mime_anomaly_text = NULL; uschar *mime_boundary = NULL; uschar *mime_charset = NULL; uschar *mime_content_description = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index b0c26c425..c1806f070 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -398,7 +398,7 @@ extern uschar *helo_try_verify_hosts; /* Soft check HELO argument for these */ extern BOOL helo_verified; /* True if HELO verified */ extern BOOL helo_verify_failed; /* True if attempt failed */ extern uschar *helo_verify_hosts; /* Hard check HELO argument for these */ -extern uschar *hex_digits; /* Used in several places */ +extern const uschar *hex_digits; /* Used in several places */ extern uschar *hold_domains; /* Hold up deliveries to these */ extern BOOL host_find_failed_syntax;/* DNS syntax check failure */ extern BOOL host_checking_callout; /* TRUE if real callout wanted */ @@ -489,7 +489,7 @@ extern uschar *message_reference; /* Reference for error messages */ /* MIME ACL expandables */ #ifdef WITH_CONTENT_SCAN extern int mime_anomaly_level; -extern uschar *mime_anomaly_text; +extern const uschar *mime_anomaly_text; extern uschar *mime_boundary; extern uschar *mime_charset; extern uschar *mime_content_description; diff --git a/src/src/header.c b/src/src/header.c index 1b6bf56d1..36a48b4e7 100644 --- a/src/src/header.c +++ b/src/src/header.c @@ -30,7 +30,7 @@ Returns: TRUE or FALSE */ BOOL -header_testname(header_line *h, uschar *name, int len, BOOL notdel) +header_testname(header_line *h, const uschar *name, int len, BOOL notdel) { uschar *tt; if (h->type == '*' && notdel) return FALSE; @@ -46,7 +46,8 @@ return *tt == ':'; header_testname() above. */ BOOL -header_testname_incomplete(header_line *h, uschar *name, int len, BOOL notdel) +header_testname_incomplete(header_line *h, const uschar *name, + int len, BOOL notdel) { if (h->type == '*' && notdel) return FALSE; if (h->text == NULL || strncmpic(h->text, name, len) != 0) return FALSE; @@ -92,7 +93,7 @@ Returns: nothing static void header_add_backend(BOOL after, uschar *name, BOOL topnot, int type, - char *format, va_list ap) + const char *format, va_list ap) { header_line *h, *new; header_line **hptr; @@ -213,7 +214,7 @@ Returns: nothing void header_add_at_position(BOOL after, uschar *name, BOOL topnot, int type, - char *format, ...) + const char *format, ...) { va_list ap; va_start(ap, format); @@ -238,7 +239,7 @@ Returns: nothing */ void -header_add(int type, char *format, ...) +header_add(int type, const char *format, ...) { va_list ap; va_start(ap, format); @@ -264,7 +265,7 @@ Returns: nothing */ void -header_remove(int occ, uschar *name) +header_remove(int occ, const uschar *name) { header_line *h; int hcount = 0; diff --git a/src/src/local_scan.h b/src/src/local_scan.h index 1f86c72d3..ffde0e3ab 100644 --- a/src/src/local_scan.h +++ b/src/src/local_scan.h @@ -117,9 +117,9 @@ typedef struct header_line { /* Entries in lists options are in this form. */ typedef struct { - char *name; - int type; - void *value; + const char *name; + int type; + void *value; } optionlist; /*Structure for holding information about an envelope address. The errors_to @@ -168,14 +168,14 @@ extern int child_close(pid_t, int); extern pid_t child_open(uschar **, uschar **, int, int *, int *, BOOL); extern pid_t child_open_exim(int *); extern pid_t child_open_exim2(int *, uschar *, uschar *); -extern void debug_printf(char *, ...) PRINTF_FUNCTION(1,2); +extern void debug_printf(const char *, ...) PRINTF_FUNCTION(1,2); extern uschar *expand_string(uschar *); -extern void header_add(int, char *, ...); -extern void header_add_at_position(BOOL, uschar *, BOOL, int, char *, ...); -extern void header_remove(int, uschar *); -extern BOOL header_testname(header_line *, uschar *, int, BOOL); -extern BOOL header_testname_incomplete(header_line *, uschar *, int, BOOL); -extern void log_write(unsigned int, int, char *format, ...); +extern void header_add(int, const char *, ...); +extern void header_add_at_position(BOOL, uschar *, BOOL, int, const char *, ...); +extern void header_remove(int, const uschar *); +extern BOOL header_testname(header_line *, const uschar *, int, BOOL); +extern BOOL header_testname_incomplete(header_line *, const uschar *, int, BOOL); +extern void log_write(unsigned int, int, const char *format, ...); extern int lss_b64decode(uschar *, uschar **); extern uschar *lss_b64encode(uschar *, int); extern int lss_match_domain(uschar *, uschar *); @@ -186,10 +186,10 @@ extern void receive_add_recipient(uschar *, int); extern BOOL receive_remove_recipient(uschar *); extern uschar *rfc2047_decode(uschar *, BOOL, uschar *, int, int *, uschar **); extern int smtp_fflush(void); -extern void smtp_printf(char *, ...) PRINTF_FUNCTION(1,2); -extern void smtp_vprintf(char *, va_list); +extern void smtp_printf(const char *, ...) PRINTF_FUNCTION(1,2); +extern void smtp_vprintf(const char *, va_list); extern uschar *string_copy(uschar *); extern uschar *string_copyn(uschar *, int); -extern uschar *string_sprintf(char *, ...); +extern uschar *string_sprintf(const char *, ...); /* End of local_scan.h */ diff --git a/src/src/log.c b/src/src/log.c index 0995621ac..a2c1d4416 100644 --- a/src/src/log.c +++ b/src/src/log.c @@ -573,7 +573,7 @@ Returns: nothing */ void -log_write(unsigned int selector, int flags, char *format, ...) +log_write(unsigned int selector, int flags, const char *format, ...) { uschar *ptr; int length, rc; diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c index 5e7c158aa..f3aaf52af 100644 --- a/src/src/lookups/dnsdb.c +++ b/src/src/lookups/dnsdb.c @@ -21,7 +21,7 @@ header files. */ /* Table of recognized DNS record types and their integer values. */ -static char *type_names[] = { +static const char *type_names[] = { "a", #if HAVE_IPV6 "aaaa", diff --git a/src/src/lookups/lf_check_file.c b/src/src/lookups/lf_check_file.c index b1919a20a..1d452599d 100644 --- a/src/src/lookups/lf_check_file.c +++ b/src/src/lookups/lf_check_file.c @@ -41,7 +41,7 @@ Side effect: sets errno to ERRNO_BADUGID, ERRNO_NOTREGULAR or ERRNO_BADMODE for int lf_check_file(int fd, uschar *filename, int s_type, int modemask, uid_t *owners, - gid_t *owngroups, char *type, uschar **errmsg) + gid_t *owngroups, const char *type, uschar **errmsg) { int i; struct stat statbuf; diff --git a/src/src/lookups/lf_functions.h b/src/src/lookups/lf_functions.h index 64cd0970e..9490b81a8 100644 --- a/src/src/lookups/lf_functions.h +++ b/src/src/lookups/lf_functions.h @@ -9,8 +9,8 @@ /* Header for the functions that are shared by the lookups */ -extern int lf_check_file(int, uschar *, int, int, uid_t *, gid_t *, char *, - uschar **); +extern int lf_check_file(int, uschar *, int, int, uid_t *, gid_t *, + const char *, uschar **); extern uschar *lf_quote(uschar *, uschar *, int, uschar *, int *, int *); extern int lf_sqlperform(uschar *, uschar *, uschar *, uschar *, uschar **, uschar **, BOOL *, int(*)(uschar *, uschar *, uschar **, diff --git a/src/src/malware.c b/src/src/malware.c index eb0c33cea..de8d08d19 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -592,7 +592,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) } } else { - char *drweb_s = NULL; + const char *drweb_s = NULL; if (drweb_rc & DERR_READ_ERR) drweb_s = "read error"; if (drweb_rc & DERR_NOMEMORY) drweb_s = "no memory"; @@ -1910,14 +1910,14 @@ static int mksd_parse_line (char *line) static int mksd_scan_packed(int sock, uschar *scan_filename) { struct iovec iov[3]; - char *cmd = "MSQ\n"; + const char *cmd = "MSQ\n"; uschar av_buffer[1024]; - iov[0].iov_base = cmd; + iov[0].iov_base = (void *) cmd; iov[0].iov_len = 3; iov[1].iov_base = CS scan_filename; iov[1].iov_len = Ustrlen(scan_filename); - iov[2].iov_base = cmd + 3; + iov[2].iov_base = (void *) cmd + 3; iov[2].iov_len = 1; if (mksd_writev (sock, iov, 3) < 0) diff --git a/src/src/mime.c b/src/src/mime.c index 76783455a..8a3d03394 100644 --- a/src/src/mime.c +++ b/src/src/mime.c @@ -23,9 +23,9 @@ uschar *mime_current_boundary = NULL; give info on detected "problems" in MIME encodings. Those are defined in mime.h. */ -void mime_set_anomaly(int level, char *text) { +void mime_set_anomaly(int level, const char *text) { mime_anomaly_level = level; - mime_anomaly_text = US text; + mime_anomaly_text = CUS text; } diff --git a/src/src/moan.c b/src/src/moan.c index f03eb8db3..ff6c36826 100644 --- a/src/src/moan.c +++ b/src/src/moan.c @@ -437,8 +437,8 @@ Returns: nothing */ void -moan_tell_someone(uschar *who, address_item *addr, uschar *subject, - char *format, ...) +moan_tell_someone(uschar *who, address_item *addr, + const uschar *subject, const char *format, ...) { FILE *f; va_list ap; @@ -505,7 +505,7 @@ Returns: does not return; exits from the program */ void -moan_smtp_batch(uschar *cmd_buffer, char *format, ...) +moan_smtp_batch(uschar *cmd_buffer, const char *format, ...) { va_list ap; int yield = (receive_messagecount > 0)? 1 : 2; diff --git a/src/src/os.c b/src/src/os.c index b8d369307..4fa9324d4 100644 --- a/src/src/os.c +++ b/src/src/os.c @@ -167,8 +167,8 @@ that have nothing. It provides a basic translation for the common standard signal numbers. I've been extra cautious with the ifdef's here. Probably more than is necessary... */ -char * -os_strsignal(int n) +const char * +os_strsignal(const int n) { switch (n) { @@ -284,8 +284,8 @@ switch (n) exit codes into text, but this function is implemented this way so that if any OS does have such a thing, it could be used instead of this build-in one. */ -char * -os_strexit(int n) +const char * +os_strexit(const int n) { switch (n) { diff --git a/src/src/osfunctions.h b/src/src/osfunctions.h index 67f7b0ebd..19b580860 100644 --- a/src/src/osfunctions.h +++ b/src/src/osfunctions.h @@ -14,10 +14,10 @@ that uses a type that isn't defined for them. */ extern ip_address_item *os_common_find_running_interfaces(void); #endif -extern int os_getloadavg(void); -extern void os_restarting_signal(int, void (*)(int)); -extern void os_non_restarting_signal(int, void (*)(int)); -extern char *os_strexit(int); /* char to match os_strsignal */ -extern char *os_strsignal(int); /* char to match strsignal in some OS */ +extern int os_getloadavg(void); +extern void os_restarting_signal(int, void (*)(int)); +extern void os_non_restarting_signal(int, void (*)(int)); +extern const char *os_strexit(int); /* char to match os_strsignal */ +extern const char *os_strsignal(int); /* char to match strsignal in some OS */ /* End of osfunctions.h */ diff --git a/src/src/pdkim/bignum.c b/src/src/pdkim/bignum.c index e4fc92d2c..d7b67a509 100644 --- a/src/src/pdkim/bignum.c +++ b/src/src/pdkim/bignum.c @@ -428,7 +428,7 @@ int mpi_read_file( mpi *X, int radix, FILE *fin ) /* * Write X into an opened file (or stdout if fout == NULL) */ -int mpi_write_file( char *p, mpi *X, int radix, FILE *fout ) +int mpi_write_file( const char *p, mpi *X, int radix, FILE *fout ) { int n, ret; size_t slen; diff --git a/src/src/pdkim/bignum.h b/src/src/pdkim/bignum.h index aaca67ff8..5b355f2fc 100644 --- a/src/src/pdkim/bignum.h +++ b/src/src/pdkim/bignum.h @@ -202,7 +202,7 @@ int mpi_read_file( mpi *X, int radix, FILE *fin ); * * \note Set fout == NULL to print X on the console. */ -int mpi_write_file( char *p, mpi *X, int radix, FILE *fout ); +int mpi_write_file( const char *p, mpi *X, int radix, FILE *fout ); /** * \brief Import X from unsigned binary data, big endian diff --git a/src/src/pdkim/pdkim.c b/src/src/pdkim/pdkim.c index 0147f5f05..b0430ea45 100644 --- a/src/src/pdkim/pdkim.c +++ b/src/src/pdkim/pdkim.c @@ -65,32 +65,32 @@ struct pdkim_str { /* -------------------------------------------------------------------------- */ /* A bunch of list constants */ -char *pdkim_querymethods[] = { +const char *pdkim_querymethods[] = { "dns/txt", NULL }; -char *pdkim_algos[] = { +const char *pdkim_algos[] = { "rsa-sha256", "rsa-sha1", NULL }; -char *pdkim_canons[] = { +const char *pdkim_canons[] = { "simple", "relaxed", NULL }; -char *pdkim_hashes[] = { +const char *pdkim_hashes[] = { "sha256", "sha1", NULL }; -char *pdkim_keytypes[] = { +const char *pdkim_keytypes[] = { "rsa", NULL }; typedef struct pdkim_combined_canon_entry { - char *str; + const char *str; int canon_headers; int canon_body; } pdkim_combined_canon_entry; @@ -105,7 +105,7 @@ pdkim_combined_canon_entry pdkim_combined_canons[] = { }; -char *pdkim_verify_status_str(int status) { +const char *pdkim_verify_status_str(int status) { switch(status) { case PDKIM_VERIFY_NONE: return "PDKIM_VERIFY_NONE"; case PDKIM_VERIFY_INVALID: return "PDKIM_VERIFY_INVALID"; @@ -114,7 +114,7 @@ char *pdkim_verify_status_str(int status) { default: return "PDKIM_VERIFY_UNKNOWN"; } } -char *pdkim_verify_ext_status_str(int ext_status) { +const char *pdkim_verify_ext_status_str(int ext_status) { switch(ext_status) { case PDKIM_VERIFY_FAIL_BODY: return "PDKIM_VERIFY_FAIL_BODY"; case PDKIM_VERIFY_FAIL_MESSAGE: return "PDKIM_VERIFY_FAIL_MESSAGE"; @@ -129,12 +129,12 @@ char *pdkim_verify_ext_status_str(int ext_status) { /* -------------------------------------------------------------------------- */ /* Print debugging functions */ #ifdef PDKIM_DEBUG -void pdkim_quoteprint(FILE *stream, char *data, int len, int lf) { +void pdkim_quoteprint(FILE *stream, const char *data, int len, int lf) { int i; - unsigned char *p = (unsigned char *)data; + const unsigned char *p = (const unsigned char *)data; for (i=0;istr[p->len] = '\0'; return p; } -char *pdkim_strncat(pdkim_str *str, char *data, int len) { +char *pdkim_strncat(pdkim_str *str, const char *data, int len) { if ((str->allocated - str->len) < (len+1)) { /* Extend the buffer */ int num_frags = ((len+1)/PDKIM_STR_ALLOC_FRAG)+1; @@ -229,7 +229,7 @@ char *pdkim_strncat(pdkim_str *str, char *data, int len) { str->str[str->len] = '\0'; return str->str; } -char *pdkim_strcat(pdkim_str *str, char *cstr) { +char *pdkim_strcat(pdkim_str *str, const char *cstr) { return pdkim_strncat(str, cstr, strlen(cstr)); } char *pdkim_numcat(pdkim_str *str, unsigned long num) { @@ -328,9 +328,9 @@ DLLEXPORT void pdkim_free_ctx(pdkim_ctx *ctx) { the passed colon-separated "list", starting at entry "start". Returns the position of the header name in the list. */ -int header_name_match(char *header, - char *tick, - int do_tick) { +int header_name_match(const char *header, + char *tick, + int do_tick) { char *hname; char *lcopy; char *p; @@ -865,7 +865,7 @@ pdkim_pubkey *pdkim_parse_pubkey_record(pdkim_ctx *ctx, char *raw_record) { /* -------------------------------------------------------------------------- */ -int pdkim_update_bodyhash(pdkim_ctx *ctx, char *data, int len) { +int pdkim_update_bodyhash(pdkim_ctx *ctx, const char *data, int len) { pdkim_signature *sig = ctx->sig; /* Cache relaxed version of data */ char *relaxed_data = NULL; @@ -874,14 +874,14 @@ int pdkim_update_bodyhash(pdkim_ctx *ctx, char *data, int len) { /* Traverse all signatures, updating their hashes. */ while (sig != NULL) { /* Defaults to simple canon (no further treatment necessary) */ - char *canon_data = data; - int canon_len = len; + const char *canon_data = data; + int canon_len = len; if (sig->canon_body == PDKIM_CANON_RELAXED) { /* Relax the line if not done already */ if (relaxed_data == NULL) { int seen_wsp = 0; - char *p = data; + const char *p = data; int q = 0; relaxed_data = malloc(len+1); if (relaxed_data == NULL) return PDKIM_ERR_OOM; diff --git a/src/src/rewrite.c b/src/src/rewrite.c index 8a640565e..e6face16a 100644 --- a/src/src/rewrite.c +++ b/src/src/rewrite.c @@ -14,7 +14,7 @@ /* Names for testing rewriting */ -static char *rrname[] = { +static const char *rrname[] = { " sender", " from", " to", @@ -29,20 +29,20 @@ static char *rrname[] = { typedef struct where_list_block { int bit; - uschar *string; + const uschar *string; } where_list_block; static where_list_block where_list[] = { - { rewrite_sender, US"sender:" }, - { rewrite_from, US"from:" }, - { rewrite_to, US"to:" }, - { rewrite_cc, US"cc:" }, - { rewrite_bcc, US"bcc:" }, - { rewrite_replyto, US"reply-to:" }, - { rewrite_envfrom, US"env-from" }, - { rewrite_envto, US"env-to" }, - { rewrite_smtp, US"smtp recipient" }, - { rewrite_smtp|rewrite_smtp_sender, US"smtp sender" } + { rewrite_sender, CUS"sender:" }, + { rewrite_from, CUS"from:" }, + { rewrite_to, CUS"to:" }, + { rewrite_cc, CUS"cc:" }, + { rewrite_bcc, CUS"bcc:" }, + { rewrite_replyto, CUS"reply-to:" }, + { rewrite_envfrom, CUS"env-from" }, + { rewrite_envto, CUS"env-to" }, + { rewrite_smtp, CUS"smtp recipient" }, + { rewrite_smtp|rewrite_smtp_sender, CUS"smtp sender" } }; static int where_list_size = sizeof(where_list)/sizeof(where_list_block); @@ -252,7 +252,7 @@ for (rule = rewrite_rules; (debug_selector & D_rewrite) != 0) { int i; - uschar *where = US"?"; + const uschar *where = CUS"?"; for (i = 0; i < where_list_size; i++) { diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 0fcedc821..2ef697702 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -49,7 +49,7 @@ the data can be quite long. */ /* Structure for SMTP command list */ typedef struct { - char *name; + const char *name; int len; short int cmd; short int has_arg; @@ -376,7 +376,7 @@ Returns: nothing */ void -smtp_printf(char *format, ...) +smtp_printf(const char *format, ...) { va_list ap; @@ -390,7 +390,7 @@ smtp_printf(), bearing in mind that in C a vararg function can't directly call another vararg function, only a function which accepts a va_list. */ void -smtp_vprintf(char *format, va_list ap) +smtp_vprintf(const char *format, va_list ap) { BOOL yield; diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c index 484735032..da1d32215 100644 --- a/src/src/smtp_out.c +++ b/src/src/smtp_out.c @@ -318,7 +318,7 @@ Returns: 0 if command added to pipelining buffer, with nothing transmitted */ int -smtp_write_command(smtp_outblock *outblock, BOOL noflush, char *format, ...) +smtp_write_command(smtp_outblock *outblock, BOOL noflush, const char *format, ...) { int count; int rc = 0; diff --git a/src/src/string.c b/src/src/string.c index 49ffc9685..d501453c7 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -641,7 +641,7 @@ Returns: pointer to fresh piece of store containing sprintf'ed string */ uschar * -string_sprintf(char *format, ...) +string_sprintf(const char *format, ...) { va_list ap; uschar buffer[STRING_SPRINTF_BUFFER_SIZE]; @@ -669,7 +669,7 @@ Returns: < 0, = 0, or > 0, according to the comparison */ int -strncmpic(uschar *s, uschar *t, int n) +strncmpic(const uschar *s, const uschar *t, int n) { while (n--) { @@ -693,7 +693,7 @@ Returns: < 0, = 0, or > 0, according to the comparison */ int -strcmpic(uschar *s, uschar *t) +strcmpic(const uschar *s, const uschar *t) { while (*s != 0) { @@ -1052,7 +1052,7 @@ Returns: TRUE if the result fitted in the buffer */ BOOL -string_format(uschar *buffer, int buflen, char *format, ...) +string_format(uschar *buffer, int buflen, const char *format, ...) { BOOL yield; va_list ap; @@ -1064,13 +1064,13 @@ return yield; BOOL -string_vformat(uschar *buffer, int buflen, char *format, va_list ap) +string_vformat(uschar *buffer, int buflen, const char *format, va_list ap) { enum { L_NORMAL, L_SHORT, L_LONG, L_LONGLONG, L_LONGDOUBLE }; BOOL yield = TRUE; int width, precision; -char *fp = format; /* Deliberately not unsigned */ +const char *fp = format; /* Deliberately not unsigned */ uschar *p = buffer; uschar *last = buffer + buflen - 1; @@ -1085,8 +1085,8 @@ while (*fp != 0) int length = L_NORMAL; int *nptr; int slen; - char *null = "NULL"; /* ) These variables */ - char *item_start, *s; /* ) are deliberately */ + const char *null = "NULL"; /* ) These variables */ + const char *item_start, *s; /* ) are deliberately */ char newformat[16]; /* ) not unsigned */ /* Non-% characters just get copied verbatim */ @@ -1340,7 +1340,7 @@ Returns: a message, in dynamic store */ uschar * -string_open_failed(int eno, char *format, ...) +string_open_failed(int eno, const char *format, ...) { va_list ap; uschar buffer[1024]; diff --git a/src/src/transport.c b/src/src/transport.c index 504ef9e06..1bf7ee5e0 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -324,7 +324,7 @@ Returns: the yield of transport_write_block() */ BOOL -transport_write_string(int fd, char *format, ...) +transport_write_string(int fd, const char *format, ...) { va_list ap; va_start(ap, format); diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index 39dd4f8f0..a399c600e 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -21,7 +21,7 @@ supported only if SUPPORT_MBX is set. */ enum { mbf_unix, mbf_mbx, mbf_smail, mbf_maildir, mbf_mailstore }; -static char *mailbox_formats[] = { +static const char *mailbox_formats[] = { "unix", "mbx", "smail", "maildir", "mailstore" }; diff --git a/src/src/transports/lmtp.c b/src/src/transports/lmtp.c index 433686d06..f4d95fa8c 100644 --- a/src/src/transports/lmtp.c +++ b/src/src/transports/lmtp.c @@ -212,7 +212,7 @@ Returns: TRUE if successful, FALSE if not, with errno set */ static BOOL -lmtp_write_command(int fd, char *format, ...) +lmtp_write_command(int fd, const char *format, ...) { int count, rc; va_list ap; diff --git a/src/src/transports/tf_maildir.c b/src/src/transports/tf_maildir.c index 472b0764d..e6c8bef94 100644 --- a/src/src/transports/tf_maildir.c +++ b/src/src/transports/tf_maildir.c @@ -48,7 +48,7 @@ BOOL maildir_ensure_directories(uschar *path, address_item *addr, { int i; struct stat statbuf; -char *subdirs[] = { "/tmp", "/new", "/cur" }; +const char *subdirs[] = { "/tmp", "/new", "/cur" }; DEBUG(D_transport) debug_printf("ensuring maildir directories exist in %s\n", path); @@ -62,16 +62,16 @@ loop so that code can be shared. */ for (i = 0; i < 4; i++) { int j; - uschar *dir, *mdir; + const uschar *dir, *mdir; if (i == 0) { - mdir = US""; + mdir = CUS""; dir = path; } else { - mdir = US subdirs[i-1]; + mdir = CUS subdirs[i-1]; dir = mdir + 1; } diff --git a/src/src/verify.c b/src/src/verify.c index f653b6e0d..a702e92d6 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -885,7 +885,7 @@ Returns: */ static void PRINTF_FUNCTION(2,3) -respond_printf(FILE *f, char *format, ...) +respond_printf(FILE *f, const char *format, ...) { va_list ap; -- 2.30.2