提交 65125772 编写于 作者: M Mupceet

fix: charing错误

Signed-off-by: NMupceet <laiguizhong@huawei.com>
上级 4006a67d
......@@ -49,6 +49,7 @@ static int ParseGroupCfgItem(cJSON *root, int type, const char *itemName)
{
int itemNumber = 0;
cJSON *json = GetArrayItem(root, &itemNumber, itemName);
INIT_LOGI("ParseGroupCfgItem %s itemNumber %d", itemName, itemNumber);
if (json == NULL) {
return 0;
}
......@@ -189,11 +190,9 @@ void InitServiceSpace(void)
g_initWorkspace.groupModeStr, sizeof(g_initWorkspace.groupModeStr));
if (ret != 0) {
INIT_LOGE("%s", "Failed to get boot group");
#ifdef INIT_TEST
if (GetBootModeFromMisc() == GROUP_CHARING) {
strcpy_s(g_initWorkspace.groupModeStr, sizeof(g_initWorkspace.groupModeStr), "device.charing.group");
}
#endif
}
free(data);
}
......
......@@ -752,7 +752,7 @@ WorkSpace *GetNextWorkSpace(WorkSpace *curr)
int SystemReadParam(const char *name, char *value, unsigned int *len)
{
PARAM_WORKSPACE_CHECK(&g_paramWorkSpace, return -1, "Invalid space");
PARAM_CHECK(name != NULL && len != NULL, return -1, "The name or value is null");
PARAM_CHECK(name != NULL && len != NULL && strlen(name) > 0, return -1, "The name or value is null");
ParamHandle handle = 0;
int ret = ReadParamWithCheck(name, DAC_READ, &handle);
if (ret != PARAM_CODE_NOT_FOUND && ret != 0 && ret != PARAM_CODE_NODE_EXIST) {
......
......@@ -32,14 +32,7 @@
#include "service_control.h"
#define MAX_BUF_SIZE 1024
#define MAX_DATA_BUFFER 2048
#define MAX_SMALL_BUFFER 512
#ifdef STARTUP_UT
#define LOG_FILE_NAME "/media/sf_ubuntu/test/log.txt"
#else
#define LOG_FILE_NAME "/data/startup_log.txt"
#endif
#define MAX_SMALL_BUFFER 3096
#define MAX_JSON_FILE_LEN 102400 // max init.cfg size 100KB
#define CONVERT_MICROSEC_TO_SEC(x) ((x) / 1000 / 1000.0)
......@@ -131,7 +124,7 @@ char *ReadFileData(const char *fileName)
INIT_ERROR_CHECK(buffer != NULL, close(fd);
return NULL, "Failed to allocate memory for %s", fileName);
ssize_t readLen = read(fd, buffer, MAX_SMALL_BUFFER - 1);
INIT_ERROR_CHECK(readLen > 0, close(fd);
INIT_ERROR_CHECK((readLen > 0) && (readLen < (MAX_SMALL_BUFFER - 1)), close(fd);
free(buffer);
return NULL, "Failed to read data for %s", fileName);
buffer[readLen] = '\0';
......@@ -373,11 +366,11 @@ int ReadFileInDir(const char *dirPath, const char *includeExt,
return -1, "Failed to malloc for %s", dirPath);
struct dirent *dp;
uint32_t count = 0;
while ((dp = readdir(pDir)) != NULL) {
if (dp->d_type == DT_DIR) {
continue;
}
INIT_LOGV("ReadFileInDir %s", dp->d_name);
if (includeExt != NULL) {
char *tmp = strstr(dp->d_name, includeExt);
if (tmp == NULL) {
......@@ -394,9 +387,11 @@ int ReadFileInDir(const char *dirPath, const char *includeExt,
}
struct stat st;
if (stat(fileName, &st) == 0) {
count++;
processFile(fileName, context);
}
}
INIT_LOGI("ReadFileInDir dirPath %s %d", dirPath, count);
free(fileName);
closedir(pDir);
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册