From: Jeremy Harris Date: Tue, 14 Nov 2023 14:08:36 +0000 (+0000) Subject: constification X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/fba5586e6d47f55e024e97681c166e857c4f3d1c constification --- diff --git a/src/src/deliver.c b/src/src/deliver.c index fa624f9de..9d459167e 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -6388,7 +6388,7 @@ Returns: When the global variable mua_wrapper is FALSE: */ int -deliver_message(uschar * id, BOOL forced, BOOL give_up) +deliver_message(const uschar * id, BOOL forced, BOOL give_up) { int i, rc; int final_yield = DELIVER_ATTEMPTED_NORMAL; diff --git a/src/src/exim.c b/src/src/exim.c index 118fe5c7c..3cc2fa2fb 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1537,7 +1537,7 @@ Returns: DOES NOT RETURN */ static void -exim_usage(uschar *progname) +exim_usage(const uschar * progname) { /* Handle specific program invocation variants */ @@ -1744,9 +1744,9 @@ Returns: EXIT_SUCCESS if terminated successfully */ int -main(int argc, char **cargv) +main(int argc, char ** cargv) { -uschar **argv = USS cargv; +const uschar ** argv = CUSS cargv; int arg_receive_timeout = -1; int arg_smtp_receive_timeout = -1; int arg_error_handling = error_handling; @@ -1795,18 +1795,18 @@ BOOL verify_address_mode = FALSE; BOOL verify_as_sender = FALSE; BOOL rcpt_verify_quota = FALSE; BOOL version_printed = FALSE; -uschar *alias_arg = NULL; -uschar *called_as = US""; -uschar *cmdline_syslog_name = NULL; -uschar *start_queue_run_id = NULL; -uschar *stop_queue_run_id = NULL; -uschar *expansion_test_message = NULL; +const uschar *alias_arg = NULL; +const uschar *called_as = US""; +const uschar *cmdline_syslog_name = NULL; +const uschar *start_queue_run_id = NULL; +const uschar *stop_queue_run_id = NULL; +const uschar *expansion_test_message = NULL; const uschar *ftest_domain = NULL; const uschar *ftest_localpart = NULL; const uschar *ftest_prefix = NULL; const uschar *ftest_suffix = NULL; uschar *log_oneline = NULL; -uschar *malware_test_file = NULL; +const uschar *malware_test_file = NULL; uschar *real_sender_address; uschar *originator_home = US"/"; size_t sz; @@ -2152,8 +2152,8 @@ on the second character (the one after '-'), to save some effort. */ for (i = 1; i < argc; i++) { BOOL badarg = FALSE; - uschar * arg = argv[i]; - uschar * argrest; + const uschar * arg = argv[i]; + const uschar * argrest; uschar switchchar; /* An argument not starting with '-' is the start of a recipients list; @@ -2347,7 +2347,7 @@ on the second character (the one after '-'), to save some effort. */ case 'I': if (Ustrlen(argrest) >= 1 && *argrest == ':') { - uschar *p = argrest+1; + const uschar * p = argrest+1; info_flag = CMDINFO_HELP; if (Ustrlen(p)) if (strcmpic(p, CUS"sieve") == 0) @@ -2674,9 +2674,9 @@ on the second character (the one after '-'), to save some effort. */ #else { int ptr = 0; - macro_item *m; + macro_item * m; uschar name[24]; - uschar *s = argrest; + const uschar * s = argrest; opt_D_used = TRUE; while (isspace(*s)) s++; @@ -2833,7 +2833,7 @@ on the second character (the one after '-'), to save some effort. */ *(sender_address = store_get(1, GET_UNTAINTED)) = '\0'; /* Ensure writeable memory */ else { - uschar * temp = argrest + Ustrlen(argrest) - 1; + const uschar * temp = argrest + Ustrlen(argrest) - 1; while (temp >= argrest && isspace(*temp)) temp--; if (temp >= argrest && *temp == '.') f_end_dot = TRUE; allow_domain_literals = TRUE; @@ -3272,7 +3272,7 @@ on the second character (the one after '-'), to save some effort. */ /* -oB: Set a connection message max value for remote deliveries */ case 'B': { - uschar * p = argrest; + const uschar * p = argrest; if (!*p) if (i+1 < argc && isdigit((argv[i+1][0]))) p = argv[++i]; @@ -4432,7 +4432,7 @@ if (bi_option) if (bi_command && *bi_command) { int i = 0; - uschar *argv[3]; + const uschar * argv[3]; argv[i++] = bi_command; /* nonexpanded option so assume untainted */ if (alias_arg) argv[i++] = alias_arg; argv[i++] = NULL; @@ -4761,7 +4761,7 @@ if (rcpt_verify_quota) exim_fail("exim: missing recipient for quota check\n"); else { - verify_quota(argv[recipients_arg]); + verify_quota(US argv[recipients_arg]); /*XXX we lose track of const here */ exim_exit(EXIT_SUCCESS); } @@ -5768,7 +5768,7 @@ for (BOOL more = TRUE; more; ) { int rcount = 0; int count = argc - recipients_arg; - uschar **list = argv + recipients_arg; + const uschar ** list = argv + recipients_arg; /* These options cannot be changed dynamically for non-SMTP messages */ diff --git a/src/src/filtertest.c b/src/src/filtertest.c index 2426f7feb..2af5f87c2 100644 --- a/src/src/filtertest.c +++ b/src/src/filtertest.c @@ -164,7 +164,7 @@ Returns: TRUE if no errors */ BOOL -filter_runtest(int fd, uschar *filename, BOOL is_system, BOOL dot_ended) +filter_runtest(int fd, const uschar * filename, BOOL is_system, BOOL dot_ended) { int rc, filter_type; BOOL yield; diff --git a/src/src/functions.h b/src/src/functions.h index 39119ca09..ba4fd215c 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -218,7 +218,7 @@ extern void delete_pid_file(void); extern void deliver_local(address_item *, BOOL); extern address_item *deliver_make_addr(uschar *, BOOL); extern void delivery_log(int, address_item *, int, uschar *); -extern int deliver_message(uschar *, BOOL, BOOL); +extern int deliver_message(const uschar *, BOOL, BOOL); extern void deliver_msglog(const char *, ...) PRINTF_FUNCTION(1,2); extern void deliver_set_expansions(address_item *); extern int deliver_split_address(address_item *); @@ -284,7 +284,7 @@ extern BOOL fd_ready(int, time_t); extern int filter_interpret(const uschar *, int, address_item **, uschar **); extern BOOL filter_personal(string_item *, BOOL); -extern BOOL filter_runtest(int, uschar *, BOOL, BOOL); +extern BOOL filter_runtest(int, const uschar *, BOOL, BOOL); extern BOOL filter_system_interpret(address_item **, uschar **); extern uschar * fn_hdrs_added(void); @@ -345,7 +345,7 @@ extern uschar *macros_expand(int, int *, BOOL *); extern void mainlog_close(void); #ifdef WITH_CONTENT_SCAN extern int malware(const uschar *, BOOL, int); -extern int malware_in_file(uschar *); +extern int malware_in_file(const uschar *); extern void malware_init(void); extern gstring * malware_show_supported(gstring *); #endif @@ -408,15 +408,15 @@ extern BOOL proxy_protocol_host(void); extern void proxy_protocol_setup(void); #endif -extern BOOL queue_action(uschar *, int, uschar **, int, int); +extern BOOL queue_action(const uschar *, int, const uschar **, int, int); extern void queue_check_only(void); extern unsigned queue_count(void); extern unsigned queue_count_cached(void); -extern void queue_list(int, uschar **, int); +extern void queue_list(int, const uschar **, int); #ifndef DISABLE_QUEUE_RAMP extern void queue_notify_daemon(const uschar * hostname); #endif -extern void queue_run(qrunner *, uschar *, uschar *, BOOL); +extern void queue_run(qrunner *, const uschar *, const uschar *, BOOL); extern int random_number(int); extern const uschar *rc_to_string(int); @@ -430,7 +430,7 @@ extern void readconf_driver_init(uschar *, driver_instance **, extern uschar *readconf_find_option(void *); extern void readconf_main(BOOL); extern void readconf_options_from_list(optionlist *, unsigned, const uschar *, uschar *); -extern BOOL readconf_print(const uschar *, uschar *, BOOL); +extern BOOL readconf_print(const uschar *, const uschar *, BOOL); extern uschar *readconf_printtime(int); extern const uschar *readconf_readname(uschar *, int, const uschar *); extern int readconf_readtime(const uschar *, int, BOOL); @@ -503,7 +503,7 @@ extern int sieve_interpret(const uschar *, int, const uschar *, const uschar *, const uschar *, const uschar *, address_item **, uschar **); extern void sigalrm_handler(int); -extern void single_queue_run(qrunner *, uschar *, uschar *); +extern void single_queue_run(qrunner *, const uschar *, const uschar *); extern int smtp_boundsock(smtp_connect_args *); extern void smtp_closedown(uschar *); extern void smtp_command_timeout_exit(void) NORETURN; @@ -544,12 +544,12 @@ extern int spam(const uschar **); extern FILE *spool_mbox(unsigned long *, const uschar *, uschar **); #endif extern void spool_clear_header_globals(void); -extern BOOL spool_move_message(uschar *, uschar *, uschar *, uschar *); -extern int spool_open_datafile(uschar *); +extern BOOL spool_move_message(const uschar *, const uschar *, const uschar *, const uschar *); +extern int spool_open_datafile(const uschar *); extern int spool_open_temp(uschar *); extern int spool_read_header(uschar *, BOOL, BOOL); extern uschar *spool_sender_from_msgid(const uschar *); -extern int spool_write_header(uschar *, int, uschar **); +extern int spool_write_header(const uschar *, int, uschar **); extern int stdin_getc(unsigned); extern int stdin_feof(void); extern int stdin_ferror(void); @@ -1144,7 +1144,7 @@ return string_sprintf("%s/%s/%s/%s", # endif static inline uschar * -spool_q_sname(const uschar * purpose, const uschar * q, uschar * subdir) +spool_q_sname(const uschar * purpose, const uschar * q, const uschar * subdir) { return string_sprintf("%s%s%s%s%s", q, *q ? "/" : "", @@ -1153,7 +1153,7 @@ return string_sprintf("%s%s%s%s%s", } static inline uschar * -spool_sname(const uschar * purpose, uschar * subdir) +spool_sname(const uschar * purpose, const uschar * subdir) { return spool_q_sname(purpose, queue_name, subdir); } diff --git a/src/src/globals.c b/src/src/globals.c index e94bef75c..46ca72f20 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -726,7 +726,7 @@ gid_t config_gid = CONFIGURE_GROUP; #else gid_t config_gid = 0; #endif -uschar *config_main_filelist = US CONFIGURE_FILE +const uschar * config_main_filelist = US CONFIGURE_FILE "\0<-----------Space to patch configure_filename->"; uschar *config_main_filename = NULL; uschar *config_main_directory = NULL; @@ -939,8 +939,8 @@ uschar *fake_response_text = US"Your message has been rejected but is " int filter_n[FILTER_VARIABLE_COUNT]; int filter_sn[FILTER_VARIABLE_COUNT]; int filter_test = FTEST_NONE; -uschar *filter_test_sfile = NULL; -uschar *filter_test_ufile = NULL; +const uschar * filter_test_sfile = NULL; +const uschar * filter_test_ufile = NULL; uschar *filter_thisaddress = NULL; int finduser_retries = 0; uid_t fixed_never_users[] = { FIXED_NEVER_USERS }; @@ -1185,7 +1185,7 @@ uschar *message_size_limit = US"50M"; int message_utf8_downconvert = 0; /* -1 ifneeded; 0 never; 1 always */ #endif uschar message_subdir[2] = { 0, 0 }; -uschar *message_reference = NULL; +const uschar *message_reference= NULL; /* MIME ACL expandables */ #ifdef WITH_CONTENT_SCAN @@ -1219,7 +1219,7 @@ uschar *originator_login = NULL; uschar *originator_name = NULL; uid_t originator_uid; uschar *override_local_interfaces = NULL; -uschar *override_pid_file_path = NULL; +const uschar *override_pid_file_path = NULL; BOOL panic_coredump = FALSE; pcre2_general_context * pcre_gen_ctx = NULL; @@ -1229,7 +1229,7 @@ pcre2_general_context * pcre_mlc_ctx = NULL; pcre2_compile_context * pcre_mlc_cmp_ctx = NULL; uschar *percent_hack_domains = NULL; -uschar *pid_file_path = US PID_FILE_PATH +const uschar *pid_file_path = US PID_FILE_PATH "\0<--------------Space to patch pid_file_path->"; #ifndef DISABLE_PIPE_CONNECT uschar *pipe_connect_advertise_hosts = US"*"; @@ -1485,7 +1485,7 @@ uschar *sending_ip_address = NULL; int sending_port = -1; SIGNAL_BOOL sigalrm_seen = FALSE; const uschar *sigalarm_setter = NULL; -uschar **sighup_argv = NULL; +const uschar **sighup_argv = NULL; int slow_lookup_log = 0; /* millisecs, zero disables */ int smtp_accept_count = 0; int smtp_accept_max = 20; @@ -1572,7 +1572,7 @@ int string_datestamp_type = -1; const uschar *submission_domain = NULL; const uschar *submission_name = NULL; int syslog_facility = LOG_MAIL; -uschar *syslog_processname = US"exim"; +const uschar *syslog_processname= US"exim"; uschar *system_filter = NULL; uschar *system_filter_directory_transport = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index 6ec4e619d..9ec44487f 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -438,7 +438,7 @@ extern FILE *config_file; /* Configuration file */ extern const uschar *config_filename; /* Configuration file name */ extern gid_t config_gid; /* Additional group owner */ extern int config_lineno; /* Line number */ -extern uschar *config_main_filelist; /* List of possible config files */ +extern const uschar *config_main_filelist; /* List of possible config files */ extern uschar *config_main_filename; /* File name actually used */ extern uschar *config_main_directory; /* Directory where the main config file was found */ extern uid_t config_uid; /* Additional owner */ @@ -625,8 +625,8 @@ extern uschar *fake_response_text; /* User defined message for the above. De extern int filter_n[FILTER_VARIABLE_COUNT]; /* filter variables */ extern int filter_sn[FILTER_VARIABLE_COUNT]; /* variables set by system filter */ extern int filter_test; /* Filter test type */ -extern uschar *filter_test_sfile; /* System filter test file */ -extern uschar *filter_test_ufile; /* User filter test file */ +extern const uschar *filter_test_sfile;/* System filter test file */ +extern const uschar *filter_test_ufile;/* User filter test file */ extern uschar *filter_thisaddress; /* For address looping */ extern int finduser_retries; /* Retry count for getpwnam() */ extern uid_t fixed_never_users[]; /* Can't be overridden */ @@ -755,7 +755,7 @@ extern int message_utf8_downconvert; /* convert from utf8 */ const extern pcre2_code *regex_UTF8; /* For recognizing SMTPUTF8 settings */ #endif extern uschar message_subdir[]; /* Subdirectory for messages */ -extern uschar *message_reference; /* Reference for error messages */ +extern const uschar *message_reference;/* Reference for error messages */ /* MIME ACL expandables */ #ifdef WITH_CONTENT_SCAN @@ -798,7 +798,7 @@ extern uschar *originator_login; /* Login of same */ extern uschar *originator_name; /* Full name of same */ extern uid_t originator_uid; /* Uid of ditto */ extern uschar *override_local_interfaces; /* Value of -oX argument */ -extern uschar *override_pid_file_path; /* Value of -oP argument */ +extern const uschar *override_pid_file_path; /* Value of -oP argument */ extern BOOL panic_coredump; /* SEGV rather than exit, on LOG_PANIC_DIE */ extern pcre2_general_context * pcre_gen_ctx; /* pcre memory management */ @@ -808,7 +808,7 @@ extern pcre2_general_context * pcre_mlc_ctx; extern pcre2_compile_context * pcre_mlc_cmp_ctx; extern uschar *percent_hack_domains; /* Local domains for which '% operates */ -extern uschar *pid_file_path; /* For writing daemon pids */ +extern const uschar *pid_file_path; /* For writing daemon pids */ #ifndef DISABLE_PIPE_CONNECT extern uschar *pipe_connect_advertise_hosts; /* for banner/EHLO pipelining */ #endif @@ -970,7 +970,7 @@ extern uschar *sending_ip_address; /* Address of outgoing (SMTP) interface * extern int sending_port; /* Port of outgoing interface */ extern SIGNAL_BOOL sigalrm_seen; /* Flag for sigalrm_handler */ extern const uschar *sigalarm_setter; /* For debug, set to callpoint of alarm() */ -extern uschar **sighup_argv; /* Args for re-execing after SIGHUP */ +extern const uschar **sighup_argv; /* Args for re-execing after SIGHUP */ extern int slow_lookup_log; /* Log DNS lookups taking longer than N millisecs */ extern int smtp_accept_count; /* Count of connections */ extern BOOL smtp_accept_keepalive; /* Set keepalive on incoming */ @@ -1065,7 +1065,7 @@ extern const uschar *submission_name; /* User name set from ACL */ extern BOOL syslog_duplication; /* FALSE => no duplicate logging */ extern int syslog_facility; /* As defined by Syslog.h */ extern BOOL syslog_pid; /* TRUE if PID on syslogs */ -extern uschar *syslog_processname; /* 'ident' param to openlog() */ +extern const uschar *syslog_processname; /* 'ident' param to openlog() */ extern BOOL syslog_timestamp; /* TRUE if time on syslogs */ extern uschar *system_filter; /* Name of system filter file */ diff --git a/src/src/malware.c b/src/src/malware.c index 9455d4769..760278079 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -2238,7 +2238,7 @@ Returns: Exim message processing code (OK, FAIL, DEFER, ...) where true means malware was found (condition applies) */ int -malware_in_file(uschar *eml_filename) +malware_in_file(const uschar * eml_filename) { uschar message_id_buf[64]; int ret; diff --git a/src/src/queue.c b/src/src/queue.c index fa4fc0aec..cfe87e953 100644 --- a/src/src/queue.c +++ b/src/src/queue.c @@ -354,7 +354,7 @@ Returns: nothing */ void -queue_run(qrunner * q, uschar * start_id, uschar * stop_id, BOOL recurse) +queue_run(qrunner * q, const uschar * start_id, const uschar * stop_id, BOOL recurse) { BOOL force_delivery = q->queue_run_force || deliver_selectstring || deliver_selectstring_sender; @@ -813,7 +813,7 @@ if (!recurse) void -single_queue_run(qrunner * q, uschar * start_id, uschar * stop_id) +single_queue_run(qrunner * q, const uschar * start_id, const uschar * stop_id) { DEBUG(D_queue_run) debug_printf("Single queue run%s%s%s%s\n", start_id ? US" starting at " : US"", @@ -919,7 +919,7 @@ Returns: nothing */ void -queue_list(int option, uschar ** list, int count) +queue_list(int option, const uschar ** list, int count) { int subcount; int now = (int)time(NULL); @@ -1093,7 +1093,7 @@ Returns: FALSE if there was any problem */ BOOL -queue_action(uschar * id, int action, uschar ** argv, int argc, +queue_action(const uschar * id, int action, const uschar ** argv, int argc, int recipients_arg) { BOOL yield = TRUE; diff --git a/src/src/readconf.c b/src/src/readconf.c index e77458d68..bbcca87f7 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -2741,7 +2741,7 @@ Returns: Boolean success */ BOOL -readconf_print(const uschar *name, uschar *type, BOOL no_labels) +readconf_print(const uschar * name, const uschar * type, BOOL no_labels) { BOOL names_only = FALSE; optionlist *ol2 = NULL; @@ -3121,8 +3121,8 @@ readconf_main(BOOL nowarn) { int sep = 0; struct stat statbuf; -uschar *s, *filename; -const uschar *list = config_main_filelist; +uschar * s, * filename; +const uschar * list = config_main_filelist; /* Loop through the possible file names */ @@ -3459,7 +3459,7 @@ leading "log_". */ if (syslog_facility_str) { int i; - uschar *s = syslog_facility_str; + uschar * s = syslog_facility_str; if ((Ustrlen(syslog_facility_str) >= 4) && (strncmpic(syslog_facility_str, US"log_", 4) == 0)) @@ -3481,10 +3481,11 @@ if (syslog_facility_str) if (*pid_file_path) { - if (!(s = expand_string(pid_file_path))) + const uschar * t = expand_cstring(pid_file_path); + if (!t) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to expand pid_file_path " "\"%s\": %s", pid_file_path, expand_string_message); - pid_file_path = s; + pid_file_path = t; } /* Set default value of process_log_path */ diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 737a01cdd..588effd2c 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -36,7 +36,7 @@ Side effect: message_subdir is set for the (possibly split) spool directory */ int -spool_open_datafile(uschar * id) +spool_open_datafile(const uschar * id) { struct stat statbuf; flock_t lock_data; diff --git a/src/src/spool_out.c b/src/src/spool_out.c index 9c5a683e3..f3373faed 100644 --- a/src/src/spool_out.c +++ b/src/src/spool_out.c @@ -152,7 +152,7 @@ Returns: the size of the header texts on success; */ int -spool_write_header(uschar * id, int where, uschar ** errmsg) +spool_write_header(const uschar * id, int where, uschar ** errmsg) { int fd, size_correction; FILE * fp; @@ -444,7 +444,7 @@ start-up time. Arguments: dir base directory name - dq destiinationqueue name + dq destination queue name subdir subdirectory name id message id suffix suffix to add to id @@ -457,8 +457,8 @@ Returns: TRUE if all went well */ static BOOL -make_link(uschar * dir, uschar * dq, uschar * subdir, uschar * id, uschar * suffix, - uschar * from, uschar * to, BOOL noentok) +make_link(const uschar * dir, const uschar * dq, const uschar * subdir, const uschar * id, + const uschar * suffix, const uschar * from, const uschar * to, BOOL noentok) { uschar * fname = spool_fname(string_sprintf("%s%s", from, dir), subdir, id, suffix); uschar * tname = spool_q_fname(string_sprintf("%s%s", to, dir), dq, subdir, id, suffix); @@ -494,8 +494,8 @@ Returns: TRUE if all went well */ static BOOL -break_link(uschar * dir, uschar * subdir, uschar * id, uschar * suffix, uschar * from, - BOOL noentok) +break_link(const uschar * dir, const uschar * subdir, const uschar * id, + const uschar * suffix, const uschar * from, BOOL noentok) { uschar * fname = spool_fname(string_sprintf("%s%s", from, dir), subdir, id, suffix); if (Uunlink(fname) < 0 && (!noentok || errno != ENOENT)) @@ -528,7 +528,8 @@ Returns: TRUE if all is well */ BOOL -spool_move_message(uschar * id, uschar * subdir, uschar * from, uschar * to) +spool_move_message(const uschar * id, const uschar * subdir, + const uschar * from, const uschar * to) { uschar * dest_qname = queue_name_dest ? queue_name_dest : queue_name;