Merge pull request #14426 from tchaikov/wip-13562-kefu

misc: SCA fixes

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-04-11 17:41:56 +08:00 committed by GitHub
commit 1efff5297f
14 changed files with 54 additions and 28 deletions

View File

@ -108,12 +108,12 @@ int main(int argc, const char **argv, const char *envp[]) {
g_ceph_context->_conf->apply_changes(NULL);
// check for 32-bit arch
if (sizeof(long) == 4) {
#ifndef __LP64__
cerr << std::endl;
cerr << "WARNING: Ceph inode numbers are 64 bits wide, and FUSE on 32-bit kernels does" << std::endl;
cerr << " not cope well with that situation. Expect to crash shortly." << std::endl;
cerr << std::endl;
}
#endif
Preforker forker;
if (g_conf->daemonize) {

View File

@ -35,7 +35,7 @@ bufferlist *clslua_checkbufferlist(lua_State *L, int pos)
*/
bufferlist *clslua_pushbufferlist(lua_State *L, bufferlist *set)
{
bufferlist_wrap *blw = (bufferlist_wrap *)lua_newuserdata(L, sizeof(*blw));
bufferlist_wrap *blw = static_cast<bufferlist_wrap *>(lua_newuserdata(L, sizeof(*blw)));
blw->bl = set ? set : new bufferlist();
blw->gc = set ? 0 : 1;
luaL_getmetatable(L, LUA_BUFFERLIST);

View File

@ -101,6 +101,8 @@ public:
int r = io_ctx.aio_operate(oid, c, (librados::ObjectReadOperation*)op, NULL);
if (r >= 0) {
add_pending(arg->id, c, oid);
} else {
c->release();
}
return r;
}
@ -115,6 +117,8 @@ public:
int r = io_ctx.aio_operate(oid, c, (librados::ObjectWriteOperation*)op);
if (r >= 0) {
add_pending(arg->id, c, oid);
} else {
c->release();
}
return r;
}

View File

@ -171,6 +171,7 @@ static char *parse_options(const char *data, int *filesys_flags)
} else if (strncmp(data, "secret", 6) == 0) {
if (!value || !*value) {
printf("mount option secret requires a value.\n");
free(saw_name);
return NULL;
}

View File

@ -533,9 +533,11 @@ ConnectionRef AsyncMessenger::get_loopback_connection()
int AsyncMessenger::_send_message(Message *m, const entity_inst_t& dest)
{
FUNCTRACE();
if (m && m->get_type() == CEPH_MSG_OSD_OP)
assert(m);
if (m->get_type() == CEPH_MSG_OSD_OP)
OID_EVENT_TRACE(((MOSDOp *)m)->get_oid().name.c_str(), "SEND_MSG_OSD_OP");
else if (m && m->get_type() == CEPH_MSG_OSD_OPREPLY)
else if (m->get_type() == CEPH_MSG_OSD_OPREPLY)
OID_EVENT_TRACE(((MOSDOpReply *)m)->get_oid().name.c_str(), "SEND_MSG_OSD_OP_REPLY");
ldout(cct, 1) << __func__ << "--> " << dest.name << " "

View File

@ -528,7 +528,7 @@ void BitMapZone::dump_state(CephContext* const cct, int& count)
BitMapEntityIter <BmapEntry> iter = BitMapEntityIter<BmapEntry>(
&m_bmap_vec, 0);
dout(0) << __func__ << " zone " << count << " dump start " << dendl;
while ((bmap = (BmapEntry *) iter.next())) {
while ((bmap = static_cast<BmapEntry *>(iter.next()))) {
bmap->dump_state(cct, bmap_idx);
bmap_idx++;
}
@ -770,8 +770,8 @@ bool BitMapAreaIN::is_allocated(int64_t start_block, int64_t num_blocks)
}
while (num_blocks) {
area = (BitMapArea *) m_child_list.get_nth_item(
start_block / m_child_size_blocks);
area = static_cast<BitMapArea *>(m_child_list.get_nth_item(
start_block / m_child_size_blocks));
area_block_offset = start_block % m_child_size_blocks;
falling_in_area = MIN(m_child_size_blocks - area_block_offset,
@ -795,7 +795,7 @@ int64_t BitMapAreaIN::alloc_blocks_dis_int_work(bool wrap, int64_t num_blocks, i
BmapEntityListIter iter = BmapEntityListIter(
&m_child_list, hint / m_child_size_blocks, wrap);
while ((child = (BitMapArea *) iter.next())) {
while ((child = static_cast<BitMapArea *>(iter.next()))) {
if (!child_check_n_lock(child, 1)) {
hint = 0;
continue;
@ -846,8 +846,8 @@ void BitMapAreaIN::set_blocks_used_int(int64_t start_block, int64_t num_blocks)
alloc_assert(start_block >= 0);
while (blks) {
child = (BitMapArea *) m_child_list.get_nth_item(
start_blk / m_child_size_blocks);
child = static_cast<BitMapArea *>(m_child_list.get_nth_item(
start_blk / m_child_size_blocks));
child_block_offset = start_blk % child->size();
falling_in_child = MIN(m_child_size_blocks - child_block_offset,
@ -886,8 +886,8 @@ void BitMapAreaIN::free_blocks_int(int64_t start_block, int64_t num_blocks)
}
while (num_blocks) {
child = (BitMapArea *) m_child_list.get_nth_item(
start_block / m_child_size_blocks);
child = static_cast<BitMapArea *>(m_child_list.get_nth_item(
start_block / m_child_size_blocks));
child_block_offset = start_block % m_child_size_blocks;
@ -920,7 +920,7 @@ void BitMapAreaIN::dump_state(CephContext* const cct, int& count)
BmapEntityListIter iter = BmapEntityListIter(
&m_child_list, 0, false);
while ((child = (BitMapArea *) iter.next())) {
while ((child = static_cast<BitMapArea *>(iter.next()))) {
child->dump_state(cct, count);
}
}
@ -974,7 +974,7 @@ BitMapAreaLeaf::~BitMapAreaLeaf()
lock_excl();
for (int64_t i = 0; i < m_child_list.size(); i++) {
BitMapArea *child = (BitMapArea *) m_child_list.get_nth_item(i);
auto child = static_cast<BitMapArea *>(m_child_list.get_nth_item(i));
delete child;
}
@ -1054,8 +1054,8 @@ void BitMapAreaLeaf::free_blocks_int(int64_t start_block, int64_t num_blocks)
}
while (num_blocks) {
child = (BitMapArea *) m_child_list.get_nth_item(
start_block / m_child_size_blocks);
child = static_cast<BitMapArea *>(m_child_list.get_nth_item(
start_block / m_child_size_blocks));
child_block_offset = start_block % m_child_size_blocks;
@ -1170,7 +1170,7 @@ BitAllocator::~BitAllocator()
lock_excl();
for (int64_t i = 0; i < m_child_list.size(); i++) {
BitMapArea *child = (BitMapArea *) m_child_list.get_nth_item(i);
auto child = static_cast<BitMapArea *>(m_child_list.get_nth_item(i));
delete child;
}

View File

@ -5058,7 +5058,7 @@ void OSD::ms_handle_fast_accept(Connection *con)
bool OSD::ms_handle_reset(Connection *con)
{
Session *session = (Session *)con->get_priv();
Session *session = static_cast<Session*>(con->get_priv());
dout(2) << "ms_handle_reset con " << con << " session " << session << dendl;
if (!session)
return false;
@ -5077,7 +5077,7 @@ bool OSD::ms_handle_refused(Connection *con)
if (!cct->_conf->osd_fast_fail_on_connection_refused)
return false;
Session *session = (Session *)con->get_priv();
Session *session = static_cast<Session*>(con->get_priv());
dout(2) << "ms_handle_refused con " << con << " session " << session << dendl;
if (!session)
return false;

View File

@ -1880,7 +1880,7 @@ bool PG::op_has_sufficient_caps(OpRequestRef& op)
const MOSDOp *req = static_cast<const MOSDOp*>(op->get_req());
Session *session = (Session *)req->get_connection()->get_priv();
Session *session = static_cast<Session*>(req->get_connection()->get_priv());
if (!session) {
dout(0) << "op_has_sufficient_caps: no session for op " << *req << dendl;
return false;

View File

@ -1533,7 +1533,7 @@ void PrimaryLogPG::get_src_oloc(const object_t& oid, const object_locator_t& olo
void PrimaryLogPG::handle_backoff(OpRequestRef& op)
{
const MOSDBackoff *m = static_cast<const MOSDBackoff*>(op->get_req());
SessionRef session((Session *)m->get_connection()->get_priv());
SessionRef session = static_cast<Session*>(m->get_connection()->get_priv());
if (!session)
return; // drop it.
session->put(); // get_priv takes a ref, and so does the SessionRef
@ -1579,7 +1579,7 @@ void PrimaryLogPG::do_request(
// pg-wide backoffs
const Message *m = op->get_req();
if (m->get_connection()->has_feature(CEPH_FEATURE_RADOS_BACKOFF)) {
SessionRef session((Session *)m->get_connection()->get_priv());
SessionRef session = static_cast<Session*>(m->get_connection()->get_priv());
if (!session)
return; // drop it.
session->put(); // get_priv takes a ref, and so does the SessionRef
@ -1779,7 +1779,7 @@ void PrimaryLogPG::do_op(OpRequestRef& op)
m->get_connection()->has_feature(CEPH_FEATURE_RADOS_BACKOFF);
SessionRef session;
if (can_backoff) {
session = ((Session *)m->get_connection()->get_priv());
session = static_cast<Session*>(m->get_connection()->get_priv());
if (!session.get()) {
dout(10) << __func__ << " no session" << dendl;
return;

View File

@ -534,6 +534,7 @@ namespace rgw {
}
void set_times(real_time t) {
lock_guard guard(mtx);
state.ctime = real_clock::to_timespec(t);
state.mtime = state.ctime;
state.atime = state.ctime;

View File

@ -1234,7 +1234,7 @@ int RGWPutObj_ObjStore_S3::validate_and_unwrap_available_aws4_chunked_data(buffe
/* grab chunk size */
while ((*(chunk_str+chunk_offset) != ';') && (chunk_offset < chunk_str_min_len))
while ((chunk_offset < chunk_str_min_len) && (chunk_str[chunk_offset] != ';'))
chunk_offset++;
string str = string(chunk_str, chunk_offset);
unsigned int chunk_data_size;
@ -4032,7 +4032,7 @@ int RGWHandler_REST_S3Website::serve_errordoc(int http_ret, const string& errord
int ret = 0;
s->formatter->reset(); /* Try to throw it all away */
std::shared_ptr<RGWGetObj_ObjStore_S3Website> getop( (RGWGetObj_ObjStore_S3Website*) op_get() );
std::shared_ptr<RGWGetObj_ObjStore_S3Website> getop( static_cast<RGWGetObj_ObjStore_S3Website*>(op_get()));
if (getop.get() == NULL) {
return -1; // Trigger double error handler
}

View File

@ -657,7 +657,7 @@ TEST_F(TestLibRBD, UpdateWatchAndResize)
uint64_t size = 2 << 20;
struct Watcher {
static void cb(void *arg) {
Watcher *watcher = (Watcher *)arg;
Watcher *watcher = static_cast<Watcher *>(arg);
watcher->handle_notify();
}
Watcher(rbd_image_t &image) : m_image(image), m_lock("lock") {}

View File

@ -99,7 +99,7 @@ TEST(BitAllocator, test_bmap_iter)
i = off;
last_idx = off;
count = 0;
while ((obj = (BmapEntityTmp*) iter.next())) {
while ((obj = static_cast<BmapEntityTmp*>(iter.next()))) {
bmap_test_assert(obj->get_index() == last_idx);
bmap_test_assert(obj->get_index() == i);
bmap_test_assert(obj == &(*arr)[i]);

View File

@ -34,6 +34,8 @@ TEST(CommonIPAddr, TestNotFound)
struct sockaddr_in net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -58,6 +60,8 @@ TEST(CommonIPAddr, TestV4_Simple)
struct sockaddr_in net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -82,6 +86,8 @@ TEST(CommonIPAddr, TestV4_Prefix25)
struct sockaddr_in net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -106,6 +112,8 @@ TEST(CommonIPAddr, TestV4_Prefix16)
struct sockaddr_in net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -129,6 +137,8 @@ TEST(CommonIPAddr, TestV4_PrefixTooLong)
struct sockaddr_in net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = NULL;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -148,6 +158,8 @@ TEST(CommonIPAddr, TestV4_PrefixZero)
struct sockaddr_in net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -172,6 +184,8 @@ TEST(CommonIPAddr, TestV6_Simple)
struct sockaddr_in6 net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -196,6 +210,8 @@ TEST(CommonIPAddr, TestV6_Prefix57)
struct sockaddr_in6 net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = &two;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;
@ -219,6 +235,8 @@ TEST(CommonIPAddr, TestV6_PrefixTooLong)
struct sockaddr_in6 net;
const struct sockaddr *result;
memset(&net, '0', sizeof(net));
one.ifa_next = NULL;
one.ifa_addr = (struct sockaddr*)&a_one;
one.ifa_name = eth0;