Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: use string::npos while 'string::find()' find nothing #9985

Merged
merged 1 commit into from
Jun 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class MultipartMetaFilter : public RGWAccessListFilter {
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);
Expand All @@ -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++;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down