NetBpfLoad: add more using statements
To shorten lines. Now: egrep 'base:' NetBpfLoad.cpp only finds the 'using' statements. Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I8b125c420c106e4b9c2af0a4fa2e4892a08bb152
This commit is contained in:
parent
3935d8b06c
commit
8a7672822d
1 changed files with 22 additions and 15 deletions
|
|
@ -60,7 +60,14 @@
|
|||
#include "bpf_map_def.h"
|
||||
|
||||
using android::base::EndsWith;
|
||||
using android::base::GetIntProperty;
|
||||
using android::base::GetProperty;
|
||||
using android::base::InitLogging;
|
||||
using android::base::KernelLogger;
|
||||
using android::base::SetProperty;
|
||||
using android::base::Split;
|
||||
using android::base::StartsWith;
|
||||
using android::base::Tokenize;
|
||||
using android::base::unique_fd;
|
||||
using std::ifstream;
|
||||
using std::ios;
|
||||
|
|
@ -112,7 +119,7 @@ struct Location {
|
|||
|
||||
// Returns the build type string (from ro.build.type).
|
||||
const std::string& getBuildType() {
|
||||
static std::string t = android::base::GetProperty("ro.build.type", "unknown");
|
||||
static std::string t = GetProperty("ro.build.type", "unknown");
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +191,7 @@ domain getDomainFromPinSubdir(const char s[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE]) {
|
|||
|
||||
static string pathToObjName(const string& path) {
|
||||
// extract everything after the final slash, ie. this is the filename 'foo@1.o' or 'bar.o'
|
||||
string filename = android::base::Split(path, "/").back();
|
||||
string filename = Split(path, "/").back();
|
||||
// strip off everything from the final period onwards (strip '.o' suffix), ie. 'foo@1' or 'bar'
|
||||
string name = filename.substr(0, filename.find_last_of('.'));
|
||||
// strip any potential @1 suffix, this will leave us with just 'foo' or 'bar'
|
||||
|
|
@ -1016,7 +1023,7 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const
|
|||
|
||||
if (!fd.ok()) {
|
||||
if (log_buf.size()) {
|
||||
vector<string> lines = android::base::Split(log_buf.data(), "\n");
|
||||
vector<string> lines = Split(log_buf.data(), "\n");
|
||||
|
||||
ALOGW("BPF_PROG_LOAD - BEGIN log_buf contents:");
|
||||
for (const auto& line : lines) ALOGW("%s", line.c_str());
|
||||
|
|
@ -1247,7 +1254,7 @@ static int createSysFsBpfSubDir(const char* const prefix) {
|
|||
// to include a newline to match 'echo "value" > /proc/sys/...foo' behaviour,
|
||||
// which is usually how kernel devs test the actual sysctl interfaces.
|
||||
static int writeProcSysFile(const char *filename, const char *value) {
|
||||
base::unique_fd fd(open(filename, O_WRONLY | O_CLOEXEC));
|
||||
unique_fd fd(open(filename, O_WRONLY | O_CLOEXEC));
|
||||
if (fd < 0) {
|
||||
const int err = errno;
|
||||
ALOGE("open('%s', O_WRONLY | O_CLOEXEC) -> %s", filename, strerror(err));
|
||||
|
|
@ -1324,7 +1331,7 @@ static int logTetheringApexVersion(void) {
|
|||
}
|
||||
|
||||
static bool hasGSM() {
|
||||
static string ph = base::GetProperty("gsm.current.phone-type", "");
|
||||
static string ph = GetProperty("gsm.current.phone-type", "");
|
||||
static bool gsm = (ph != "");
|
||||
static bool logged = false;
|
||||
if (!logged) {
|
||||
|
|
@ -1337,7 +1344,7 @@ static bool hasGSM() {
|
|||
static bool isTV() {
|
||||
if (hasGSM()) return false; // TVs don't do GSM
|
||||
|
||||
static string key = base::GetProperty("ro.oem.key1", "");
|
||||
static string key = GetProperty("ro.oem.key1", "");
|
||||
static bool tv = StartsWith(key, "ATV00");
|
||||
static bool logged = false;
|
||||
if (!logged) {
|
||||
|
|
@ -1348,10 +1355,10 @@ static bool isTV() {
|
|||
}
|
||||
|
||||
static bool isWear() {
|
||||
static string wearSdkStr = base::GetProperty("ro.cw_build.wear_sdk.version", "");
|
||||
static int wearSdkInt = base::GetIntProperty("ro.cw_build.wear_sdk.version", 0);
|
||||
static string buildChars = base::GetProperty("ro.build.characteristics", "");
|
||||
static vector<string> v = base::Tokenize(buildChars, ",");
|
||||
static string wearSdkStr = GetProperty("ro.cw_build.wear_sdk.version", "");
|
||||
static int wearSdkInt = GetIntProperty("ro.cw_build.wear_sdk.version", 0);
|
||||
static string buildChars = GetProperty("ro.build.characteristics", "");
|
||||
static vector<string> v = Tokenize(buildChars, ",");
|
||||
static bool watch = (std::find(v.begin(), v.end(), "watch") != v.end());
|
||||
static bool wear = (wearSdkInt > 0) || watch;
|
||||
static bool logged = false;
|
||||
|
|
@ -1368,7 +1375,7 @@ static int doLoad(char** argv, char * const envp[]) {
|
|||
|
||||
// Any released device will have codename REL instead of a 'real' codename.
|
||||
// For safety: default to 'REL' so we default to unreleased=false on failure.
|
||||
const bool unreleased = (base::GetProperty("ro.build.version.codename", "REL") != "REL");
|
||||
const bool unreleased = (GetProperty("ro.build.version.codename", "REL") != "REL");
|
||||
|
||||
// goog/main device_api_level is bumped *way* before aosp/main api level
|
||||
// (the latter only gets bumped during the push of goog/main to aosp/main)
|
||||
|
|
@ -1399,7 +1406,7 @@ static int doLoad(char** argv, char * const envp[]) {
|
|||
const bool isAtLeastV = (effective_api_level >= __ANDROID_API_V__);
|
||||
const bool isAtLeastW = (effective_api_level > __ANDROID_API_V__); // TODO: switch to W
|
||||
|
||||
const int first_api_level = base::GetIntProperty("ro.board.first_api_level", effective_api_level);
|
||||
const int first_api_level = GetIntProperty("ro.board.first_api_level", effective_api_level);
|
||||
|
||||
// last in U QPR2 beta1
|
||||
const bool has_platform_bpfloader_rc = exists("/system/etc/init/bpfloader.rc");
|
||||
|
|
@ -1620,7 +1627,7 @@ static int doLoad(char** argv, char * const envp[]) {
|
|||
|
||||
int key = 1;
|
||||
int value = 123;
|
||||
base::unique_fd map(
|
||||
unique_fd map(
|
||||
createMap(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), 2, 0));
|
||||
if (writeToMapEntry(map, &key, &value, BPF_ANY)) {
|
||||
ALOGE("Critical kernel bug - failure to write into index 1 of 2 element bpf map array.");
|
||||
|
|
@ -1652,11 +1659,11 @@ static int doLoad(char** argv, char * const envp[]) {
|
|||
} // namespace android
|
||||
|
||||
int main(int argc, char** argv, char * const envp[]) {
|
||||
android::base::InitLogging(argv, &android::base::KernelLogger);
|
||||
InitLogging(argv, &KernelLogger);
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "done")) {
|
||||
// we're being re-exec'ed from platform bpfloader to 'finalize' things
|
||||
if (!android::base::SetProperty("bpf.progs_loaded", "1")) {
|
||||
if (!SetProperty("bpf.progs_loaded", "1")) {
|
||||
ALOGE("Failed to set bpf.progs_loaded property to 1.");
|
||||
return 125;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue