From b84bf19797130ef766e668ea3f26f664c9afb0e8 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Fri, 3 May 2024 18:18:00 +0100 Subject: [PATCH] constify --- src/src/deliver.c | 12 +++++++----- src/src/functions.h | 2 +- src/src/globals.c | 8 ++++---- src/src/globals.h | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/src/deliver.c b/src/src/deliver.c index 0157743a1..43ac7fd41 100644 --- a/src/src/deliver.c +++ b/src/src/deliver.c @@ -859,9 +859,10 @@ Return: string expansion from listener, or NULL */ uschar * -event_raise(uschar * action, const uschar * event, uschar * ev_data, int * errnop) +event_raise(const uschar * action, const uschar * event, const uschar * ev_data, + int * errnop) { -uschar * s; +const uschar * s; if (action) { DEBUG(D_deliver) @@ -872,7 +873,7 @@ if (action) event_name = event; event_data = ev_data; - if (!(s = expand_string(action)) && *expand_string_message) + if (!(s = expand_cstring(action)) && *expand_string_message) log_write(0, LOG_MAIN|LOG_PANIC, "failed to expand event_action %s in %s: %s\n", event, transport_name ? transport_name : US"main", expand_string_message); @@ -880,7 +881,8 @@ if (action) event_name = event_data = NULL; /* If the expansion returns anything but an empty string, flag for - the caller to modify his normal processing + the caller to modify his normal processing. Copy the string to + de-const it. */ if (s && *s) { @@ -888,7 +890,7 @@ if (action) debug_printf("Event(%s): event_action returned \"%s\"\n", event, s); if (errnop) *errnop = ERRNO_EVENT; - return s; + return string_copy(s); } } return NULL; diff --git a/src/src/functions.h b/src/src/functions.h index f0b600ccc..9407b44df 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -253,7 +253,7 @@ extern BOOL dscp_lookup(const uschar *, int, int *, int *, int *); extern void enq_end(uschar *); extern BOOL enq_start(uschar *, unsigned); #ifndef DISABLE_EVENT -extern uschar *event_raise(uschar *, const uschar *, uschar *, int *); +extern uschar *event_raise(const uschar *, const uschar *, const uschar *, int *); extern void msg_event_raise(const uschar *, const address_item *); #endif diff --git a/src/src/globals.c b/src/src/globals.c index 2885caa23..4e5fd2991 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -909,10 +909,10 @@ int error_handling = ERRORS_SENDER; uschar *errors_reply_to = NULL; int errors_sender_rc = EXIT_FAILURE; #ifndef DISABLE_EVENT -uschar *event_action = NULL; /* expansion for delivery events */ -uschar *event_data = NULL; /* auxiliary data variable for event */ -int event_defer_errno = 0; -const uschar *event_name = NULL; /* event name variable */ +uschar *event_action = NULL; /* expansion for delivery events */ +const uschar *event_data = NULL; /* auxiliary data variable for event */ +int event_defer_errno = 0; +const uschar *event_name = NULL; /* event name variable */ #endif diff --git a/src/src/globals.h b/src/src/globals.h index 427590050..30c8bbad4 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -602,7 +602,7 @@ extern int errors_sender_rc; /* Return after message to sender*/ #ifndef DISABLE_EVENT extern uschar *event_action; /* expansion for delivery events */ -extern uschar *event_data; /* event data */ +extern const uschar *event_data; /* event data */ extern int event_defer_errno; /* error number set when a remote delivery is deferred with a host error */ extern const uschar *event_name; /* event classification */ #endif -- 2.30.2