Enable C++11 support.
This CL catches the sailing C++11 train by enabling C++11 support in the
gyp file and migrating code to use range-based for loops and braced
initializer lists.
BUG=None
TEST=Tested the following:
1. `USE='gdmwimax wimax' FEATURES=test emerge-$BOARD platform2`
2. Run platform_WiMaxPresent and platform_WiMaxSmoke test.
Change-Id: I7613bd7ae7b74120caa8d4c321e5600371cb0a5b
Reviewed-on: https://chromium-review.googlesource.com/196388
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/device_dbus_adaptor.cc b/device_dbus_adaptor.cc
index b2d9656..1f09b09 100644
--- a/device_dbus_adaptor.cc
+++ b/device_dbus_adaptor.cc
@@ -30,13 +30,10 @@
CHECK(dictionary_value);
dictionary_value->Clear();
- for (map<string, DBus::Variant>::const_iterator
- dictionary_it = dbus_dictionary.begin();
- dictionary_it != dbus_dictionary.end();
- ++dictionary_it) {
- const string &key = dictionary_it->first;
- const DBus::Signature &value_signature = dictionary_it->second.signature();
- DBus::MessageIter value_reader = dictionary_it->second.reader();
+ for (const auto &key_value : dbus_dictionary) {
+ const string &key = key_value.first;
+ const DBus::Signature &value_signature = key_value.second.signature();
+ DBus::MessageIter value_reader = key_value.second.reader();
if (value_signature == DBus::type<string>::sig()) {
dictionary_value->SetString(key, value_reader.get_string());
} else if (value_signature == DBus::type<bool>::sig()) {
@@ -142,10 +139,8 @@
void DeviceDBusAdaptor::UpdateNetworks() {
vector<DBus::Path> network_paths;
- const NetworkMap &networks = device_->networks();
- for (NetworkMap::const_iterator network_iterator = networks.begin();
- network_iterator != networks.end(); ++network_iterator) {
- network_paths.push_back(network_iterator->second->dbus_object_path());
+ for (const auto &network : device_->networks()) {
+ network_paths.push_back(network.second->dbus_object_path());
}
Networks = network_paths;
NetworksChanged(network_paths);
@@ -166,11 +161,9 @@
NetworkRefPtr DeviceDBusAdaptor::FindNetworkByDBusObjectPath(
const DBus::Path &network_object_path) const {
- const NetworkMap &networks = device_->networks();
- for (NetworkMap::const_iterator network_iterator = networks.begin();
- network_iterator != networks.end(); ++network_iterator) {
- if (network_iterator->second->dbus_object_path() == network_object_path)
- return network_iterator->second;
+ for (const auto &network : device_->networks()) {
+ if (network.second->dbus_object_path() == network_object_path)
+ return network.second;
}
return NULL;
}
diff --git a/gdm_driver.cc b/gdm_driver.cc
index f40c019..584fcdf 100644
--- a/gdm_driver.cc
+++ b/gdm_driver.cc
@@ -290,15 +290,11 @@
device->SetBaseStationId(base_station_id);
device->set_frequency(rf_info.Frequency);
- vector<int> cinr;
- cinr.push_back(Network::DecodeCINR(rf_info.CINR));
- cinr.push_back(Network::DecodeCINR(rf_info.CINR2));
- device->set_cinr(cinr);
+ device->set_cinr({Network::DecodeCINR(rf_info.CINR),
+ Network::DecodeCINR(rf_info.CINR2)});
- vector<int> rssi;
- rssi.push_back(Network::DecodeRSSI(rf_info.RSSI));
- rssi.push_back(Network::DecodeRSSI(rf_info.RSSI2));
- device->set_rssi(rssi);
+ device->set_rssi({Network::DecodeRSSI(rf_info.RSSI),
+ Network::DecodeRSSI(rf_info.RSSI2)});
device->UpdateRFInfo();
return true;
diff --git a/manager_dbus_adaptor.cc b/manager_dbus_adaptor.cc
index fd6ef98..edbedcd 100644
--- a/manager_dbus_adaptor.cc
+++ b/manager_dbus_adaptor.cc
@@ -30,9 +30,8 @@
void ManagerDBusAdaptor::UpdateDevices() {
vector<DBus::Path> device_paths;
const vector<Device *> &devices = manager_->devices();
- for (vector<Device *>::const_iterator device_iterator = devices.begin();
- device_iterator != devices.end(); ++device_iterator) {
- device_paths.push_back((*device_iterator)->dbus_object_path());
+ for (const auto &device : devices) {
+ device_paths.push_back(device->dbus_object_path());
}
Devices = device_paths;
DevicesChanged(device_paths);
diff --git a/utility.h b/utility.h
index 3bf5852..4d1ae4a 100644
--- a/utility.h
+++ b/utility.h
@@ -15,9 +15,8 @@
template <typename KeyType, typename ValueType>
std::set<KeyType> GetKeysOfMap(const std::map<KeyType, ValueType> &m) {
std::set<KeyType> keys;
- typename std::map<KeyType, ValueType>::const_iterator map_iterator;
- for (map_iterator = m.begin(); map_iterator != m.end(); ++map_iterator) {
- keys.insert(map_iterator->first);
+ for (const auto &key_value : m) {
+ keys.insert(key_value.first);
}
return keys;
}
@@ -27,10 +26,8 @@
const std::set<KeyType> &keys_to_remove) {
CHECK(m);
- typename std::set<KeyType>::const_iterator key_iterator;
- for (key_iterator = keys_to_remove.begin();
- key_iterator != keys_to_remove.end(); ++key_iterator) {
- m->erase(*key_iterator);
+ for (const auto &key : keys_to_remove) {
+ m->erase(key);
}
}
diff --git a/wimax_manager.gyp b/wimax_manager.gyp
index 9e6355d..dc4182b 100644
--- a/wimax_manager.gyp
+++ b/wimax_manager.gyp
@@ -14,6 +14,9 @@
'protobuf',
],
},
+ 'cflags_cc': [
+ '-std=gnu++11',
+ ],
},
'targets': [
{