]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: conform to the standard usage of string::find 10086/head
authorYan Jun <yan.jun8@zte.com.cn>
Wed, 29 Jun 2016 00:55:18 +0000 (08:55 +0800)
committerYan Jun <yan.jun8@zte.com.cn>
Sat, 2 Jul 2016 03:03:25 +0000 (11:03 +0800)
Signed-off-by: Yan Jun <yan.jun8@zte.com.cn>
src/rgw/rgw_rest_s3.cc

index 1d64aa061a70688a9d68ecb534c5206df2d6d098..380ac43b005c0505fbbaa9cb12621638221cf355 100644 (file)
@@ -1247,8 +1247,8 @@ void RGWPutObj_ObjStore_S3::send_response()
 static void parse_params(const string& params_str, string& first,
                         map<string, string>& params)
 {
-  int pos = params_str.find(';');
-  if (pos < 0) {
+  size_t pos = params_str.find(';');
+  if (pos == string::npos) {
     first = rgw_trim_whitespace(params_str);
     return;
   }
@@ -1257,18 +1257,17 @@ static void parse_params(const string& params_str, string& first,
 
   pos++;
 
-  while (pos < (int)params_str.size()) {
-    ssize_t end = params_str.find(';', pos);
-    if (end < 0)
+  while (pos < params_str.size()) {
+    size_t end = params_str.find(';', pos);
+    if (end == string::npos)
       end = params_str.size();
 
     string param = params_str.substr(pos, end - pos);
 
-    int eqpos = param.find('=');
-    if (eqpos > 0) {
-      string param_name = rgw_trim_whitespace(param.substr(0, eqpos));
-      string val = rgw_trim_quotes(param.substr(eqpos + 1));
-      params[param_name] = val;
+    size_t eqpos = param.find('=');
+    if (eqpos != string::npos) {
+      params[rgw_trim_whitespace(param.substr(0, eqpos))] =
+        rgw_trim_quotes(param.substr(eqpos + 1));
     } else {
       params[rgw_trim_whitespace(param)] = "";
     }
@@ -1280,12 +1279,12 @@ static void parse_params(const string& params_str, string& first,
 static int parse_part_field(const string& line, string& field_name,
                            struct post_part_field& field)
 {
-  int pos = line.find(':');
-  if (pos < 0)
+  size_t pos = line.find(':');
+  if (pos == string::npos)
     return -EINVAL;
 
   field_name = line.substr(0, pos);
-  if (pos >= (int)line.size() - 1)
+  if (pos >= line.size() - 1)
     return 0;
 
   parse_params(line.substr(pos + 1), field.val, field.params);