From: Christophe Jaillet Date: Fri, 28 Feb 2020 06:13:50 +0000 (+0000) Subject: Slighly simplify code. X-Git-Tag: 2.5.0-alpha2-ci-test-only~1609 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7c32365ec80346677b14657de8203779a2948b0;p=thirdparty%2Fapache%2Fhttpd.git Slighly simplify code. No need to set to NULL or 0 fields that are apr_pcalloc'ed. Axe 'set_cookie_enable' and use 'ap_set_flag_slot' instead. (based on ideas taken from r1874389) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874602 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/metadata/mod_usertrack.c b/modules/metadata/mod_usertrack.c index 8ddff6624f1..fc022fac97b 100644 --- a/modules/metadata/mod_usertrack.c +++ b/modules/metadata/mod_usertrack.c @@ -284,10 +284,9 @@ static void *make_cookie_dir(apr_pool_t *p, char *d) dcfg = (cookie_dir_rec *) apr_pcalloc(p, sizeof(cookie_dir_rec)); dcfg->cookie_name = COOKIE_NAME; - dcfg->cookie_domain = NULL; dcfg->style = CT_UNSET; - dcfg->enabled = 0; - /* calloc'ed to disabled: samesite, is_secure, is_httponly */ + /* calloc'ed to disabled: enabled, cookie_domain, samesite, is_secure, + * is_httponly */ /* In case the user does not use the CookieName directive, * we need to compile the regexp for the default cookie name. */ @@ -296,14 +295,6 @@ static void *make_cookie_dir(apr_pool_t *p, char *d) return dcfg; } -static const char *set_cookie_enable(cmd_parms *cmd, void *mconfig, int arg) -{ - cookie_dir_rec *dcfg = mconfig; - - dcfg->enabled = arg; - return NULL; -} - static const char *set_cookie_exp(cmd_parms *parms, void *dummy, const char *arg) { @@ -479,7 +470,8 @@ static const command_rec cookie_log_cmds[] = { "domain to which this cookie applies"), AP_INIT_TAKE1("CookieStyle", set_cookie_style, NULL, OR_FILEINFO, "'Netscape', 'Cookie' (RFC2109), or 'Cookie2' (RFC2965)"), - AP_INIT_FLAG("CookieTracking", set_cookie_enable, NULL, OR_FILEINFO, + AP_INIT_FLAG("CookieTracking", ap_set_flag_slot, + (void *)APR_OFFSETOF(cookie_dir_rec, enabled), OR_FILEINFO, "whether or not to enable cookies"), AP_INIT_TAKE1("CookieName", set_cookie_name, NULL, OR_FILEINFO, "name of the tracking cookie"),