]> granicus.if.org Git - apache/commitdiff
Merge r1629440, r1629441, r1681424, r1681440, r1681685 from trunk:
authorJim Jagielski <jim@apache.org>
Mon, 1 Jun 2015 12:40:51 +0000 (12:40 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 1 Jun 2015 12:40:51 +0000 (12:40 +0000)
Style (mostly indent)
remove a useless local variable initialization

More style

Constify + save a few bytes in conf pool (+ some minor space adjustments)

Save a few bytes in conf pool and axe a function that duplicates 'ap_set_string_slot'

Save a few bytes in conf pool
Submitted by: jailletc36
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1682889 13f79535-47bb-0310-9956-ffa450edef68

STATUS
modules/aaa/mod_allowmethods.c
modules/aaa/mod_auth_basic.c
modules/aaa/mod_authn_dbm.c
modules/proxy/mod_proxy_express.c

diff --git a/STATUS b/STATUS
index d0bb4a208fd3b932a0621797eb6e1d6b58c8470a..4e88189c950eed2c0cf12c811e2cf2ad0efd97ea 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,22 +105,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) Easy proposals:
-        mod_allowmethods: Style (mostly indent)
-        mod_allowmethods: More style
-        mod_proxy_express: Constify + save a few bytes in conf pool
-                           (+ some minor space adjustments)
-        mod_authn_dbm: Save a few bytes in conf pool and axe a function
-                       that duplicates 'ap_set_string_slot'
-        mod_auth_basic: Save a few bytes in conf pool
-     trunk patch:
-        http://svn.apache.org/r1629440
-        http://svn.apache.org/r1629441
-        http://svn.apache.org/r1681424
-        http://svn.apache.org/r1681440
-        http://svn.apache.org/r1681685
-     2.4.x patch: trunk patch works
-     +1: jailletc36, ylavic, rjung
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
index 43ba176fc11421e6b7771c63750e864cde238f44..bcde09924f2e9351725c2a17ca02496a298804c6 100644 (file)
  */
 
 typedef struct am_conf_t {
-  int allowed_set;
-  apr_int64_t allowed;
+    int allowed_set;
+    apr_int64_t allowed;
 } am_conf_t;
 
 module AP_MODULE_DECLARE_DATA allowmethods_module;
 
 static int am_check_access(request_rec *r)
 {
-  int method = r->method_number;
-  am_conf_t *conf;
+    int method = r->method_number;
+    am_conf_t *conf;
 
-  conf = (am_conf_t *) ap_get_module_config(r->per_dir_config,
-                                            &allowmethods_module);
-  if (!conf || conf->allowed == 0) {
-    return DECLINED;
-  }
+    conf = (am_conf_t *) ap_get_module_config(r->per_dir_config,
+                                              &allowmethods_module);
+    if (!conf || conf->allowed == 0) {
+        return DECLINED;
+    }
 
-  r->allowed = conf->allowed;
+    r->allowed = conf->allowed;
 
-  if (conf->allowed & (AP_METHOD_BIT << method)) {
-    return DECLINED;
-  }
+    if (conf->allowed & (AP_METHOD_BIT << method)) {
+        return DECLINED;
+    }
 
-  ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01623)
+    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01623)
                   "client method denied by server configuration: '%s' to %s%s",
                   r->method,
                   r->filename ? "" : "uri ",
                   r->filename ? r->filename : r->uri);
 
-  return HTTP_METHOD_NOT_ALLOWED;
+    return HTTP_METHOD_NOT_ALLOWED;
 }
 
-static void *am_create_conf(apr_pool_t * p, char *dummy)
+static void *am_create_conf(apr_pool_t *p, char *dummy)
 {
-  am_conf_t *conf = apr_pcalloc(p, sizeof(am_conf_t));
+    am_conf_t *conf = apr_pcalloc(p, sizeof(am_conf_t));
 
-  conf->allowed = 0;
-  conf->allowed_set = 0;
-  return conf;
+    conf->allowed = 0;
+    conf->allowed_set = 0;
+    return conf;
 }
 
