]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_rest_s3: unify return value type of valid_s3_bucket/object_name 13764/head
authorGui Hecheng <guihecheng@cmss.chinamobile.com>
Fri, 10 Mar 2017 08:47:39 +0000 (16:47 +0800)
committerGui Hecheng <guihecheng@cmss.chinamobile.com>
Fri, 10 Mar 2017 09:35:35 +0000 (17:35 +0800)
Signed-off-by: Gui Hecheng <guihecheng@cmss.chinamobile.com>
src/rgw/rgw_file.h
src/rgw/rgw_rest_s3.h

index d5d1626f3d10d8a55a8876d9a80a774295f73cf8..829232791969f1470aa9648ee1f64770d508ff96 100644 (file)
@@ -1522,8 +1522,9 @@ public:
     RGWOp::init(rados_ctx->store, get_state(), this);
     op = this; // assign self as op: REQUIRED
 
-    if (! valid_s3_object_name(obj_name))
-      return -ERR_INVALID_OBJECT_NAME;
+    int rc = valid_s3_object_name(obj_name);
+    if (rc != 0)
+      return rc;
 
     return 0;
   }
@@ -2169,8 +2170,9 @@ public:
     dest_object = dst_parent->format_child_name(dst_name);
     // need s->object_name?
 
-    if (! valid_s3_object_name(dest_object))
-      return -ERR_INVALID_OBJECT_NAME;
+    int rc = valid_s3_object_name(dest_object);
+    if (rc != 0)
+      return rc;
 
     /* XXX and fixup key attr (could optimize w/string ref and
      * dest_object) */
index a5a17686dd8a384aff8de801bf113e7f196e299e..e0726733684e9a5cd647d8be70a82d6450a65048 100644 (file)
@@ -610,14 +610,14 @@ static inline bool looks_like_ip_address(const char *bucket)
   return (num_periods == 3);
 }
 
-static inline bool valid_s3_object_name(const string& name) {
+static inline int valid_s3_object_name(const string& name) {
   if (name.size() > 1024) {
-    return false;
+    return -ERR_INVALID_OBJECT_NAME;
   }
   if (check_utf8(name.c_str(), name.size())) {
-    return false;
+    return -ERR_INVALID_OBJECT_NAME;
   }
-  return true;
+  return 0;
 }
 
 static inline int valid_s3_bucket_name(const string& name, bool relaxed=false)