mirror of
https://github.com/ceph/ceph
synced 2024-12-19 01:46:00 +00:00
Merge pull request #3495 from XinzeChi/wip-size-empty
cleanup: replace some size() or length() with !empty() Reviewed-by: Loic Dachary <ldachary@redhat.com>
This commit is contained in:
commit
e41c052103
@ -181,9 +181,9 @@ public:
|
||||
}
|
||||
// This function maybe needs some work; assumes last event is completion time
|
||||
double get_duration() const {
|
||||
return events.size() ?
|
||||
(events.rbegin()->first - get_initiated()) :
|
||||
0.0;
|
||||
return events.empty() ?
|
||||
0.0 :
|
||||
(events.rbegin()->first - get_initiated());
|
||||
}
|
||||
|
||||
void mark_event(const string &event);
|
||||
|
@ -91,13 +91,13 @@ MDS::MDS(const std::string &n, Messenger *m, MonClient *mc) :
|
||||
hb(NULL),
|
||||
beacon(m->cct, mc, n),
|
||||
authorize_handler_cluster_registry(new AuthAuthorizeHandlerRegistry(m->cct,
|
||||
m->cct->_conf->auth_supported.length() ?
|
||||
m->cct->_conf->auth_supported :
|
||||
m->cct->_conf->auth_cluster_required)),
|
||||
m->cct->_conf->auth_supported.empty() ?
|
||||
m->cct->_conf->auth_cluster_required :
|
||||
m->cct->_conf->auth_supported)),
|
||||
authorize_handler_service_registry(new AuthAuthorizeHandlerRegistry(m->cct,
|
||||
m->cct->_conf->auth_supported.length() ?
|
||||
m->cct->_conf->auth_supported :
|
||||
m->cct->_conf->auth_service_required)),
|
||||
m->cct->_conf->auth_supported.empty() ?
|
||||
m->cct->_conf->auth_service_required :
|
||||
m->cct->_conf->auth_supported)),
|
||||
name(n),
|
||||
whoami(MDS_RANK_NONE), incarnation(0),
|
||||
standby_for_rank(MDSMap::MDS_NO_STANDBY_PREF),
|
||||
|
@ -6809,7 +6809,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
|
||||
}
|
||||
|
||||
if (reply_witness) {
|
||||
assert(srcdnrep.size());
|
||||
assert(!srcdnrep.empty());
|
||||
MMDSSlaveRequest *reply = new MMDSSlaveRequest(mdr->reqid, mdr->attempt,
|
||||
MMDSSlaveRequest::OP_RENAMEPREPACK);
|
||||
reply->witnesses.swap(srcdnrep);
|
||||
|
@ -354,7 +354,7 @@ int MonClient::init()
|
||||
Mutex::Locker l(monc_lock);
|
||||
|
||||
string method;
|
||||
if (cct->_conf->auth_supported.length() != 0)
|
||||
if (!cct->_conf->auth_supported.empty())
|
||||
method = cct->_conf->auth_supported;
|
||||
else if (entity_name.get_type() == CEPH_ENTITY_TYPE_OSD ||
|
||||
entity_name.get_type() == CEPH_ENTITY_TYPE_MDS ||
|
||||
@ -372,7 +372,7 @@ int MonClient::init()
|
||||
r = keyring->from_ceph_context(cct);
|
||||
if (r == -ENOENT) {
|
||||
auth_supported->remove_supported_auth(CEPH_AUTH_CEPHX);
|
||||
if (auth_supported->get_supported_set().size() > 0) {
|
||||
if (!auth_supported->get_supported_set().empty()) {
|
||||
r = 0;
|
||||
no_keyring_disabled_cephx = true;
|
||||
} else {
|
||||
|
@ -145,11 +145,11 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
|
||||
log_client(cct_, messenger, monmap, LogClient::FLAG_MON),
|
||||
key_server(cct, &keyring),
|
||||
auth_cluster_required(cct,
|
||||
cct->_conf->auth_supported.length() ?
|
||||
cct->_conf->auth_supported : cct->_conf->auth_cluster_required),
|
||||
cct->_conf->auth_supported.empty() ?
|
||||
cct->_conf->auth_cluster_required : cct->_conf->auth_supported),
|
||||
auth_service_required(cct,
|
||||
cct->_conf->auth_supported.length() ?
|
||||
cct->_conf->auth_supported : cct->_conf->auth_service_required),
|
||||
cct->_conf->auth_supported.empty() ?
|
||||
cct->_conf->auth_service_required : cct->_conf->auth_supported ),
|
||||
leader_supported_mon_commands(NULL),
|
||||
leader_supported_mon_commands_size(0),
|
||||
store(s),
|
||||
@ -2504,10 +2504,10 @@ void Monitor::set_leader_supported_commands(const MonCommand *cmds, int size)
|
||||
|
||||
bool Monitor::is_keyring_required()
|
||||
{
|
||||
string auth_cluster_required = g_conf->auth_supported.length() ?
|
||||
g_conf->auth_supported : g_conf->auth_cluster_required;
|
||||
string auth_service_required = g_conf->auth_supported.length() ?
|
||||
g_conf->auth_supported : g_conf->auth_service_required;
|
||||
string auth_cluster_required = g_conf->auth_supported.empty() ?
|
||||
g_conf->auth_cluster_required : g_conf->auth_supported;
|
||||
string auth_service_required = g_conf->auth_supported.empty() ?
|
||||
g_conf->auth_service_required : g_conf->auth_supported;
|
||||
|
||||
return auth_service_required == "cephx" ||
|
||||
auth_cluster_required == "cephx";
|
||||
|
@ -6469,7 +6469,7 @@ done:
|
||||
}
|
||||
string out_str;
|
||||
err = reweight_by_utilization(oload, out_str, true,
|
||||
pools.size() ? &pools : NULL);
|
||||
pools.empty() ? NULL : &pools);
|
||||
if (err < 0) {
|
||||
ss << "FAILED reweight-by-pg: " << out_str;
|
||||
} else if (err == 0) {
|
||||
|
@ -1501,13 +1501,13 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_,
|
||||
osd_lock("OSD::osd_lock"),
|
||||
tick_timer(cct, osd_lock),
|
||||
authorize_handler_cluster_registry(new AuthAuthorizeHandlerRegistry(cct,
|
||||
cct->_conf->auth_supported.length() ?
|
||||
cct->_conf->auth_supported :
|
||||
cct->_conf->auth_cluster_required)),
|
||||
cct->_conf->auth_supported.empty() ?
|
||||
cct->_conf->auth_cluster_required :
|
||||
cct->_conf->auth_supported)),
|
||||
authorize_handler_service_registry(new AuthAuthorizeHandlerRegistry(cct,
|
||||
cct->_conf->auth_supported.length() ?
|
||||
cct->_conf->auth_supported :
|
||||
cct->_conf->auth_service_required)),
|
||||
cct->_conf->auth_supported.empty() ?
|
||||
cct->_conf->auth_service_required :
|
||||
cct->_conf->auth_supported)),
|
||||
cluster_messenger(internal_messenger),
|
||||
client_messenger(external_messenger),
|
||||
objecter_messenger(osdc_messenger),
|
||||
|
@ -563,9 +563,9 @@ void ReplicatedBackend::submit_transaction(
|
||||
reqid,
|
||||
trim_to,
|
||||
trim_rollback_to,
|
||||
t->get_temp_added().size() ? *(t->get_temp_added().begin()) : hobject_t(),
|
||||
t->get_temp_cleared().size() ?
|
||||
*(t->get_temp_cleared().begin()) :hobject_t(),
|
||||
t->get_temp_added().empty() ? hobject_t() : *(t->get_temp_added().begin()),
|
||||
t->get_temp_cleared().empty() ?
|
||||
hobject_t() : *(t->get_temp_cleared().begin()),
|
||||
log_entries,
|
||||
hset_history,
|
||||
&op,
|
||||
@ -573,7 +573,7 @@ void ReplicatedBackend::submit_transaction(
|
||||
|
||||
ObjectStore::Transaction local_t;
|
||||
local_t.set_use_tbl(op_t->get_use_tbl());
|
||||
if (t->get_temp_added().size()) {
|
||||
if (!(t->get_temp_added().empty())) {
|
||||
get_temp_coll(&local_t);
|
||||
add_temp_objs(t->get_temp_added());
|
||||
}
|
||||
|
@ -11273,8 +11273,8 @@ int ReplicatedPG::recover_backfill(
|
||||
dout(20) << *i << " is still in flight" << dendl;
|
||||
}
|
||||
|
||||
hobject_t next_backfill_to_complete = backfills_in_flight.size() ?
|
||||
*(backfills_in_flight.begin()) : backfill_pos;
|
||||
hobject_t next_backfill_to_complete = backfills_in_flight.empty() ?
|
||||
backfill_pos : *(backfills_in_flight.begin());
|
||||
hobject_t new_last_backfill = earliest_backfill();
|
||||
dout(10) << "starting new_last_backfill at " << new_last_backfill << dendl;
|
||||
for (map<hobject_t, pg_stat_t>::iterator i = pending_backfill_updates.begin();
|
||||
|
Loading…
Reference in New Issue
Block a user