diff --git a/frameworks/libhilog/vsnprintf/output_p.inl b/frameworks/libhilog/vsnprintf/output_p.inl index e54242479749830adeefff90f21a843c33ddfdcc..eb6ba050ff49a53068b7cc58aa54b2f986aa133e 100644 --- a/frameworks/libhilog/vsnprintf/output_p.inl +++ b/frameworks/libhilog/vsnprintf/output_p.inl @@ -156,8 +156,8 @@ static void SecWritePrivateStr(SecPrintfStream *stream, int *pCharsOut) int ii = 0; #define PRIVATE_STR_LEN (9) #ifndef SECUREC_FOR_WCHAR - static const char privacyString[] = ""; - const char *pPrivStr = privacyString; + static const char PRIVACY_STRING[] = ""; + const char *pPrivStr = PRIVACY_STRING; if (SECUREC_IS_REST_BUF_ENOUGH(PRIVATE_STR_LEN)) { SECUREC_SAFE_WRITE_STR(pPrivStr, PRIVATE_STR_LEN, stream, pCharsOut); @@ -253,10 +253,11 @@ static int SecDecodeSize(SecChar ch, SecFormatAttr *attr, const SecChar **format break; case SECUREC_CHAR('h'): - if (**format == SECUREC_CHAR('h')) + if (**format == SECUREC_CHAR('h')) { attr->flags |= SECUREC_FLAG_CHAR; /* char */ - else + } else { attr->flags |= SECUREC_FLAG_SHORT; /* short int */ + } break; case SECUREC_CHAR('w'): @@ -428,7 +429,7 @@ int SecOutputPS(SecPrintfStream *stream, int priv, const char *cformat, va_list SecChar prefix[2] = { 0 }; SecChar ch; /* currently read character */ - static const unsigned char fmtCharTable[337] = { + static const unsigned char FMT_CHAR_TABLE[337] = { /* type 0: nospecial meaning; 1: '%'; 2: '.' @@ -494,7 +495,7 @@ int SecOutputPS(SecPrintfStream *stream, int priv, const char *cformat, va_list /* remove format != NULL */ while ((ch = *format++) != SECUREC_CHAR('\0') && charsOut >= 0) { laststate = state; - state = SECUREC_DECODE_STATE(ch, fmtCharTable, laststate); + state = SECUREC_DECODE_STATE(ch, FMT_CHAR_TABLE, laststate); switch (state) { case STAT_NORMAL: @@ -538,7 +539,7 @@ NORMAL_CHAR: isPrivacy = 1; } - if (0 == priv) { + if (priv == 0) { isPrivacy = 0; } @@ -736,7 +737,7 @@ NORMAL_CHAR: char *fltFmtHeap = NULL; /* to clear warning */ /* must meet '%' (normal format) or '}'(with{private} or{public} format)*/ - while (SECUREC_CHAR('%') != *pFltFmt && SECUREC_CHAR('}') != *pFltFmt) { + while (*pFltFmt != SECUREC_CHAR('%') && *pFltFmt != SECUREC_CHAR('}')) { --pFltFmt; } fltFmtStrLen = (int)((format - pFltFmt) + 1); /* with ending terminator */ diff --git a/frameworks/libhilog/vsnprintf/vsnprintf_s_p.c b/frameworks/libhilog/vsnprintf/vsnprintf_s_p.c index 073b976291beeae568aa578d26d765997dba7408..080037b7132bacc184b08c53d326ff141641ffa3 100644 --- a/frameworks/libhilog/vsnprintf/vsnprintf_s_p.c +++ b/frameworks/libhilog/vsnprintf/vsnprintf_s_p.c @@ -34,15 +34,15 @@ #if defined(_DEBUG) || defined(DEBUG) #if defined(SECUREC_ERROR_HANDLER_BY_ASSERT) - #define SECUREC_ERROR_INVALID_PARAMTER(msg) assert( msg "invalid argument" == NULL) - #define SECUREC_ERROR_INVALID_RANGE(msg) assert( msg "invalid dest buffer size" == NULL) + #define SECUREC_ERROR_INVALID_PARAMTER(msg) assert(msg "invalid argument" == NULL) + #define SECUREC_ERROR_INVALID_RANGE(msg) assert(msg "invalid dest buffer size" == NULL) #elif defined(SECUREC_ERROR_HANDLER_BY_PRINTF) #if SECUREC_IN_KERNEL - #define SECUREC_ERROR_INVALID_PARAMTER(msg) printk( "%s invalid argument\n",msg) - #define SECUREC_ERROR_INVALID_RANGE(msg) printk( "%s invalid dest buffer size\n", msg) + #define SECUREC_ERROR_INVALID_PARAMTER(msg) printk("%s invalid argument\n", msg) + #define SECUREC_ERROR_INVALID_RANGE(msg) printk("%s invalid dest buffer size\n", msg) #else - #define SECUREC_ERROR_INVALID_PARAMTER(msg) printf( "%s invalid argument\n",msg) - #define SECUREC_ERROR_INVALID_RANGE(msg) printf( "%s invalid dest buffer size\n", msg) + #define SECUREC_ERROR_INVALID_PARAMTER(msg) printf("%s invalid argument\n", msg) + #define SECUREC_ERROR_INVALID_RANGE(msg) printf("%s invalid dest buffer size\n", msg) #endif #elif defined(SECUREC_ERROR_HANDLER_BY_FILE_LOG) #define SECUREC_ERROR_INVALID_PARAMTER(msg) LogSecureCRuntimeError(msg " EINVAL\n") @@ -140,7 +140,8 @@ typedef enum { #else #define SECUREC_MALLOC(x) (NULL) -#define SECUREC_FREE(x) { printf("Malloc is not allowed, so free should not be possible to execute!"); exit(EXIT_FAILURE); } +#define SECUREC_FREE(x) { printf("Malloc is not allowed, so free should not be possible to execute!"); \ + exit(EXIT_FAILURE); } #endif #if (defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)) || defined(__ARMCC_VERSION) diff --git a/interfaces/native/kits/include/hilog/log.h b/interfaces/native/kits/include/hilog/log.h index c07f632e069f8a0775ef4288c5aa54a29b4e3aa9..7452137c280d212fc271cca2f31466f0dc11bd6f 100644 --- a/interfaces/native/kits/include/hilog/log.h +++ b/interfaces/native/kits/include/hilog/log.h @@ -259,7 +259,7 @@ bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level); */ typedef void (*LogCallback)(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, const char *msg); - + /** * @brief Set the user-defined log processing function. * diff --git a/interfaces/rust/src/lib.rs b/interfaces/rust/src/lib.rs index d4f8793cd576ec385d97371c81b4a5f8ba7725d3..143a49ff9647c8cc09a02d412f65f7e6a5371c67 100644 --- a/interfaces/rust/src/lib.rs +++ b/interfaces/rust/src/lib.rs @@ -1,18 +1,20 @@ -// Copyright (C) 2022 Huawei Device Co., Ltd. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ //! hilog dylib_crate for Rust. -use std::ffi::c_char; +use std::ffi::{c_char}; #[macro_use] mod macros; diff --git a/services/hilogd/log_buffer.cpp b/services/hilogd/log_buffer.cpp index 7056aff1ac00a9a38b24d506b0b5b6bae385bea8..5ac81547bd091b20d0c3249d1e9eca54832977dd 100644 --- a/services/hilogd/log_buffer.cpp +++ b/services/hilogd/log_buffer.cpp @@ -151,8 +151,7 @@ static std::string WildcardToRegex(const std::string& wildcard) if (std::strchr(WILDCARDS, c) != nullptr) { size_t index = std::strchr(WILDCARDS, c) - WILDCARDS; result += REPLACEMENT_S[index]; - } - else { + } else { result += c; } } @@ -178,8 +177,7 @@ static bool LogMatchFilter(const LogFilter& filter, const HilogData& logData) (0xd0123ff & 0xffffff00 == 0xd012345 & 0xffffff00) */ bool match = false; for (i = 0; i < filter.domainCount; i++) { - if ((logData.domain == filter.domains[i]) - || ((static_cast(filter.domains[i]) == LOW_BYTE) + if ((logData.domain == filter.domains[i]) || ((static_cast(filter.domains[i]) == LOW_BYTE) && ((logData.domain & LOW_BYTE_REVERSE) == (filter.domains[i] & LOW_BYTE_REVERSE)))) { match = true; break; diff --git a/services/hilogd/main.cpp b/services/hilogd/main.cpp index f966871b514f5e4a287be09a9c7ff66d7bcd99ee..d45938124844249fb75511fbb19ed875b1f19a67 100644 --- a/services/hilogd/main.cpp +++ b/services/hilogd/main.cpp @@ -169,7 +169,7 @@ int HilogdEntry() } HilogBuffer kmsgBuffer(false); - ffrt::submit([&hilogBuffer,&kmsgBuffer]() { + ffrt::submit([&hilogBuffer, &kmsgBuffer]() { int ret = WaitingToDo(WAITING_DATA_MS, HILOG_FILE_DIR, [](const string &path) { struct stat s; if (stat(path.c_str(), &s) != -1) {