-static void* am_merge_conf(apr_pool_t* pool, void* a, void* b) {
-  am_conf_t* base = (am_conf_t*) a;
-  am_conf_t* add = (am_conf_t*) b;
-  am_conf_t* conf = apr_palloc(pool, sizeof(am_conf_t));
+static void *am_merge_conf(apr_pool_t *pool, void *a, void *b)
+{
+    am_conf_t *base = (am_conf_t *)a;
+    am_conf_t *add = (am_conf_t *)b;
+    am_conf_t *conf = apr_palloc(pool, sizeof(am_conf_t));
 
-  if (add->allowed_set) {
-      conf->allowed = add->allowed;
-      conf->allowed_set = add->allowed_set;
-  } else {
-      conf->allowed = base->allowed;
-      conf->allowed_set = base->allowed_set;
-  }
+    if (add->allowed_set) {
+        conf->allowed = add->allowed;
+        conf->allowed_set = add->allowed_set;
+    }
+    else {
+        conf->allowed = base->allowed;
+        conf->allowed_set = base->allowed_set;
+    }
 
-  return conf;
+    return conf;
 }
 
-static const char *am_allowmethods(cmd_parms *cmd, void *d, int argc, char *const argv[])
+static const char *am_allowmethods(cmd_parms *cmd, void *d, int argc,
+                                   char *const argv[])
 {
-  int i;
-  am_conf_t* conf = (am_conf_t*) d;
-  if (argc == 0) {
-      return "AllowMethods: No method or 'reset' keyword given";
-  }
-  if (argc == 1) {
-    if (strcasecmp("reset", argv[0]) == 0) {
-      conf->allowed = 0;
-      conf->allowed_set = 1;
-      return NULL;
-    }
-  }
+    int i;
+    am_conf_t *conf = (am_conf_t *)d;
 
-  for (i = 0; i < argc; i++) {
-    int m = 0;
-    m = ap_method_number_of(argv[i]);
-    if (m == M_INVALID) {
-      return apr_pstrcat(cmd->pool, "AllowMethods: Invalid Method '", argv[i], "'", NULL);
+    if (argc == 0) {
+        return "AllowMethods: No method or 'reset' keyword given";
     }
+    if (argc == 1) {
+        if (strcasecmp("reset", argv[0]) == 0) {
+            conf->allowed = 0;
+            conf->allowed_set = 1;
+            return NULL;
+        }
+    }
+
+    for (i = 0; i < argc; i++) {
+        int m;
+
+        m = ap_method_number_of(argv[i]);
+        if (m == M_INVALID) {
+            return apr_pstrcat(cmd->pool, "AllowMethods: Invalid Method '",
+                               argv[i], "'", NULL);
+        }
 
-    conf->allowed |= (AP_METHOD_BIT << m);
-  }
-  conf->allowed_set = 1;
-  return NULL;
+        conf->allowed |= (AP_METHOD_BIT << m);
+    }
+    conf->allowed_set = 1;
+    return NULL;
 }
 
 static void am_register_hooks(apr_pool_t * p)
 {
-  ap_hook_access_checker(am_check_access, NULL, NULL, APR_HOOK_REALLY_FIRST);
+    ap_hook_access_checker(am_check_access, NULL, NULL, APR_HOOK_REALLY_FIRST);
 }
 
 static const command_rec am_cmds[] = {
-  AP_INIT_TAKE_ARGV("AllowMethods", am_allowmethods, NULL,
-              ACCESS_CONF,
-              "only allow specific methods"),
-  {NULL}
+    AP_INIT_TAKE_ARGV("AllowMethods", am_allowmethods, NULL,
+                      ACCESS_CONF,
+                      "only allow specific methods"),
+    {NULL}
 };
 
 AP_DECLARE_MODULE(allowmethods) = {
-  STANDARD20_MODULE_STUFF,
-  am_create_conf,
-  am_merge_conf,
-  NULL,
-  NULL,
-  am_cmds,
-  am_register_hooks,
+    STANDARD20_MODULE_STUFF,
+    am_create_conf,
+    am_merge_conf,
+    NULL,
+    NULL,
+    am_cmds,
+    am_register_hooks,
 };
-
index 5ef40f755ef17e0f4f969a82864cc1d8834101f2..dc03b43897299e3bad4a56d4147928b1a99dc238 100644 (file)
@@ -195,7 +195,7 @@ static const char *set_use_digest_algorithm(cmd_parms *cmd, void *config,
                            "AuthBasicUseDigestAlgorithm: ", alg, NULL);
     }
 
-    conf->use_digest_algorithm = apr_pstrdup(cmd->pool, alg);
+    conf->use_digest_algorithm = alg;
     conf->use_digest_algorithm_set = 1;
 
     return NULL;
index 9ab05e45161936f1d694f63b0c713e11c6d6c50c..f4fb73672eeb37dcad8f2bb49a940dce5b6ddfbe 100644 (file)
@@ -59,23 +59,13 @@ static void *create_authn_dbm_dir_config(apr_pool_t *p, char *d)
     return conf;
 }
 
-static const char *set_dbm_type(cmd_parms *cmd,
-                                void *dir_config,
-                                const char *arg)
-{
-    authn_dbm_config_rec *conf = dir_config;
-
-    conf->dbmtype = apr_pstrdup(cmd->pool, arg);
-    return NULL;
-}
-
 static const command_rec authn_dbm_cmds[] =
 {
     AP_INIT_TAKE1("AuthDBMUserFile", ap_set_file_slot,
      (void *)APR_OFFSETOF(authn_dbm_config_rec, pwfile),
      OR_AUTHCFG, "dbm database file containing user IDs and passwords"),
-    AP_INIT_TAKE1("AuthDBMType", set_dbm_type,
-     NULL,
+    AP_INIT_TAKE1("AuthDBMType", ap_set_string_slot,
+     (void *)APR_OFFSETOF(authn_dbm_config_rec, dbmtype),
      OR_AUTHCFG, "what type of DBM file the user file is"),
     {NULL}
 };
index 1863f745c4f61b891043a180f426341ce8479ec8..9904fbbd7e82b178a09c9d27c344cefd24eec1d8 100644 (file)
@@ -22,8 +22,8 @@ module AP_MODULE_DECLARE_DATA proxy_express_module;
 static int proxy_available = 0;
 
 typedef struct {
-    char *dbmfile;
-    char *dbmtype;
+    const char *dbmfile;
+    const char *dbmtype;
     int enabled;
 } express_server_conf;
 
@@ -48,13 +48,14 @@ static const char *set_dbmtype(cmd_parms *cmd,
     express_server_conf *sconf;
     sconf = ap_get_module_config(cmd->server->module_config, &proxy_express_module);
 
-    sconf->dbmtype = apr_pstrdup(cmd->pool, arg);
+    sconf->dbmtype = arg;
+
     return NULL;
 }
 
 static const char *set_enabled(cmd_parms *cmd,
-                              void *dconf,
-                              int flag)
+                               void *dconf,
+                               int flag)
 {
     express_server_conf *sconf;
     sconf = ap_get_module_config(cmd->server->module_config, &proxy_express_module);
@@ -220,4 +221,3 @@ AP_DECLARE_MODULE(proxy_express) =
     command_table,  /* table of config file commands */
     register_hooks  /* register hooks */
 };
-