Merge pull request #6797 from mathslinux/fix-parse-return

rgw: fix wrong check for parse() return

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Sage Weil 2016-01-14 19:01:00 -05:00
commit 2f9f91b6a1
3 changed files with 10 additions and 13 deletions

View File

@ -1494,16 +1494,16 @@ int OSD::peek_meta(ObjectStore *store, std::string& magic,
if (r < 0)
return r;
r = cluster_fsid.parse(val.c_str());
if (r < 0)
return r;
if (!r)
return -EINVAL;
r = store->read_meta("fsid", &val);
if (r < 0) {
osd_fsid = uuid_d();
} else {
r = osd_fsid.parse(val.c_str());
if (r < 0)
return r;
if (!r)
return -EINVAL;
}
return 0;

View File

@ -698,10 +698,9 @@ static int read_decode_json(const string& infile, T& t)
return ret;
}
JSONParser p;
ret = p.parse(bl.c_str(), bl.length());
if (ret < 0) {
if (!p.parse(bl.c_str(), bl.length())) {
cout << "failed to parse JSON" << std::endl;
return ret;
return -EINVAL;
}
try {
@ -723,10 +722,9 @@ static int read_decode_json(const string& infile, T& t, K *k)
return ret;
}
JSONParser p;
ret = p.parse(bl.c_str(), bl.length());
if (ret < 0) {
if (!p.parse(bl.c_str(), bl.length())) {
cout << "failed to parse JSON" << std::endl;
return ret;
return -EINVAL;
}
try {

View File

@ -1601,10 +1601,9 @@ static int forward_request_to_master(struct req_state *s, obj_version *objv, RGW
return ret;
ldout(s->cct, 20) << "response: " << response.c_str() << dendl;
ret = jp->parse(response.c_str(), response.length());
if (ret < 0) {
if (!jp->parse(response.c_str(), response.length())) {
ldout(s->cct, 0) << "failed parsing response from master region" << dendl;
return ret;
return -EINVAL;
}
return 0;