]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Browser Upload's primitives take bool output params as references.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 24 Apr 2017 14:34:35 +0000 (16:34 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 24 Apr 2017 15:32:16 +0000 (17:32 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_rest.cc
src/rgw/rgw_rest.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc

index 572b58aa9b9eca6b8be5d5a4eb650de67a3bdfb5..c6a412e3956020e8b569cce0d444bdc0525636f7 100644 (file)
@@ -1301,12 +1301,15 @@ static bool is_crlf(const char *s)
  * find the index of the boundary, if exists, or optionally the next end of line
  * also returns how many bytes to skip
  */
-static int index_of(bufferlist& bl, int max_len, const string& str,
-                   bool check_crlf,
-                   bool *reached_boundary, int *skip)
+static int index_of(ceph::bufferlist& bl,
+                    uint64_t max_len,
+                    const std::string& str,
+                    const bool check_crlf,
+                    bool& reached_boundary,
+                    int& skip)
 {
-  *reached_boundary = false;
-  *skip = 0;
+  reached_boundary = false;
+  skip = 0;
 
   if (str.size() < 2) // we assume boundary is at least 2 chars (makes it easier with crlf checks)
     return -EINVAL;
@@ -1317,21 +1320,20 @@ static int index_of(bufferlist& bl, int max_len, const string& str,
   const char *buf = bl.c_str();
   const char *s = str.c_str();
 
-  if (max_len > (int)bl.length())
+  if (max_len > bl.length())
     max_len = bl.length();
 
-  int i;
-  for (i = 0; i < max_len; i++, buf++) {
+  for (uint64_t i = 0; i < max_len; i++, buf++) {
     if (check_crlf &&
        i >= 1 &&
        is_crlf(buf - 1)) {
       return i + 1; // skip the crlf
     }
-    if ((i < max_len - (int)str.size() + 1) &&
+    if ((i < max_len - str.size() + 1) &&
        (buf[0] == s[0] && buf[1] == s[1]) &&
        (strncmp(buf, s, str.size()) == 0)) {
-      *reached_boundary = true;
-      *skip = str.size();
+      reached_boundary = true;
+      skip = str.size();
 
       /* oh, great, now we need to swallow the preceding crlf
        * if exists
@@ -1339,7 +1341,7 @@ static int index_of(bufferlist& bl, int max_len, const string& str,
       if ((i >= 2) &&
          is_crlf(buf - 2)) {
        i -= 2;
-       *skip += 2;
+       skip += 2;
       }
       return i;
     }
@@ -1351,8 +1353,8 @@ static int index_of(bufferlist& bl, int max_len, const string& str,
 int RGWPostObj_ObjStore::read_with_boundary(ceph::bufferlist& bl,
                                             uint64_t max,
                                             const bool check_crlf,
-                                            bool* const reached_boundary,
-                                            bool* const done)
+                                            bool& reached_boundary,
+                                            bool& done)
 {
   uint64_t cl = max + 2 + boundary.size();
 
@@ -1368,10 +1370,10 @@ int RGWPostObj_ObjStore::read_with_boundary(ceph::bufferlist& bl,
     in_data.append(bp, 0, read_len);
   }
 
-  *done = false;
+  done = false;
   int skip;
-  int index = index_of(in_data, cl, boundary, check_crlf, reached_boundary,
-                      &skip);
+  const int index = index_of(in_data, cl, boundary, check_crlf,
+                             reached_boundary, skip);
   if (index >= 0) {
     max = index;
   }
@@ -1388,7 +1390,7 @@ int RGWPostObj_ObjStore::read_with_boundary(ceph::bufferlist& bl,
    * now we need to skip boundary for next time, also skip any crlf, or
    * check to see if it's the last final boundary (marked with "--" at the end
    */
-  if (*reached_boundary) {
+  if (reached_boundary) {
     int left = in_data.length() - max;
     if (left < skip + 2) {
       int need = skip + 2 - left;
@@ -1407,7 +1409,7 @@ int RGWPostObj_ObjStore::read_with_boundary(ceph::bufferlist& bl,
       } else {
        if (*(data + max) == '-' &&
            *(data + max + 1) == '-') {
-         *done = true;
+         done = true;
          max += 2;
        }
       }
@@ -1422,41 +1424,41 @@ int RGWPostObj_ObjStore::read_with_boundary(ceph::bufferlist& bl,
 
 int RGWPostObj_ObjStore::read_line(ceph::bufferlist& bl,
                                    const uint64_t max,
-                                   bool* const reached_boundary,
-                                   bool* const done)
+                                   bool& reached_boundary,
+                                   bool& done)
 {
   return read_with_boundary(bl, max, true, reached_boundary, done);
 }
 
 int RGWPostObj_ObjStore::read_data(ceph::bufferlist& bl,
                                    const uint64_t max,
-                                   bool* const reached_boundary,
-                                   bool* const done)
+                                   bool& reached_boundary,
+                                   bool& done)
 {
   return read_with_boundary(bl, max, false, reached_boundary, done);
 }
 
 
 int RGWPostObj_ObjStore::read_form_part_header(struct post_form_part* const part,
-                                               bool* const done)
+                                               bool& done)
 {
   bufferlist bl;
   bool reached_boundary;
   uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
-  int r = read_line(bl, chunk_size, &reached_boundary, done);
+  int r = read_line(bl, chunk_size, reached_boundary, done);
   if (r < 0) {
     return r;
   }
 
-  if (*done) {
+  if (done) {
     return 0;
   }
 
   if (reached_boundary) { // skip the first boundary
-    r = read_line(bl, chunk_size, &reached_boundary, done);
+    r = read_line(bl, chunk_size, reached_boundary, done);
     if (r < 0) {
       return r;
-    } else if (*done) {
+    } else if (done) {
       return 0;
     }
   }
@@ -1489,7 +1491,7 @@ int RGWPostObj_ObjStore::read_form_part_header(struct post_form_part* const part
       break;
     }
 
-    r = read_line(bl, chunk_size, &reached_boundary, done);
+    r = read_line(bl, chunk_size, reached_boundary, done);
   }
 
   return 0;
index 79d78b9209eb09d196472960e110f838e9d8af8b..4b092935e4652821da2b4527a39350da27abfab8 100644 (file)
@@ -242,21 +242,20 @@ protected:
   int read_with_boundary(ceph::bufferlist& bl,
                          uint64_t max,
                          bool check_eol,
-                         bool* reached_boundary,
-                         bool* done);
+                         bool& reached_boundary,
+                         bool& done);
 
   int read_line(ceph::bufferlist& bl,
                 uint64_t max,
-                bool* reached_boundary,
-                bool* done);
+                bool& reached_boundary,
+                bool& done);
 
   int read_data(ceph::bufferlist& bl,
                 uint64_t max,
-                bool* reached_boundary,
-                bool* done);
+                bool& reached_boundary,
+                bool& done);
 
-  int read_form_part_header(struct post_form_part *part,
-                            bool *done);
+  int read_form_part_header(struct post_form_part *part, bool& done);
 
   int get_params() override;
 
index 80ca50e1f6f8c554a2ef94b61684156166c392e4..b41441160f58f5a32134a2ada39f8755cabc5699 100644 (file)
@@ -1533,7 +1533,7 @@ int RGWPostObj_ObjStore_S3::get_params()
   bool done;
   do {
     struct post_form_part part;
-    int r = read_form_part_header(&part, &done);
+    int r = read_form_part_header(&part, done);
     if (r < 0)
       return r;
 
@@ -1570,7 +1570,7 @@ int RGWPostObj_ObjStore_S3::get_params()
 
     bool boundary;
     uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
-    r = read_data(part.data, chunk_size, &boundary, &done);
+    r = read_data(part.data, chunk_size, boundary, done);
     if (!boundary) {
       err_msg = "Couldn't find boundary";
       return -EINVAL;
@@ -1752,7 +1752,7 @@ int RGWPostObj_ObjStore_S3::complete_get_params()
   bool done;
   do {
     struct post_form_part part;
-    int r = read_form_part_header(&part, &done);
+    int r = read_form_part_header(&part, done);
     if (r < 0) {
       return r;
     }
@@ -1760,7 +1760,7 @@ int RGWPostObj_ObjStore_S3::complete_get_params()
     ceph::bufferlist part_data;
     bool boundary;
     uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
-    r = read_data(part.data, chunk_size, &boundary, &done);
+    r = read_data(part.data, chunk_size, boundary, done);
     if (!boundary) {
       return -EINVAL;
     }
@@ -1777,7 +1777,7 @@ int RGWPostObj_ObjStore_S3::get_data(ceph::bufferlist& bl, bool& again)
   bool done;
 
   const uint64_t chunk_size = s->cct->_conf->rgw_max_chunk_size;
-  int r = read_data(bl, chunk_size, &boundary, &done);
+  int r = read_data(bl, chunk_size, boundary, done);
   if (r < 0) {
     return r;
   }
index f1a3f787fabdfb0a15205634e364a61900a36166..bf17a2fdfe3207e3f4f68c9773b3e946576b83a5 100644 (file)
@@ -1814,7 +1814,7 @@ int RGWFormPost::get_params()
    * by-step till encountering the first part with file data. */
   do {
     struct post_form_part part;
-    ret = read_form_part_header(&part, &stream_done);
+    ret = read_form_part_header(&part, stream_done);
     if (ret < 0) {
       return ret;
     }
@@ -1855,7 +1855,7 @@ int RGWFormPost::get_params()
       /* Control part ahead. Receive, parse and store for later usage. */
       bool boundary;
       ret = read_data(part.data, s->cct->_conf->rgw_max_chunk_size,
-                      &boundary, &stream_done);
+                      boundary, stream_done);
       if (ret < 0) {
         return ret;
       } else if (! boundary) {
@@ -1921,7 +1921,7 @@ bool RGWFormPost::is_next_file_to_upload()
   if (! stream_done) {
     /* We have at least one additional part in the body. */
     struct post_form_part part;
-    int r = read_form_part_header(&part, &stream_done);
+    int r = read_form_part_header(&part, stream_done);
     if (r < 0) {
       return false;
     }
@@ -1945,7 +1945,7 @@ int RGWFormPost::get_data(ceph::bufferlist& bl, bool& again)
   bool boundary;
 
   int r = read_data(bl, s->cct->_conf->rgw_max_chunk_size,
-                    &boundary, &stream_done);
+                    boundary, stream_done);
   if (r < 0) {
     return r;
   }