mirror of
https://gitee.com/openharmony/startup_init
synced 2024-11-24 00:30:12 +00:00
commit
30ee206752
@ -298,7 +298,7 @@ static void InitSandbox(sandbox_t *sandbox, const char *sandboxConfig, const cha
|
||||
return;
|
||||
}
|
||||
if (sandbox->isCreated) {
|
||||
BEGET_LOGE("Sandbox %s has created.");
|
||||
BEGET_LOGE("Sandbox %s has created.", name);
|
||||
return;
|
||||
}
|
||||
if (UnshareNamespace(CLONE_NEWNS) < 0) {
|
||||
|
@ -81,13 +81,13 @@ static void WriteLogoContent(int fd, const std::string &logoPath, uint32_t size)
|
||||
(void)fclose(rgbFile);
|
||||
return;
|
||||
}
|
||||
uint32_t ret = fread(buffer, 1, size, rgbFile);
|
||||
if (ret < 0) {
|
||||
(void)fread(buffer, 1, size, rgbFile);
|
||||
if (ferror(rgbFile)) {
|
||||
(void)fclose(rgbFile);
|
||||
free(buffer);
|
||||
return;
|
||||
}
|
||||
ret = write(fd, buffer, size);
|
||||
uint32_t ret = write(fd, buffer, size);
|
||||
if (ret != size) {
|
||||
(void)fclose(rgbFile);
|
||||
free(buffer);
|
||||
|
@ -573,7 +573,7 @@ static void ServiceTimerStartProcess(const TimerHandle handler, void *context)
|
||||
ServiceStopTimer(service);
|
||||
int ret = ServiceStart(service);
|
||||
if (ret != SERVICE_SUCCESS) {
|
||||
INIT_LOGE("Start service \' %s \' in timer failed");
|
||||
INIT_LOGE("Start service \' %s \' in timer failed", service->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,8 @@ static InitWorkspace g_initWorkspace = {0, 0, {0}, {0}, {0}};
|
||||
int GenerateHashCode(const char *key)
|
||||
{
|
||||
int code = 0;
|
||||
for (size_t i = 0; i < strlen(key); i++) {
|
||||
size_t keyLen = strlen(key);
|
||||
for (size_t i = 0; i < keyLen; i++) {
|
||||
code += key[i] - 'A';
|
||||
}
|
||||
return code;
|
||||
|
@ -142,7 +142,7 @@ static void HandlerGetFds(int sock, Service *service)
|
||||
}
|
||||
|
||||
if (service->fds == NULL || service->fdCount == 0) {
|
||||
INIT_LOGE("Service \' %s \' does not have any held fds");
|
||||
INIT_LOGE("Service \' %s \' does not have any held fds", service->name);
|
||||
errorInfo = "Service without any fds";
|
||||
}
|
||||
|
||||
|
@ -242,10 +242,12 @@ static int CheckParamPermissionWithSelinux(const ParamSecurityLabel *srcLabel, c
|
||||
{
|
||||
static void (*setSelinuxLogCallback)();
|
||||
static int (*setParamCheck)(const char *paraName, struct ucred *uc);
|
||||
g_selinuxHandle = dlopen("/system/lib/libparaperm_checker.z.so", RTLD_LAZY);
|
||||
if (g_selinuxHandle == NULL) {
|
||||
PARAM_LOGE("Failed to dlopen libparaperm_checker.z.so, %s\n", dlerror());
|
||||
return DAC_RESULT_FORBIDED;
|
||||
g_selinuxHandle = dlopen("/system/lib/libparaperm_checker.z.so", RTLD_LAZY);
|
||||
if (g_selinuxHandle == NULL) {
|
||||
PARAM_LOGE("Failed to dlopen libparaperm_checker.z.so, %s\n", dlerror());
|
||||
return DAC_RESULT_FORBIDED;
|
||||
}
|
||||
}
|
||||
if (setSelinuxLogCallback == NULL) {
|
||||
setSelinuxLogCallback = (void (*)())dlsym(g_selinuxHandle, "SetSelinuxLogCallback");
|
||||
|
@ -60,8 +60,9 @@ int GetSubStringInfo(const char *buff, uint32_t buffLen, char delimiter, SubStri
|
||||
{
|
||||
PARAM_CHECK(buff != NULL && info != NULL, return 0, "Invalid buff");
|
||||
size_t i = 0;
|
||||
size_t buffStrLen = strlen(buff);
|
||||
// 去掉开始的空格
|
||||
for (; i < strlen(buff); i++) {
|
||||
for (; i < buffStrLen; i++) {
|
||||
if (!isspace(buff[i])) {
|
||||
break;
|
||||
}
|
||||
|
@ -220,11 +220,12 @@ int ComputeCondition(LogicCalculator *calculator, const char *condition)
|
||||
PARAM_CHECK(calculator != NULL && condition != NULL, return -1, "Invalid calculator");
|
||||
uint32_t currIndex = 0;
|
||||
uint32_t start = 0;
|
||||
size_t conditionLen = strlen(condition);
|
||||
int noneOper = 1;
|
||||
CalculatorClear(calculator);
|
||||
LogicData data1 = {};
|
||||
LogicData data2 = {};
|
||||
while (currIndex < strlen(condition)) {
|
||||
while (currIndex < conditionLen) {
|
||||
if (condition[currIndex] == '|' || condition[currIndex] == '&') {
|
||||
noneOper = 0;
|
||||
int ret = CalculatorPop(calculator, (void*)&data2);
|
||||
@ -274,10 +275,11 @@ int ConvertInfixToPrefix(const char *condition, char *prefix, uint32_t prefixLen
|
||||
int ret;
|
||||
uint32_t curr = 0;
|
||||
uint32_t prefixIndex = 0;
|
||||
size_t conditionLen = strlen(condition);
|
||||
LogicCalculator calculator;
|
||||
CalculatorInit(&calculator, MAX_CALC_PARAM, 1, 0);
|
||||
|
||||
while (curr < strlen(condition)) {
|
||||
while (curr < conditionLen) {
|
||||
if (condition[curr] == ')') {
|
||||
CalculatorPopChar(&calculator, &e);
|
||||
while (e != '(') {
|
||||
|
@ -595,7 +595,8 @@ static int JobNodeGetNodeHasCode(const HashNode *node)
|
||||
{
|
||||
JobNode *jobNode = HASHMAP_ENTRY(node, JobNode, hashNode);
|
||||
int code = 0;
|
||||
for (size_t i = 0; i < strlen(jobNode->name); i++) {
|
||||
size_t nameLen = strlen(jobNode->name);
|
||||
for (size_t i = 0; i < nameLen; i++) {
|
||||
code += jobNode->name[i] - 'A';
|
||||
}
|
||||
return code;
|
||||
@ -605,7 +606,8 @@ static int JobNodeGetKeyHasCode(const void *key)
|
||||
{
|
||||
int code = 0;
|
||||
const char *buff = (char *)key;
|
||||
for (size_t i = 0; i < strlen(buff); i++) {
|
||||
size_t buffLen = strlen(buff);
|
||||
for (size_t i = 0; i < buffLen; i++) {
|
||||
code += buff[i] - 'A';
|
||||
}
|
||||
return code;
|
||||
|
@ -135,9 +135,9 @@ int32_t WatcherManagerKits::AddWatcher(const std::string &keyPrefix, ParameterCh
|
||||
watcher = new ParamWatcher(keyPrefix, callback, context);
|
||||
WATCHER_CHECK(watcher != nullptr, return -1, "Failed to create watcher for %s", keyPrefix.c_str());
|
||||
auto watcherManager = GetService();
|
||||
WATCHER_CHECK(watcherManager != nullptr, return -1, "Failed to get watcher manager");
|
||||
WATCHER_CHECK(watcherManager != nullptr, delete watcher; return -1, "Failed to get watcher manager");
|
||||
uint32_t watcherId = watcherManager->AddWatcher(keyPrefix, watcher);
|
||||
WATCHER_CHECK(watcherId != 0, return -1, "Failed to add watcher for %s", keyPrefix.c_str());
|
||||
WATCHER_CHECK(watcherId != 0, delete watcher; return -1, "Failed to add watcher for %s", keyPrefix.c_str());
|
||||
watcher->SetWatcherId(watcherId);
|
||||
SetParamWatcher(keyPrefix, watcher);
|
||||
return watcher->GetWatcherId();
|
||||
|
@ -58,7 +58,8 @@ uid_t DecodeUid(const char *name)
|
||||
{
|
||||
INIT_CHECK_RETURN_VALUE(name != NULL, -1);
|
||||
int digitFlag = 1;
|
||||
for (unsigned int i = 0; i < strlen(name); ++i) {
|
||||
size_t nameLen = strlen(name);
|
||||
for (unsigned int i = 0; i < nameLen; ++i) {
|
||||
if (isalpha(name[i])) {
|
||||
digitFlag = 0;
|
||||
break;
|
||||
|
@ -216,9 +216,6 @@ int ParseUeventConfig(char *buffer)
|
||||
|
||||
static void DoUeventConfigParse(char *buffer, size_t length)
|
||||
{
|
||||
if (length < 0) {
|
||||
return;
|
||||
}
|
||||
char **items = NULL;
|
||||
int count = -1;
|
||||
const int maxItemCount = DEFAULTITEMCOUNT;
|
||||
|
Loading…
Reference in New Issue
Block a user