crushtester: fix uninit var

CID 717197: Uninitialized scalar variable (UNINIT)
At (35): Using uninitialized value "only_osd_affected".

Fix some whitespace too.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-09-28 07:00:12 -07:00
parent b7cf6030ae
commit 687d6d58f1

View File

@ -152,8 +152,8 @@ bool CrushTester::check_valid_placement(int ruleno, vector<int> in, const vector
map<string,string> seen_devices;
// first do the easy check that all devices are "up"
for (vector<int>::iterator it = in.begin(); it != in.end(); it++){
if (weight[(*it)] == 0){
for (vector<int>::iterator it = in.begin(); it != in.end(); it++) {
if (weight[(*it)] == 0) {
valid_placement = false;
break;
} else if (weight[(*it)] > 0) {
@ -173,8 +173,8 @@ bool CrushTester::check_valid_placement(int ruleno, vector<int> in, const vector
// get the smallest type id, and name
int min_map_type = crush.get_num_type_names();
for (map<int,string>::iterator it = crush.type_map.begin(); it != crush.type_map.end(); it++ ){
if ( (*it).first < min_map_type ){
for (map<int,string>::iterator it = crush.type_map.begin(); it != crush.type_map.end(); it++ ) {
if ( (*it).first < min_map_type ) {
min_map_type = (*it).first;
}
}
@ -182,37 +182,37 @@ bool CrushTester::check_valid_placement(int ruleno, vector<int> in, const vector
string min_map_type_name = crush.type_map[min_map_type];
// get the types of devices affected by RULENO
for (int i = 0; i < rule_size; i++){
for (int i = 0; i < rule_size; i++) {
// get what operation is done by the current step
int rule_operation = crush.get_rule_op(ruleno, i);
// if the operation specifies choosing a device type, store it
if (rule_operation >= 2 && rule_operation != 4){
if (rule_operation >= 2 && rule_operation != 4) {
int affected_type = crush.get_rule_arg2(ruleno,i);
affected_types.push_back( crush.get_type_name(affected_type));
}
}
// find in if we are only dealing with osd's
bool only_osd_affected;
if (affected_types.size() == 1){
if ( (affected_types.back() == min_map_type_name) && (min_map_type_name == "osd") ){
bool only_osd_affected = false;
if (affected_types.size() == 1) {
if ((affected_types.back() == min_map_type_name) && (min_map_type_name == "osd")) {
only_osd_affected = true;
}
}
// check that we don't have any duplicate id's
for (vector<int>::iterator it = included_devices.begin(); it != included_devices.end(); it++){
for (vector<int>::iterator it = included_devices.begin(); it != included_devices.end(); it++) {
int num_copies = count(included_devices.begin(), included_devices.end(), (*it) );
if (num_copies > 1){
if (num_copies > 1) {
valid_placement = false;
}
}
// if we have more than just osd's affected we need to do a lot more work
if (!only_osd_affected){
if (!only_osd_affected) {
// loop through the devices that are "in/up"
for (vector<int>::iterator it = included_devices.begin(); it != included_devices.end(); it++){
for (vector<int>::iterator it = included_devices.begin(); it != included_devices.end(); it++) {
if (valid_placement == false)
break;
@ -220,13 +220,13 @@ bool CrushTester::check_valid_placement(int ruleno, vector<int> in, const vector
map<string,string> device_location_hierarchy = crush.get_full_location(*it);
// loop over the types affected by RULENO looking for duplicate bucket assignments
for (vector<string>::iterator t = affected_types.begin(); t != affected_types.end(); t++){
if (seen_devices.count( device_location_hierarchy[*t] ) ){
for (vector<string>::iterator t = affected_types.begin(); t != affected_types.end(); t++) {
if (seen_devices.count( device_location_hierarchy[*t])) {
valid_placement = false;
break;
} else {
// store the devices we have seen in the form of (device name, device type)
seen_devices[ device_location_hierarchy[*t] ] = *t ;
seen_devices[ device_location_hierarchy[*t] ] = *t;
}
}
}