1
0
Fork 0
android_external_drm_hwcomp.../utils/properties.h
Roman Stratiienko d518a0594a drm_hwcomposer: CI: Initial build and clang-tidy checks
Build android-agnostic code in linux environment.
Enable static code analysis using clang-tidy.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-03-03 12:14:13 +02:00

28 lines
No EOL
541 B
C++

#ifndef UTILS_PROPERTIES_H_
#define UTILS_PROPERTIES_H_
#ifdef ANDROID
#include <cutils/properties.h>
#else
#include <cstdio>
#include <cstdlib>
#include <cstring>
// NOLINTNEXTLINE(readability-identifier-naming)
constexpr int PROPERTY_VALUE_MAX = 92;
auto inline property_get(const char *name, char *value,
const char *default_value) -> int {
char *prop = std::getenv(name);
if (prop == nullptr) {
snprintf(value, PROPERTY_VALUE_MAX, "%s", default_value);
}
return strlen(value);
}
#endif
#endif