From 762df4155e5c383292bbda1b830a15db422dbb6a Mon Sep 17 00:00:00 2001 From: yudechen Date: Thu, 10 Feb 2022 16:08:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9HasSystemCapability=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5param=E5=90=8D=E9=94=99=E8=AF=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic147a9b0d15ceb0e3a33146c2c429924c96e54bc Signed-off-by: yudechen --- interfaces/innerkits/syscap/init_syscap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/interfaces/innerkits/syscap/init_syscap.c b/interfaces/innerkits/syscap/init_syscap.c index 72fbb622..399b7ccf 100644 --- a/interfaces/innerkits/syscap/init_syscap.c +++ b/interfaces/innerkits/syscap/init_syscap.c @@ -25,6 +25,7 @@ #define SYSCAP_MAX_SIZE 100 #define SYSCAP_PREFIX_NAME "SystemCapability" +#define CONST_SYSCAP_PREFIX_NAME "const.SystemCapability" bool HasSystemCapability(const char *cap) { @@ -32,12 +33,12 @@ bool HasSystemCapability(const char *cap) char paramValue[PARAM_VALUE_LEN_MAX] = { 0 }; unsigned int valueLen = PARAM_VALUE_LEN_MAX; - if (strncmp(SYSCAP_PREFIX_NAME, cap, sizeof(SYSCAP_PREFIX_NAME) - 1) != 0) { - if (strncpy_s(capName, sizeof(capName), cap, sizeof(capName) - 1) < 0) { - BEGET_LOGE("Failed strncpy_s err=%d", errno); + if (strncmp(SYSCAP_PREFIX_NAME, cap, sizeof(SYSCAP_PREFIX_NAME) - 1) == 0) { + if (snprintf_s(capName, SYSCAP_MAX_SIZE, SYSCAP_MAX_SIZE - 1, "const.%s", cap) == -1) { + BEGET_LOGE("Failed snprintf_s err=%d", errno); return false; } - } else if (snprintf_s(capName, SYSCAP_MAX_SIZE, SYSCAP_MAX_SIZE - 1, SYSCAP_PREFIX_NAME".%s", cap) == -1) { + } else if (snprintf_s(capName, SYSCAP_MAX_SIZE, SYSCAP_MAX_SIZE - 1, CONST_SYSCAP_PREFIX_NAME".%s", cap) == -1) { BEGET_LOGE("Failed snprintf_s err=%d", errno); return false; } -- GitLab