diff --git a/BUILD.gn b/BUILD.gn index da7c411..51dd893 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -135,6 +135,7 @@ build_ext_component("generate_pcid") { ohos_prebuilt_etc("PCID.sc") { deps = [ ":generate_pcid" ] source = "$root_out_dir/PCID.sc" + subsystem_name = "developtools" part_name = "syscap_codec" } diff --git a/bundle.json b/bundle.json index 6190d87..c807cc6 100644 --- a/bundle.json +++ b/bundle.json @@ -15,6 +15,8 @@ "syscap": [ "SystemCapability.Developtools.Syscap" ], "feature": [ "syscap_codec_config_path" ], "adapted_system_type": [ "small", "standard" ], + "rom": "0", + "ram": "0", "deps": { "components": [ "napi", diff --git a/config.gni b/config.gni index cbdf88c..eb75e6b 100644 --- a/config.gni +++ b/config.gni @@ -9,7 +9,7 @@ # 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. +# limitations under the License. declare_args() { syscap_codec_config_path = diff --git a/include/codec_config/syscap_define.h b/include/codec_config/syscap_define.h index 3e05a78..96cfe9e 100644 --- a/include/codec_config/syscap_define.h +++ b/include/codec_config/syscap_define.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef _SYSCAP_DEFINE_H -#define _SYSCAP_DEFINE_H +#ifndef SYSCAP_DEFINE_H +#define SYSCAP_DEFINE_H #include @@ -556,4 +556,4 @@ const static SyscapWithNum g_arraySyscap[] = { } #endif /* __cplusplus */ #endif /* __cplusplus */ -#endif // _SYSCAP_DEFINE_H +#endif // SYSCAP_DEFINE_H diff --git a/include/create_pcid.h b/include/create_pcid.h index 65f5d85..f2cf99c 100644 --- a/include/create_pcid.h +++ b/include/create_pcid.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef _CREATE_PCID_H -#define _CREATE_PCID_H +#ifndef CREATE_PCID_H +#define CREATE_PCID_H #include @@ -29,7 +29,7 @@ typedef struct ProductCompatibilityID { uint8_t osSyscap[OS_SYSCAP_BYTES]; } PCIDMain; -typedef struct pcidHeader { +typedef struct PcidHeader { uint16_t apiVersion : 15; uint16_t apiVersionType : 1; uint16_t systemType : 3; diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index bf8372d..79cd86a 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -57,7 +57,7 @@ typedef struct ProductCompatibilityID { uint8_t osSyscap[OS_SYSCAP_BYTES]; } PCIDMain; -static const char *pcidPath = "/system/etc/PCID.sc"; +static const char *g_pcidPath = "/system/etc/PCID.sc"; static void FreeContextBuffer(char *contextBuffer) { @@ -131,7 +131,7 @@ bool EncodeOsSyscap(char *output, int len) return false; } - ret = GetFileContext(pcidPath, &contextBuffer, &bufferLen); + ret = GetFileContext(g_pcidPath, &contextBuffer, &bufferLen); if (ret != 0) { PRINT_ERR("GetFileContext failed, input file : /system/etc/PCID.sc\n"); return false; @@ -155,7 +155,7 @@ bool EncodePrivateSyscap(char **output, int *outputLen) char *outputStr = NULL; uint32_t bufferLen; - ret = GetFileContext(pcidPath, &contextBuffer, &bufferLen); + ret = GetFileContext(g_pcidPath, &contextBuffer, &bufferLen); if (ret != 0) { PRINT_ERR("GetFileContext failed, input file : /system/etc/PCID.sc\n"); return false; diff --git a/interfaces/inner_api/syscap_interface.h b/interfaces/inner_api/syscap_interface.h index be48c6e..a26bfae 100644 --- a/interfaces/inner_api/syscap_interface.h +++ b/interfaces/inner_api/syscap_interface.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef _SYSCAP_INTERFACE_H -#define _SYSCAP_INTERFACE_H +#ifndef SYSCAP_INTERFACE_H +#define SYSCAP_INTERFACE_H #include #include @@ -76,4 +76,4 @@ int32_t FreeCompareError(CompareError *result); #endif /* __cplusplus */ #endif /* __cplusplus */ -#endif /* _SYSCAP_INTERFACE_H */ \ No newline at end of file +#endif /* SYSCAP_INTERFACE_H */ \ No newline at end of file diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 858f934..8788c1b 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -55,7 +55,7 @@ struct SystemCapabilityAsyncContext { int status = 0; }; -static char* getSystemCapability() +static char* GetSystemCapability() { bool retBool; int retError, priOutputLen, priCapArrayCnt, sumLen; @@ -179,7 +179,7 @@ napi_value QuerySystemCapability(napi_env env, napi_callback_info info) env, nullptr, resource, [](napi_env env, void* data) { SystemCapabilityAsyncContext *asyncContext = (SystemCapabilityAsyncContext *)data; - char *syscapStr = getSystemCapability(); + char *syscapStr = GetSystemCapability(); if (syscapStr != nullptr) { asyncContext->value = syscapStr; asyncContext->status = 0; @@ -248,7 +248,7 @@ static napi_module g_systemCapabilityModule = { /* * Module register function */ -extern "C" __attribute__((constructor)) void systemCapabilityRegisterModule(void) +extern "C" __attribute__((constructor)) void SystemCapabilityRegisterModule(void) { napi_module_register(&g_systemCapabilityModule); } diff --git a/napi/query_syscap.js b/napi/query_syscap.js index 6ea4023..2edc9a7 100644 --- a/napi/query_syscap.js +++ b/napi/query_syscap.js @@ -1,7 +1,22 @@ +/* + * 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. + */ + // 首先需要通过requireInternal函数加载本模块 const systemCapability = requireInternal('systemCapability'); // 这里定义了模块对外暴露的所有api export default { - querySystemCapabilities: systemCapability.querySystemCapabilities -} \ No newline at end of file + querySystemCapabilities: systemCapability.querySystemCapabilities +}; \ No newline at end of file diff --git a/src/endian_internal.c b/src/endian_internal.c index 5da4f70..9788509 100644 --- a/src/endian_internal.c +++ b/src/endian_internal.c @@ -13,15 +13,16 @@ * limitations under the License. */ +#include #include "endian_internal.h" #define B_L_SWAP16(A) ((((uint16_t)(A) & 0xff00) >> 8) | (((uint16_t)(A) & 0x00ff) << 8)) #define B_L_SWAP32(A) ((((uint32_t)(A) & 0xff000000) >> 24) | (((uint32_t)(A) & 0x00ff0000) >> 8) | \ (((uint32_t)(A) & 0x0000ff00) << 8) | (((uint32_t)(A) & 0x000000ff) << 24)) -int32_t CheckEndian(void); +static bool CheckEndian(void); -int32_t CheckEndian(void) +static bool CheckEndian(void) { union { int32_t i; @@ -29,7 +30,7 @@ int32_t CheckEndian(void) } c; c.i = 0x12345678; - return (0x12 == c.s[0]); + return (c.s[0] == 0x12); } uint32_t HtonlInter(uint32_t h) diff --git a/src/endian_internal.h b/src/endian_internal.h index 8a2c201..aacd786 100644 --- a/src/endian_internal.h +++ b/src/endian_internal.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef _ENDIAN_INTERNAL_H -#define _ENDIAN_INTERNAL_H +#ifndef ENDIAN_INTERNAL_H +#define ENDIAN_INTERNAL_H #include @@ -35,4 +35,4 @@ extern uint16_t NtohsInter(uint16_t n); #endif /* __cplusplus */ #endif /* __cplusplus */ -#endif /* _ENDIAN_INTERNAL_H */ \ No newline at end of file +#endif /* ENDIAN_INTERNAL_H */ \ No newline at end of file diff --git a/src/main.c b/src/main.c index 6bf204e..8726d43 100644 --- a/src/main.c +++ b/src/main.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) char *outputpath = getcwd(curpath, sizeof(curpath)); while (1) { - static struct option long_options[] = { + static struct option longOptions[] = { {"help", no_argument, 0, 'h' }, {"version", no_argument, 0, 'v' }, {"RPCID", no_argument, 0, 'R' }, @@ -74,7 +74,7 @@ int main(int argc, char **argv) {0, 0, 0, 0 } }; - int32_t flag = getopt_long(argc, argv, "hvRPC:edsi:o:", long_options, &optIndex); + int32_t flag = getopt_long(argc, argv, "hvRPC:edsi:o:", longOptions, &optIndex); if (flag == -1) { break; } diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 01f1802..4697046 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -330,7 +330,7 @@ FREE_SYSCAP_OUT: return ret; } -static int32_t CheckRpcidFormat(char *inputFile, char **Buffer, uint32_t *Len) +static int32_t CheckRpcidFormat(char *inputFile, char **buffer, uint32_t *Len) { uint32_t bufferLen; uint16_t sysCaptype, sysCapLength; @@ -361,7 +361,7 @@ static int32_t CheckRpcidFormat(char *inputFile, char **Buffer, uint32_t *Len) return -1; } - *Buffer = contextBuffer; + *buffer = contextBuffer; *Len = bufferLen; return 0; } diff --git a/test/unittest/common/include/syscap_codec_test.h b/test/unittest/common/include/syscap_codec_test.h index 2410fa1..3cb35fa 100644 --- a/test/unittest/common/include/syscap_codec_test.h +++ b/test/unittest/common/include/syscap_codec_test.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef _SYSCAP_CODEC_TEST_H -#define _SYSCAP_CODEC_TEST_H +#ifndef SYSCAP_CODEC_TEST_H +#define SYSCAP_CODEC_TEST_H #ifdef __cplusplus #if __cplusplus @@ -38,4 +38,4 @@ public: #endif /* __cplusplus */ #endif /* __cplusplus */ -#endif /* _SYSCAP_CODEC_TEST_H */ \ No newline at end of file +#endif /* SYSCAP_CODEC_TEST_H */ \ No newline at end of file diff --git a/test/unittest/common/syscap_codec_test.cpp b/test/unittest/common/syscap_codec_test.cpp index 649d6fd..1d04b48 100644 --- a/test/unittest/common/syscap_codec_test.cpp +++ b/test/unittest/common/syscap_codec_test.cpp @@ -83,7 +83,8 @@ HWTEST_F(SyscapCodecTest, DecodeOsSyscap, TestSize.Level1) HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1) { char (*priOutput)[SINGLE_SYSCAP_LEN] = nullptr; - char priSyscap[] = "Device.syscap1GEDR,Device.syscap2WREGW,Vendor.syscap3RGD,Vendor.syscap4RWEG,Vendor.syscap5REWGWE,"; + char priSyscap[] = "Device.syscap1GEDR,Device.syscap2WREGW,Vendor." + "syscap3RGD,Vendor.syscap4RWEG,Vendor.syscap5REWGWE,"; int decodePriCnt; char expectPriOutput001[] = "SystemCapability.Device.syscap1GEDR"; char expectPriOutput002[] = "SystemCapability.Device.syscap2WREGW";