]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: improve const-correctness of ACL-related code.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Fri, 22 Jan 2016 16:40:03 +0000 (17:40 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 2 Jun 2016 13:30:39 +0000 (15:30 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_acl.h
src/rgw/rgw_acl_swift.cc

index 8aca31504c3c9cf80394cb3a339da0abf569a467..ec073ba3ed8f186543ef250631a709e0f65876d4 100644 (file)
@@ -48,7 +48,7 @@ protected:
 public:
   ACLPermission() : flags(0) {}
   ~ACLPermission() {}
-  int get_permissions() { return flags; }
+  int get_permissions() const { return flags; }
   void set_permissions(int perm) { flags = perm; }
 
   void encode(bufferlist& bl) const {
@@ -74,7 +74,7 @@ public:
   ACLGranteeType() : type(ACL_TYPE_UNKNOWN) {}
   virtual ~ACLGranteeType() {}
 //  virtual const char *to_string() = 0;
-  ACLGranteeTypeEnum get_type() { return (ACLGranteeTypeEnum)type; }
+  ACLGranteeTypeEnum get_type() const { return (ACLGranteeTypeEnum)type; }
   void set(ACLGranteeTypeEnum t) { type = t; }
 //  virtual void set(const char *s) = 0;
   void encode(bufferlist& bl) const {
@@ -116,7 +116,7 @@ public:
 
   /* there's an assumption here that email/uri/id encodings are
      different and there can't be any overlap */
-  bool get_id(rgw_user& _id) {
+  bool get_id(rgw_user& _id) const {
     switch(type.get_type()) {
     case ACL_TYPE_EMAIL_USER:
       _id = email; // implies from_str() that parses the 't:u' syntax
@@ -129,8 +129,10 @@ public:
     }
   }
   ACLGranteeType& get_type() { return type; }
+  const ACLGranteeType& get_type() const { return type; }
   ACLPermission& get_permission() { return permission; }
-  ACLGroupTypeEnum get_group() { return group; }
+  const ACLPermission& get_permission() const { return permission; }
+  ACLGroupTypeEnum get_group() const { return group; }
 
   void encode(bufferlist& bl) const {
     ENCODE_START(4, 3, bl);
@@ -241,6 +243,7 @@ public:
   void add_grant(ACLGrant *grant);
 
   multimap<string, ACLGrant>& get_grant_map() { return grant_map; }
+  const multimap<string, ACLGrant>& get_grant_map() const { return grant_map; }
 
   void create_default(const rgw_user& id, string name) {
     acl_user_map.clear();
@@ -281,7 +284,7 @@ public:
   void dump(Formatter *f) const;
   static void generate_test_instances(list<ACLOwner*>& o);
   void set_id(const rgw_user& _id) { id = _id; }
-  void set_name(string& name) { display_name = name; }
+  void set_name(const string& name) { display_name = name; }
 
   rgw_user& get_id() { return id; }
   string& get_display_name() { return display_name; }
@@ -345,6 +348,9 @@ public:
   RGWAccessControlList& get_acl() {
     return acl;
   }
+  const RGWAccessControlList& get_acl() const {
+    return acl;
+  }
 
   virtual bool compare_group_name(string& id, ACLGroupTypeEnum group) { return false; }
 };
index a9729e33cc585a9aaf88fa30afd9f8ca19c6d2a7..83fdc09c0f5b2c4ed723feb9570eedb9fde6850e 100644 (file)
@@ -38,7 +38,7 @@ static int parse_list(string& uid_list, list<string>& uids)
   return 0;
 }
 
-static bool uid_is_public(string& uid)
+static bool uid_is_public(const string& uid)
 {
   if (uid[0] != '.' || uid[1] != 'r')
     return false;