You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2020/02/28 06:13:50 UTC

svn commit: r1874602 - /httpd/httpd/trunk/modules/metadata/mod_usertrack.c

Author: jailletc36
Date: Fri Feb 28 06:13:50 2020
New Revision: 1874602

URL: http://svn.apache.org/viewvc?rev=1874602&view=rev
Log:
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)

Modified:
    httpd/httpd/trunk/modules/metadata/mod_usertrack.c

Modified: httpd/httpd/trunk/modules/metadata/mod_usertrack.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_usertrack.c?rev=1874602&r1=1874601&r2=1874602&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_usertrack.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_usertrack.c Fri Feb 28 06:13:50 2020
@@ -284,10 +284,9 @@ static void *make_cookie_dir(apr_pool_t
 
     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
     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"),