提交 e8832dd0 编写于 作者: M Mupceet

fix bug for read misc

Signed-off-by: NMupceet <laiguizhong@huawei.com>
上级 466ea295
......@@ -79,6 +79,8 @@ int GetMapValue(const char *name, const InitArgInfo *infos, int argNum, int defV
const InitArgInfo *GetServieStatusMap(int *size);
uint32_t GetRandom(void);
void OpenConsole(void);
void TrimTail(char *str, char c);
char *TrimHead(char *str, char c);
INIT_LOCAL_API int StringToULL(const char *str, unsigned long long int *out);
INIT_LOCAL_API int StringToLL(const char *str, long long int *out);
......
......@@ -367,8 +367,8 @@ void SystemConfig(void)
options.preHook = InitPreHook;
options.postHook = InitPostHook;
HookMgrExecute(GetBootStageHookMgr(), INIT_GLOBAL_INIT, (void *)&timingStat, (void *)&options);
InitServiceSpace();
HookMgrExecute(GetBootStageHookMgr(), INIT_GLOBAL_INIT, (void *)&timingStat, (void *)&options);
HookMgrExecute(GetBootStageHookMgr(), INIT_PRE_PARAM_SERVICE, (void *)&timingStat, (void *)&options);
InitParamService();
......
......@@ -75,6 +75,7 @@ static Fstab* LoadFstabFromCommandLine(void)
bool isDone = false;
INIT_ERROR_CHECK(cmdline != NULL, return NULL, "Read from \'/proc/cmdline\' failed, err = %d", errno);
TrimTail(cmdline, '\n');
INIT_ERROR_CHECK((fstab = (Fstab *)calloc(1, sizeof(Fstab))) != NULL, return NULL,
"Allocate memory for FS table failed, err = %d", errno);
char *start = cmdline;
......
......@@ -287,7 +287,7 @@ char **SplitStringExt(char *buffer, const char *del, int *returnCount, int maxIt
INIT_LOGV("Too many items,expand size");
char **expand = (char **)(realloc(items, sizeof(char *) * itemCounts));
INIT_ERROR_CHECK(expand != NULL, FreeStringVector(items, count);
return NULL, "Failed to expand memory for uevent config parser");
return NULL, "Failed to expand memory");
items = expand;
}
size_t len = strlen(p);
......@@ -630,3 +630,23 @@ INIT_LOCAL_API int StringToULL(const char *str, unsigned long long int *out)
BEGET_CHECK(*end == '\0', return -1);
return 0;
}
void TrimTail(char *str, char c)
{
char *end = str + strlen(str) - 1;
while (end >= str && *end == c) {
*end = '\0';
end--;
}
}
char *TrimHead(char *str, char c)
{
char *head = str;
const char *end = str + strlen(str);
while (head < end && *head == c) {
*head = '\0';
head++;
}
return head;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册