]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use string::npos while 'string::find()' find nothing 9985/head
authorYan Jun <yan.jun8@zte.com.cn>
Mon, 27 Jun 2016 16:24:02 +0000 (00:24 +0800)
committerYan Jun <yan.jun8@zte.com.cn>
Tue, 28 Jun 2016 14:03:59 +0000 (22:03 +0800)
Signed-off-by: Yan Jun <yan.jun8@zte.com.cn>
src/rgw/rgw_op.cc

index f198ea6c3093896c542b9f9f6cb03be8995d2cce..a8b28728b651685a691f18c31551efd1f61ceb02 100644 (file)
@@ -52,12 +52,12 @@ public:
     if (len < 6)
       return false;
 
-    int pos = name.find(MP_META_SUFFIX, len - 5);
-    if (pos <= 0)
+    size_t pos = name.find(MP_META_SUFFIX, len - 5);
+    if (pos == string::npos)
       return false;
 
     pos = name.rfind('.', pos - 1);
-    if (pos < 0)
+    if (pos == string::npos)
       return false;
 
     key = name.substr(0, pos);
@@ -77,8 +77,8 @@ static int parse_range(const char *range, off_t& ofs, off_t& end, bool *partial_
 
   *partial_content = false;
 
-  int pos = s.find("bytes=");
-  if (pos < 0) {
+  size_t pos = s.find("bytes=");
+  if (pos == string::npos) {
     pos = 0;
     while (isspace(s[pos]))
       pos++;
@@ -96,7 +96,7 @@ static int parse_range(const char *range, off_t& ofs, off_t& end, bool *partial_
     s = s.substr(pos + 6); /* size of("bytes=")  */
   }
   pos = s.find('-');
-  if (pos < 0)
+  if (pos == string::npos)
     goto done;
 
   *partial_content = true;
@@ -1019,8 +1019,8 @@ int RGWGetObj::handle_user_manifest(const char *prefix)
   ldout(s->cct, 2) << "RGWGetObj::handle_user_manifest() prefix=" << prefix << dendl;
 
   string prefix_str = prefix;
-  int pos = prefix_str.find('/');
-  if (pos < 0)
+  size_t pos = prefix_str.find('/');
+  if (pos == string::npos)
     return -EINVAL;
 
   string bucket_name_raw, bucket_name;
@@ -3377,8 +3377,8 @@ bool RGWCopyObj::parse_copy_location(const string& url_src, string& bucket_name,
   string name_str;
   string params_str;
 
-  int pos = url_src.find('?');
-  if (pos < 0) {
+  size_t pos = url_src.find('?');
+  if (pos == string::npos) {
     name_str = url_src;
   } else {
     name_str = url_src.substr(0, pos);
@@ -3395,7 +3395,7 @@ bool RGWCopyObj::parse_copy_location(const string& url_src, string& bucket_name,
   string str(src);
 
   pos = str.find('/');
-  if (pos <= 0)
+  if (pos ==string::npos)
     return false;
 
   bucket_name = str.substr(0, pos);