liblog: log_time add explicit to some constructors.

Add explicit to constructors, to prevent implicit conversions.

Test: compile
Bug: 37378309
Change-Id: I3f9f8d561e84c492eafa6528db7c238da072dad8
This commit is contained in:
Mark Salyzyn 2017-04-17 12:37:11 -07:00
parent 3614a0c5d4
commit d87d47f7dd
1 changed files with 7 additions and 8 deletions

View File

@ -41,13 +41,12 @@ struct log_time {
static const uint32_t tv_sec_max = 0xFFFFFFFFUL;
static const uint32_t tv_nsec_max = 999999999UL;
log_time(const timespec& T) {
tv_sec = static_cast<uint32_t>(T.tv_sec);
tv_nsec = static_cast<uint32_t>(T.tv_nsec);
log_time(const timespec& T)
: tv_sec(static_cast<uint32_t>(T.tv_sec)),
tv_nsec(static_cast<uint32_t>(T.tv_nsec)) {
}
log_time(uint32_t sec, uint32_t nsec) {
tv_sec = sec;
tv_nsec = nsec;
explicit log_time(uint32_t sec, uint32_t nsec = 0)
: tv_sec(sec), tv_nsec(nsec) {
}
#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
#define __struct_log_time_private_defined
@ -56,14 +55,14 @@ struct log_time {
log_time() {
}
#ifdef __linux__
log_time(clockid_t id) {
explicit log_time(clockid_t id) {
timespec T;
clock_gettime(id, &T);
tv_sec = static_cast<uint32_t>(T.tv_sec);
tv_nsec = static_cast<uint32_t>(T.tv_nsec);
}
#endif
log_time(const char* T) {
explicit log_time(const char* T) {
const uint8_t* c = reinterpret_cast<const uint8_t*>(T);
tv_sec = c[0] | (static_cast<uint32_t>(c[1]) << 8) |
(static_cast<uint32_t>(c[2]) << 16) |