Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
7525b21e
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
9 个月 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
7525b21e
编写于
7月 05, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
!894 隐藏libbegetutil不对外开放的符号,解决util类函数符号冲突
Merge pull request !894 from Mupceet/master_cc
上级
c06ab5ae
3d0cb750
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
153 addition
and
154 deletion
+153
-154
interfaces/innerkits/fs_manager/fstab.c
interfaces/innerkits/fs_manager/fstab.c
+1
-1
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+1
-1
interfaces/innerkits/hookmgr/hookmgr.c
interfaces/innerkits/hookmgr/hookmgr.c
+16
-17
interfaces/innerkits/modulemgr/modulemgr.c
interfaces/innerkits/modulemgr/modulemgr.c
+7
-7
interfaces/innerkits/reboot/init_reboot_innerkits.c
interfaces/innerkits/reboot/init_reboot_innerkits.c
+1
-1
services/include/init_hashmap.h
services/include/init_hashmap.h
+8
-8
services/include/list.h
services/include/list.h
+12
-12
services/init/init_group_manager.c
services/init/init_group_manager.c
+6
-6
services/init/standard/init_cmdexecutor.c
services/init/standard/init_cmdexecutor.c
+5
-5
services/loopevent/loop/le_loop.c
services/loopevent/loop/le_loop.c
+5
-5
services/loopevent/socket/le_socket.c
services/loopevent/socket/le_socket.c
+1
-1
services/loopevent/task/le_asynctask.c
services/loopevent/task/le_asynctask.c
+1
-1
services/loopevent/task/le_streamtask.c
services/loopevent/task/le_streamtask.c
+2
-2
services/loopevent/task/le_task.c
services/loopevent/task/le_task.c
+3
-3
services/modules/bootevent/bootevent.c
services/modules/bootevent/bootevent.c
+5
-5
services/param/base/param_base.c
services/param/base/param_base.c
+7
-7
services/param/base/param_comm.c
services/param/base/param_comm.c
+2
-2
services/param/base/param_trie.c
services/param/base/param_trie.c
+1
-1
services/param/linux/param_service.c
services/param/linux/param_service.c
+5
-5
services/param/trigger/trigger_manager.c
services/param/trigger/trigger_manager.c
+12
-12
services/param/watcher/proxy/watcher_manager.cpp
services/param/watcher/proxy/watcher_manager.cpp
+3
-3
services/param/watcher/proxy/watcher_manager.h
services/param/watcher/proxy/watcher_manager.h
+2
-2
services/utils/init_hashmap.c
services/utils/init_hashmap.c
+9
-9
services/utils/list.c
services/utils/list.c
+10
-10
test/unittest/init/group_unittest.cpp
test/unittest/init/group_unittest.cpp
+16
-16
test/unittest/init/loopevent_unittest.cpp
test/unittest/init/loopevent_unittest.cpp
+1
-1
test/unittest/init/service_unittest.cpp
test/unittest/init/service_unittest.cpp
+1
-1
test/unittest/param/paramservice_unittest.cpp
test/unittest/param/paramservice_unittest.cpp
+1
-1
test/unittest/param/trigger_unittest.cpp
test/unittest/param/trigger_unittest.cpp
+1
-1
ueventd/standard/ueventd_parameter.c
ueventd/standard/ueventd_parameter.c
+4
-4
ueventd/ueventd_read_cfg.c
ueventd/ueventd_read_cfg.c
+4
-4
未找到文件。
interfaces/innerkits/fs_manager/fstab.c
浏览文件 @
7525b21e
...
@@ -45,7 +45,7 @@ struct MountFlags {
...
@@ -45,7 +45,7 @@ struct MountFlags {
unsigned
long
flags
;
unsigned
long
flags
;
};
};
unsigned
int
ConvertFlags
(
char
*
flagBuffer
)
static
unsigned
int
ConvertFlags
(
char
*
flagBuffer
)
{
{
static
struct
FsManagerFlags
fsFlags
[]
=
{
static
struct
FsManagerFlags
fsFlags
[]
=
{
{
"check"
,
FS_MANAGER_CHECK
},
{
"check"
,
FS_MANAGER_CHECK
},
...
...
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
7525b21e
...
@@ -333,7 +333,7 @@ int MountOneItem(FstabItem *item)
...
@@ -333,7 +333,7 @@ int MountOneItem(FstabItem *item)
return
rc
;
return
rc
;
}
}
int
CheckRequiredAndMount
(
FstabItem
*
item
,
bool
required
)
static
int
CheckRequiredAndMount
(
FstabItem
*
item
,
bool
required
)
{
{
int
rc
=
0
;
int
rc
=
0
;
if
(
item
==
NULL
)
{
if
(
item
==
NULL
)
{
...
...
interfaces/innerkits/hookmgr/hookmgr.c
浏览文件 @
7525b21e
...
@@ -85,7 +85,7 @@ static void hookStageDestroy(ListNode *node)
...
@@ -85,7 +85,7 @@ static void hookStageDestroy(ListNode *node)
BEGET_CHECK
(
node
!=
NULL
,
return
);
BEGET_CHECK
(
node
!=
NULL
,
return
);
stage
=
(
HOOK_STAGE
*
)
node
;
stage
=
(
HOOK_STAGE
*
)
node
;
ListRemoveAll
(
&
(
stage
->
hooks
),
NULL
);
OH_
ListRemoveAll
(
&
(
stage
->
hooks
),
NULL
);
free
((
void
*
)
stage
);
free
((
void
*
)
stage
);
}
}
...
@@ -94,7 +94,7 @@ static HOOK_STAGE *getHookStage(HOOK_MGR *hookMgr, int stage, int createIfNotFou
...
@@ -94,7 +94,7 @@ static HOOK_STAGE *getHookStage(HOOK_MGR *hookMgr, int stage, int createIfNotFou
{
{
HOOK_STAGE
*
stageItem
;
HOOK_STAGE
*
stageItem
;
stageItem
=
(
HOOK_STAGE
*
)
ListFind
(
&
(
hookMgr
->
stages
),
(
void
*
)(
&
stage
),
hookStageCompare
);
stageItem
=
(
HOOK_STAGE
*
)
OH_
ListFind
(
&
(
hookMgr
->
stages
),
(
void
*
)(
&
stage
),
hookStageCompare
);
BEGET_CHECK
(
stageItem
==
NULL
,
return
stageItem
);
BEGET_CHECK
(
stageItem
==
NULL
,
return
stageItem
);
BEGET_CHECK
(
createIfNotFound
,
return
NULL
);
BEGET_CHECK
(
createIfNotFound
,
return
NULL
);
...
@@ -103,8 +103,8 @@ static HOOK_STAGE *getHookStage(HOOK_MGR *hookMgr, int stage, int createIfNotFou
...
@@ -103,8 +103,8 @@ static HOOK_STAGE *getHookStage(HOOK_MGR *hookMgr, int stage, int createIfNotFou
stageItem
=
(
HOOK_STAGE
*
)
malloc
(
sizeof
(
HOOK_STAGE
));
stageItem
=
(
HOOK_STAGE
*
)
malloc
(
sizeof
(
HOOK_STAGE
));
BEGET_CHECK
(
stageItem
!=
NULL
,
return
NULL
);
BEGET_CHECK
(
stageItem
!=
NULL
,
return
NULL
);
stageItem
->
stage
=
stage
;
stageItem
->
stage
=
stage
;
ListInit
(
&
(
stageItem
->
hooks
));
OH_
ListInit
(
&
(
stageItem
->
hooks
));
ListAddTail
(
&
(
hookMgr
->
stages
),
(
ListNode
*
)
stageItem
);
OH_
ListAddTail
(
&
(
hookMgr
->
stages
),
(
ListNode
*
)
stageItem
);
return
stageItem
;
return
stageItem
;
}
}
...
@@ -143,7 +143,7 @@ static int addHookToStage(HOOK_STAGE *hookStage, int prio, OhosHook hook, void *
...
@@ -143,7 +143,7 @@ static int addHookToStage(HOOK_STAGE *hookStage, int prio, OhosHook hook, void *
// Check if exists
// Check if exists
compareVal
.
prio
=
prio
;
compareVal
.
prio
=
prio
;
compareVal
.
hook
=
hook
;
compareVal
.
hook
=
hook
;
hookItem
=
(
HOOK_ITEM
*
)
ListFind
(
&
(
hookStage
->
hooks
),
(
void
*
)(
&
compareVal
),
hookItemCompareValue
);
hookItem
=
(
HOOK_ITEM
*
)
OH_
ListFind
(
&
(
hookStage
->
hooks
),
(
void
*
)(
&
compareVal
),
hookItemCompareValue
);
BEGET_CHECK
(
hookItem
==
NULL
,
return
0
);
BEGET_CHECK
(
hookItem
==
NULL
,
return
0
);
// Create new item
// Create new item
...
@@ -156,7 +156,7 @@ static int addHookToStage(HOOK_STAGE *hookStage, int prio, OhosHook hook, void *
...
@@ -156,7 +156,7 @@ static int addHookToStage(HOOK_STAGE *hookStage, int prio, OhosHook hook, void *
hookItem
->
stage
=
hookStage
;
hookItem
->
stage
=
hookStage
;
// Insert with order
// Insert with order
ListAddWithOrder
(
&
(
hookStage
->
hooks
),
(
ListNode
*
)
hookItem
,
hookItemCompare
);
OH_
ListAddWithOrder
(
&
(
hookStage
->
hooks
),
(
ListNode
*
)
hookItem
,
hookItemCompare
);
return
0
;
return
0
;
}
}
...
@@ -196,7 +196,7 @@ static int hookTraversalDelProc(ListNode *node, void *cookie)
...
@@ -196,7 +196,7 @@ static int hookTraversalDelProc(ListNode *node, void *cookie)
BEGET_CHECK
((
void
*
)
hookItem
->
info
.
hook
==
cookie
,
return
0
);
BEGET_CHECK
((
void
*
)
hookItem
->
info
.
hook
==
cookie
,
return
0
);
// Remove from the list
// Remove from the list
ListRemove
(
node
);
OH_
ListRemove
(
node
);
// Destroy myself
// Destroy myself
free
((
void
*
)
node
);
free
((
void
*
)
node
);
...
@@ -220,12 +220,12 @@ void HookMgrDel(HOOK_MGR *hookMgr, int stage, OhosHook hook)
...
@@ -220,12 +220,12 @@ void HookMgrDel(HOOK_MGR *hookMgr, int stage, OhosHook hook)
BEGET_CHECK
(
stageItem
!=
NULL
,
return
);
BEGET_CHECK
(
stageItem
!=
NULL
,
return
);
if
(
hook
!=
NULL
)
{
if
(
hook
!=
NULL
)
{
ListTraversal
(
&
(
stageItem
->
hooks
),
hook
,
hookTraversalDelProc
,
0
);
OH_
ListTraversal
(
&
(
stageItem
->
hooks
),
hook
,
hookTraversalDelProc
,
0
);
return
;
return
;
}
}
// Remove from list
// Remove from list
ListRemove
((
ListNode
*
)
stageItem
);
OH_
ListRemove
((
ListNode
*
)
stageItem
);
// Destroy stage item
// Destroy stage item
hookStageDestroy
((
ListNode
*
)
stageItem
);
hookStageDestroy
((
ListNode
*
)
stageItem
);
...
@@ -279,8 +279,7 @@ int HookMgrExecute(HOOK_MGR *hookMgr, int stage, void *executionContext, const H
...
@@ -279,8 +279,7 @@ int HookMgrExecute(HOOK_MGR *hookMgr, int stage, void *executionContext, const H
args
.
options
=
options
;
args
.
options
=
options
;
// Traversal all hooks in the specified stage
// Traversal all hooks in the specified stage
return
ListTraversal
(
&
(
stageItem
->
hooks
),
(
void
*
)(
&
args
),
return
OH_ListTraversal
(
&
(
stageItem
->
hooks
),
(
void
*
)(
&
args
),
hookExecutionProc
,
flags
);
hookExecutionProc
,
flags
);
}
}
HOOK_MGR
*
HookMgrCreate
(
const
char
*
name
)
HOOK_MGR
*
HookMgrCreate
(
const
char
*
name
)
...
@@ -296,7 +295,7 @@ HOOK_MGR *HookMgrCreate(const char *name)
...
@@ -296,7 +295,7 @@ HOOK_MGR *HookMgrCreate(const char *name)
free
((
void
*
)
ret
);
free
((
void
*
)
ret
);
return
NULL
;
return
NULL
;
}
}
ListInit
(
&
(
ret
->
stages
));
OH_
ListInit
(
&
(
ret
->
stages
));
return
ret
;
return
ret
;
}
}
...
@@ -305,7 +304,7 @@ void HookMgrDestroy(HOOK_MGR *hookMgr)
...
@@ -305,7 +304,7 @@ void HookMgrDestroy(HOOK_MGR *hookMgr)
hookMgr
=
getHookMgr
(
hookMgr
,
0
);
hookMgr
=
getHookMgr
(
hookMgr
,
0
);
BEGET_CHECK
(
hookMgr
!=
NULL
,
return
);
BEGET_CHECK
(
hookMgr
!=
NULL
,
return
);
ListRemoveAll
(
&
(
hookMgr
->
stages
),
hookStageDestroy
);
OH_
ListRemoveAll
(
&
(
hookMgr
->
stages
),
hookStageDestroy
);
if
(
hookMgr
==
defaultHookMgr
)
{
if
(
hookMgr
==
defaultHookMgr
)
{
defaultHookMgr
=
NULL
;
defaultHookMgr
=
NULL
;
...
@@ -336,7 +335,7 @@ static int hookItemTraversal(ListNode *node, void *data)
...
@@ -336,7 +335,7 @@ static int hookItemTraversal(ListNode *node, void *data)
static
int
hookStageTraversal
(
ListNode
*
node
,
void
*
data
)
static
int
hookStageTraversal
(
ListNode
*
node
,
void
*
data
)
{
{
HOOK_STAGE
*
stageItem
=
(
HOOK_STAGE
*
)
node
;
HOOK_STAGE
*
stageItem
=
(
HOOK_STAGE
*
)
node
;
ListTraversal
(
&
(
stageItem
->
hooks
),
data
,
hookItemTraversal
,
0
);
OH_
ListTraversal
(
&
(
stageItem
->
hooks
),
data
,
hookItemTraversal
,
0
);
return
0
;
return
0
;
}
}
...
@@ -355,7 +354,7 @@ void HookMgrTraversal(HOOK_MGR *hookMgr, void *traversalCookie, OhosHookTraversa
...
@@ -355,7 +354,7 @@ void HookMgrTraversal(HOOK_MGR *hookMgr, void *traversalCookie, OhosHookTraversa
// Prepare common args
// Prepare common args
stageArgs
.
traversalCookie
=
traversalCookie
;
stageArgs
.
traversalCookie
=
traversalCookie
;
stageArgs
.
traversal
=
traversal
;
stageArgs
.
traversal
=
traversal
;
ListTraversal
(
&
(
hookMgr
->
stages
),
(
void
*
)(
&
stageArgs
),
hookStageTraversal
,
0
);
OH_
ListTraversal
(
&
(
hookMgr
->
stages
),
(
void
*
)(
&
stageArgs
),
hookStageTraversal
,
0
);
}
}
/*
/*
...
@@ -372,7 +371,7 @@ int HookMgrGetHooksCnt(HOOK_MGR *hookMgr, int stage)
...
@@ -372,7 +371,7 @@ int HookMgrGetHooksCnt(HOOK_MGR *hookMgr, int stage)
stageItem
=
getHookStage
(
hookMgr
,
stage
,
false
);
stageItem
=
getHookStage
(
hookMgr
,
stage
,
false
);
BEGET_CHECK
(
stageItem
!=
NULL
,
return
0
);
BEGET_CHECK
(
stageItem
!=
NULL
,
return
0
);
return
ListGetCnt
(
&
(
stageItem
->
hooks
));
return
OH_
ListGetCnt
(
&
(
stageItem
->
hooks
));
}
}
/*
/*
...
@@ -383,5 +382,5 @@ int HookMgrGetStagesCnt(HOOK_MGR *hookMgr)
...
@@ -383,5 +382,5 @@ int HookMgrGetStagesCnt(HOOK_MGR *hookMgr)
hookMgr
=
getHookMgr
(
hookMgr
,
0
);
hookMgr
=
getHookMgr
(
hookMgr
,
0
);
BEGET_CHECK
(
hookMgr
!=
NULL
,
return
0
);
BEGET_CHECK
(
hookMgr
!=
NULL
,
return
0
);
return
ListGetCnt
(
&
(
hookMgr
->
stages
));
return
OH_
ListGetCnt
(
&
(
hookMgr
->
stages
));
}
}
interfaces/innerkits/modulemgr/modulemgr.c
浏览文件 @
7525b21e
...
@@ -48,7 +48,7 @@ MODULE_MGR *ModuleMgrCreate(const char *name)
...
@@ -48,7 +48,7 @@ MODULE_MGR *ModuleMgrCreate(const char *name)
moduleMgr
=
(
MODULE_MGR
*
)
malloc
(
sizeof
(
MODULE_MGR
));
moduleMgr
=
(
MODULE_MGR
*
)
malloc
(
sizeof
(
MODULE_MGR
));
BEGET_CHECK
(
moduleMgr
!=
NULL
,
return
NULL
);
BEGET_CHECK
(
moduleMgr
!=
NULL
,
return
NULL
);
ListInit
(
&
(
moduleMgr
->
modules
));
OH_
ListInit
(
&
(
moduleMgr
->
modules
));
moduleMgr
->
name
=
strdup
(
name
);
moduleMgr
->
name
=
strdup
(
name
);
if
(
moduleMgr
->
name
==
NULL
)
{
if
(
moduleMgr
->
name
==
NULL
)
{
free
((
void
*
)
moduleMgr
);
free
((
void
*
)
moduleMgr
);
...
@@ -154,7 +154,7 @@ int ModuleMgrInstall(MODULE_MGR *moduleMgr, const char *moduleName,
...
@@ -154,7 +154,7 @@ int ModuleMgrInstall(MODULE_MGR *moduleMgr, const char *moduleName,
}
}
// Add to list
// Add to list
ListAddTail
(
&
(
moduleMgr
->
modules
),
(
ListNode
*
)
module
);
OH_
ListAddTail
(
&
(
moduleMgr
->
modules
),
(
ListNode
*
)
module
);
return
0
;
return
0
;
}
}
...
@@ -252,16 +252,16 @@ void ModuleMgrUninstall(MODULE_MGR *moduleMgr, const char *name)
...
@@ -252,16 +252,16 @@ void ModuleMgrUninstall(MODULE_MGR *moduleMgr, const char *name)
BEGET_CHECK
(
moduleMgr
!=
NULL
,
return
);
BEGET_CHECK
(
moduleMgr
!=
NULL
,
return
);
// Uninstall all modules if no name specified
// Uninstall all modules if no name specified
if
(
name
==
NULL
)
{
if
(
name
==
NULL
)
{
ListRemoveAll
(
&
(
moduleMgr
->
modules
),
moduleDestroy
);
OH_
ListRemoveAll
(
&
(
moduleMgr
->
modules
),
moduleDestroy
);
return
;
return
;
}
}
BEGET_LOGV
(
"ModuleMgrUninstall moduleName %s"
,
name
);
BEGET_LOGV
(
"ModuleMgrUninstall moduleName %s"
,
name
);
// Find module by name
// Find module by name
module
=
(
MODULE_ITEM
*
)
ListFind
(
&
(
moduleMgr
->
modules
),
(
void
*
)
name
,
moduleCompare
);
module
=
(
MODULE_ITEM
*
)
OH_
ListFind
(
&
(
moduleMgr
->
modules
),
(
void
*
)
name
,
moduleCompare
);
BEGET_ERROR_CHECK
(
module
!=
NULL
,
return
,
"Can not find module %s"
,
name
);
BEGET_ERROR_CHECK
(
module
!=
NULL
,
return
,
"Can not find module %s"
,
name
);
// Remove from the list
// Remove from the list
ListRemove
((
ListNode
*
)
module
);
OH_
ListRemove
((
ListNode
*
)
module
);
// Destroy the module
// Destroy the module
moduleDestroy
((
ListNode
*
)
module
);
moduleDestroy
((
ListNode
*
)
module
);
}
}
...
@@ -269,7 +269,7 @@ void ModuleMgrUninstall(MODULE_MGR *moduleMgr, const char *name)
...
@@ -269,7 +269,7 @@ void ModuleMgrUninstall(MODULE_MGR *moduleMgr, const char *name)
int
ModuleMgrGetCnt
(
const
MODULE_MGR
*
moduleMgr
)
int
ModuleMgrGetCnt
(
const
MODULE_MGR
*
moduleMgr
)
{
{
BEGET_CHECK
(
moduleMgr
!=
NULL
,
return
0
);
BEGET_CHECK
(
moduleMgr
!=
NULL
,
return
0
);
return
ListGetCnt
(
&
(
moduleMgr
->
modules
));
return
OH_
ListGetCnt
(
&
(
moduleMgr
->
modules
));
}
}
typedef
struct
tagMODULE_TRAVERSAL_ARGS
{
typedef
struct
tagMODULE_TRAVERSAL_ARGS
{
...
@@ -312,5 +312,5 @@ void ModuleMgrTraversal(const MODULE_MGR *moduleMgr, void *cookie, OhosModuleTra
...
@@ -312,5 +312,5 @@ void ModuleMgrTraversal(const MODULE_MGR *moduleMgr, void *cookie, OhosModuleTra
args
.
cookie
=
cookie
;
args
.
cookie
=
cookie
;
args
.
traversal
=
traversal
;
args
.
traversal
=
traversal
;
ListTraversal
((
ListNode
*
)(
&
(
moduleMgr
->
modules
)),
(
void
*
)(
&
args
),
moduleTraversalProc
,
0
);
OH_
ListTraversal
((
ListNode
*
)(
&
(
moduleMgr
->
modules
)),
(
void
*
)(
&
args
),
moduleTraversalProc
,
0
);
}
}
interfaces/innerkits/reboot/init_reboot_innerkits.c
浏览文件 @
7525b21e
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#define DOREBOOT_PARAM "reboot.ut"
#define DOREBOOT_PARAM "reboot.ut"
#endif
#endif
int
DoReboot_
(
const
char
*
option
)
static
int
DoReboot_
(
const
char
*
option
)
{
{
char
value
[
MAX_REBOOT_OPTION_SIZE
];
char
value
[
MAX_REBOOT_OPTION_SIZE
];
int
ret
=
0
;
int
ret
=
0
;
...
...
services/include/init_hashmap.h
浏览文件 @
7525b21e
...
@@ -51,15 +51,15 @@ typedef struct {
...
@@ -51,15 +51,15 @@ typedef struct {
typedef
void
*
HashMapHandle
;
typedef
void
*
HashMapHandle
;
int
HashMapIsEmpty
(
HashMapHandle
handle
);
int
OH_
HashMapIsEmpty
(
HashMapHandle
handle
);
int32_t
HashMapCreate
(
HashMapHandle
*
handle
,
const
HashInfo
*
info
);
int32_t
OH_
HashMapCreate
(
HashMapHandle
*
handle
,
const
HashInfo
*
info
);
void
HashMapDestory
(
HashMapHandle
handle
);
void
OH_
HashMapDestory
(
HashMapHandle
handle
);
int32_t
HashMapAdd
(
HashMapHandle
handle
,
HashNode
*
hashNode
);
int32_t
OH_
HashMapAdd
(
HashMapHandle
handle
,
HashNode
*
hashNode
);
void
HashMapRemove
(
HashMapHandle
handle
,
const
void
*
key
);
void
OH_
HashMapRemove
(
HashMapHandle
handle
,
const
void
*
key
);
HashNode
*
HashMapGet
(
HashMapHandle
handle
,
const
void
*
key
);
HashNode
*
OH_
HashMapGet
(
HashMapHandle
handle
,
const
void
*
key
);
HashNode
*
HashMapFind
(
HashMapHandle
handle
,
HashNode
*
OH_
HashMapFind
(
HashMapHandle
handle
,
int
hashCode
,
const
void
*
key
,
HashKeyCompare
keyCompare
);
int
hashCode
,
const
void
*
key
,
HashKeyCompare
keyCompare
);
void
HashMapTraverse
(
HashMapHandle
handle
,
void
(
*
hashNodeTraverse
)(
const
HashNode
*
node
,
const
void
*
context
),
void
OH_
HashMapTraverse
(
HashMapHandle
handle
,
void
(
*
hashNodeTraverse
)(
const
HashNode
*
node
,
const
void
*
context
),
const
void
*
context
);
const
void
*
context
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
...
...
services/include/list.h
浏览文件 @
7525b21e
...
@@ -43,7 +43,7 @@ extern "C" {
...
@@ -43,7 +43,7 @@ extern "C" {
* int value;
* int value;
* } TEST_LIST_ITEM;
* } TEST_LIST_ITEM;
*
*
* 2. Define a list and init list by ListAddTail
* 2. Define a list and init list by
OH_
ListAddTail
* ListNode testList;
* ListNode testList;
* c(&testList);
* c(&testList);
*
*
...
@@ -52,7 +52,7 @@ extern "C" {
...
@@ -52,7 +52,7 @@ extern "C" {
* item.value = 0;
* item.value = 0;
*
*
* 4. Add list item to list
* 4. Add list item to list
* ListAddTail(&testList, (ListNode *)(&item));
*
OH_
ListAddTail(&testList, (ListNode *)(&item));
*
*
* 5. Advanced usage: add with order
* 5. Advanced usage: add with order
* // Ordering compare function
* // Ordering compare function
...
@@ -62,7 +62,7 @@ extern "C" {
...
@@ -62,7 +62,7 @@ extern "C" {
* TEST_LIST_ITEM *right = (TEST_LIST_ITEM *)newNode;
* TEST_LIST_ITEM *right = (TEST_LIST_ITEM *)newNode;
* return left->value - right->value;
* return left->value - right->value;
* }
* }
* ListAddWithOrder(&testList, (ListNode *)(&item))
*
OH_
ListAddWithOrder(&testList, (ListNode *)(&item))
*/
*/
/**
/**
...
@@ -85,7 +85,7 @@ typedef struct ListNode {
...
@@ -85,7 +85,7 @@ typedef struct ListNode {
* @param head list head, make sure head is valid pointer
* @param head list head, make sure head is valid pointer
* @return None
* @return None
*/
*/
void
ListInit
(
struct
ListNode
*
list
);
void
OH_
ListInit
(
struct
ListNode
*
list
);
/**
/**
* @brief Add a node to the end of the list
* @brief Add a node to the end of the list
...
@@ -94,7 +94,7 @@ void ListInit(struct ListNode *list);
...
@@ -94,7 +94,7 @@ void ListInit(struct ListNode *list);
* @param item new node to be added
* @param item new node to be added
* @return None
* @return None
*/
*/
void
ListAddTail
(
struct
ListNode
*
list
,
struct
ListNode
*
item
);
void
OH_
ListAddTail
(
struct
ListNode
*
list
,
struct
ListNode
*
item
);
/**
/**
* @brief Remove a node from the list
* @brief Remove a node from the list
...
@@ -103,7 +103,7 @@ void ListAddTail(struct ListNode *list, struct ListNode *item);
...
@@ -103,7 +103,7 @@ void ListAddTail(struct ListNode *list, struct ListNode *item);
* This function does not free any memory within item.
* This function does not free any memory within item.
* @return None
* @return None
*/
*/
void
ListRemove
(
struct
ListNode
*
item
);
void
OH_
ListRemove
(
struct
ListNode
*
item
);
/**
/**
* @brief ListNode comparison function prototype
* @brief ListNode comparison function prototype
...
@@ -128,7 +128,7 @@ typedef int (*ListCompareProc)(ListNode *node, ListNode *newNode);
...
@@ -128,7 +128,7 @@ typedef int (*ListCompareProc)(ListNode *node, ListNode *newNode);
* respectively less than, equal to, or greater than the second.
* respectively less than, equal to, or greater than the second.
* @return None
* @return None
*/
*/
void
ListAddWithOrder
(
struct
ListNode
*
head
,
struct
ListNode
*
item
,
ListCompareProc
compareProc
);
void
OH_
ListAddWithOrder
(
struct
ListNode
*
head
,
struct
ListNode
*
item
,
ListCompareProc
compareProc
);
/**
/**
* @brief ListNode traversing and find function prototype
* @brief ListNode traversing and find function prototype
...
@@ -136,7 +136,7 @@ void ListAddWithOrder(struct ListNode *head, struct ListNode *item, ListCompareP
...
@@ -136,7 +136,7 @@ void ListAddWithOrder(struct ListNode *head, struct ListNode *item, ListCompareP
* @param node ListNode to be compared.
* @param node ListNode to be compared.
* @param data value for traversing
* @param data value for traversing
* @return
* @return
* return 0 if node value equals data for ListFind
* return 0 if node value equals data for
OH_
ListFind
*/
*/
typedef
int
(
*
ListTraversalProc
)(
ListNode
*
node
,
void
*
data
);
typedef
int
(
*
ListTraversalProc
)(
ListNode
*
node
,
void
*
data
);
...
@@ -148,7 +148,7 @@ typedef int (*ListTraversalProc)(ListNode *node, void *data);
...
@@ -148,7 +148,7 @@ typedef int (*ListTraversalProc)(ListNode *node, void *data);
* @param compareProc comparing function, return 0 if matched.
* @param compareProc comparing function, return 0 if matched.
* @return the found node; return NULL if none is found.
* @return the found node; return NULL if none is found.
*/
*/
ListNode
*
ListFind
(
const
ListNode
*
head
,
void
*
data
,
ListTraversalProc
compareProc
);
ListNode
*
OH_
ListFind
(
const
ListNode
*
head
,
void
*
data
,
ListTraversalProc
compareProc
);
/* Traversing from end to start */
/* Traversing from end to start */
#define TRAVERSE_REVERSE_ORDER 0x1
#define TRAVERSE_REVERSE_ORDER 0x1
...
@@ -169,7 +169,7 @@ ListNode *ListFind(const ListNode *head, void *data, ListTraversalProc comparePr
...
@@ -169,7 +169,7 @@ ListNode *ListFind(const ListNode *head, void *data, ListTraversalProc comparePr
* @return return -1 for invalid input arguments.
* @return return -1 for invalid input arguments.
* when TRAVERSE_STOP_WHEN_ERROR is specified, it will return errors from traversalProc
* when TRAVERSE_STOP_WHEN_ERROR is specified, it will return errors from traversalProc
*/
*/
int
ListTraversal
(
ListNode
*
head
,
void
*
data
,
ListTraversalProc
traversalProc
,
int
flags
);
int
OH_
ListTraversal
(
ListNode
*
head
,
void
*
data
,
ListTraversalProc
traversalProc
,
int
flags
);
/**
/**
* @brief ListNode destroy function prototype
* @brief ListNode destroy function prototype
...
@@ -186,7 +186,7 @@ typedef void (*ListDestroyProc)(ListNode *node);
...
@@ -186,7 +186,7 @@ typedef void (*ListDestroyProc)(ListNode *node);
* @param destroyProc destroy function; if NULL, it will free each node by default.
* @param destroyProc destroy function; if NULL, it will free each node by default.
* @return None
* @return None
*/
*/
void
ListRemoveAll
(
ListNode
*
head
,
ListDestroyProc
destroyProc
);
void
OH_
ListRemoveAll
(
ListNode
*
head
,
ListDestroyProc
destroyProc
);
/**
/**
* @brief Get list count
* @brief Get list count
...
@@ -194,7 +194,7 @@ void ListRemoveAll(ListNode *head, ListDestroyProc destroyProc);
...
@@ -194,7 +194,7 @@ void ListRemoveAll(ListNode *head, ListDestroyProc destroyProc);
* @param head list head, make sure head is valid pointer.
* @param head list head, make sure head is valid pointer.
* @return the count of nodes in the list; return 0 if error
* @return the count of nodes in the list; return 0 if error
*/
*/
int
ListGetCnt
(
const
ListNode
*
head
);
int
OH_
ListGetCnt
(
const
ListNode
*
head
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
...
...
services/init/init_group_manager.c
浏览文件 @
7525b21e
...
@@ -99,7 +99,7 @@ static int InitFreeGroupNodes_(InitGroupNode *groupRoot)
...
@@ -99,7 +99,7 @@ static int InitFreeGroupNodes_(InitGroupNode *groupRoot)
while
(
groupNode
!=
NULL
)
{
while
(
groupNode
!=
NULL
)
{
groupRoot
=
groupNode
->
next
;
groupRoot
=
groupNode
->
next
;
if
(
groupNode
->
type
<
NODE_TYPE_GROUPS
)
{
// remove from hashmap
if
(
groupNode
->
type
<
NODE_TYPE_GROUPS
)
{
// remove from hashmap
HashMapRemove
(
g_initWorkspace
.
hashMap
[
groupNode
->
type
],
groupNode
->
name
);
OH_
HashMapRemove
(
g_initWorkspace
.
hashMap
[
groupNode
->
type
],
groupNode
->
name
);
}
}
free
(
groupNode
);
free
(
groupNode
);
groupNode
=
groupRoot
;
groupNode
=
groupRoot
;
...
@@ -173,7 +173,7 @@ void InitServiceSpace(void)
...
@@ -173,7 +173,7 @@ void InitServiceSpace(void)
GROUP_HASHMAP_BUCKET
GROUP_HASHMAP_BUCKET
};
};
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
g_initWorkspace
.
hashMap
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
g_initWorkspace
.
hashMap
);
i
++
)
{
int
ret
=
HashMapCreate
(
&
g_initWorkspace
.
hashMap
[
i
],
&
info
);
int
ret
=
OH_
HashMapCreate
(
&
g_initWorkspace
.
hashMap
[
i
],
&
info
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
INIT_LOGE
(
"%s"
,
"Failed to create hash map"
);
INIT_LOGE
(
"%s"
,
"Failed to create hash map"
);
}
}
...
@@ -242,7 +242,7 @@ InitGroupNode *AddGroupNode(int type, const char *name)
...
@@ -242,7 +242,7 @@ InitGroupNode *AddGroupNode(int type, const char *name)
g_initWorkspace
.
groupNodes
[
type
]
=
groupNode
;
g_initWorkspace
.
groupNodes
[
type
]
=
groupNode
;
if
(
type
<
NODE_TYPE_GROUPS
)
{
// add hashmap
if
(
type
<
NODE_TYPE_GROUPS
)
{
// add hashmap
HashMapAdd
(
g_initWorkspace
.
hashMap
[
type
],
&
groupNode
->
hashNode
);
OH_
HashMapAdd
(
g_initWorkspace
.
hashMap
[
type
],
&
groupNode
->
hashNode
);
}
}
return
groupNode
;
return
groupNode
;
}
}
...
@@ -253,7 +253,7 @@ InitGroupNode *GetGroupNode(int type, const char *name)
...
@@ -253,7 +253,7 @@ InitGroupNode *GetGroupNode(int type, const char *name)
return
NULL
;
return
NULL
;
}
}
INIT_LOGV
(
"GetGroupNode type %d %p name %s"
,
type
,
g_initWorkspace
.
hashMap
[
type
],
name
);
INIT_LOGV
(
"GetGroupNode type %d %p name %s"
,
type
,
g_initWorkspace
.
hashMap
[
type
],
name
);
HashNode
*
node
=
HashMapGet
(
g_initWorkspace
.
hashMap
[
type
],
name
);
HashNode
*
node
=
OH_
HashMapGet
(
g_initWorkspace
.
hashMap
[
type
],
name
);
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -275,7 +275,7 @@ void DelGroupNode(int type, const char *name)
...
@@ -275,7 +275,7 @@ void DelGroupNode(int type, const char *name)
return
;
return
;
}
}
INIT_LOGV
(
"DelGroupNode type %d %p name %s"
,
type
,
g_initWorkspace
.
hashMap
[
type
],
name
);
INIT_LOGV
(
"DelGroupNode type %d %p name %s"
,
type
,
g_initWorkspace
.
hashMap
[
type
],
name
);
HashMapRemove
(
g_initWorkspace
.
hashMap
[
type
],
name
);
OH_
HashMapRemove
(
g_initWorkspace
.
hashMap
[
type
],
name
);
InitGroupNode
*
groupNode
=
g_initWorkspace
.
groupNodes
[
type
];
InitGroupNode
*
groupNode
=
g_initWorkspace
.
groupNodes
[
type
];
InitGroupNode
*
preNode
=
groupNode
;
InitGroupNode
*
preNode
=
groupNode
;
while
(
groupNode
!=
NULL
)
{
while
(
groupNode
!=
NULL
)
{
...
@@ -299,7 +299,7 @@ int CheckNodeValid(int type, const char *name)
...
@@ -299,7 +299,7 @@ int CheckNodeValid(int type, const char *name)
if
(
type
>=
NODE_TYPE_GROUPS
)
{
if
(
type
>=
NODE_TYPE_GROUPS
)
{
return
-
1
;
return
-
1
;
}
}
HashNode
*
node
=
HashMapGet
(
g_initWorkspace
.
hashMap
[
type
],
name
);
HashNode
*
node
=
OH_
HashMapGet
(
g_initWorkspace
.
hashMap
[
type
],
name
);
if
(
node
!=
NULL
)
{
if
(
node
!=
NULL
)
{
INIT_LOGI
(
"Found %s in %s group"
,
name
,
type
==
NODE_TYPE_JOBS
?
"job"
:
"service"
);
INIT_LOGI
(
"Found %s in %s group"
,
name
,
type
==
NODE_TYPE_JOBS
?
"job"
:
"service"
);
return
0
;
return
0
;
...
...
services/init/standard/init_cmdexecutor.c
浏览文件 @
7525b21e
...
@@ -43,17 +43,17 @@ int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd)
...
@@ -43,17 +43,17 @@ int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd)
groupNode
->
data
.
cmd
=
cmd
;
groupNode
->
data
.
cmd
=
cmd
;
cmd
->
cmdId
=
g_cmdId
++
;
cmd
->
cmdId
=
g_cmdId
++
;
cmd
->
name
=
groupNode
->
name
;
cmd
->
name
=
groupNode
->
name
;
ListInit
(
&
cmd
->
cmdExecutor
);
OH_
ListInit
(
&
cmd
->
cmdExecutor
);
}
}
if
(
execCmd
==
NULL
)
{
if
(
execCmd
==
NULL
)
{
return
0
;
return
0
;
}
}
PluginCmdExecutor
*
cmdExec
=
(
PluginCmdExecutor
*
)
calloc
(
1
,
sizeof
(
PluginCmdExecutor
));
PluginCmdExecutor
*
cmdExec
=
(
PluginCmdExecutor
*
)
calloc
(
1
,
sizeof
(
PluginCmdExecutor
));
INIT_ERROR_CHECK
(
cmdExec
!=
NULL
,
return
-
1
,
"Failed to create cmd listener"
);
INIT_ERROR_CHECK
(
cmdExec
!=
NULL
,
return
-
1
,
"Failed to create cmd listener"
);
ListInit
(
&
cmdExec
->
node
);
OH_
ListInit
(
&
cmdExec
->
node
);
cmdExec
->
id
=
++
g_cmdExecutorId
;
cmdExec
->
id
=
++
g_cmdExecutorId
;
cmdExec
->
execCmd
=
execCmd
;
cmdExec
->
execCmd
=
execCmd
;
ListAddTail
(
&
cmd
->
cmdExecutor
,
&
cmdExec
->
node
);
OH_
ListAddTail
(
&
cmd
->
cmdExecutor
,
&
cmdExec
->
node
);
return
cmdExec
->
id
;
return
cmdExec
->
id
;
}
}
...
@@ -69,7 +69,7 @@ void RemoveCmdExecutor(const char *cmdName, int id)
...
@@ -69,7 +69,7 @@ void RemoveCmdExecutor(const char *cmdName, int id)
while
(
node
!=
&
cmd
->
cmdExecutor
)
{
while
(
node
!=
&
cmd
->
cmdExecutor
)
{
PluginCmdExecutor
*
cmdExec
=
ListEntry
(
node
,
PluginCmdExecutor
,
node
);
PluginCmdExecutor
*
cmdExec
=
ListEntry
(
node
,
PluginCmdExecutor
,
node
);
if
(
cmdExec
->
id
==
id
)
{
if
(
cmdExec
->
id
==
id
)
{
ListRemove
(
&
cmdExec
->
node
);
OH_
ListRemove
(
&
cmdExec
->
node
);
free
(
cmdExec
);
free
(
cmdExec
);
break
;
break
;
}
}
...
@@ -148,7 +148,7 @@ void PluginExecCmdByCmdIndex(int index, const char *cmdContent)
...
@@ -148,7 +148,7 @@ void PluginExecCmdByCmdIndex(int index, const char *cmdContent)
{
{
int
hashCode
=
((
index
>>
16
)
&
0x0000ffff
)
-
1
;
// 16 left shift
int
hashCode
=
((
index
>>
16
)
&
0x0000ffff
)
-
1
;
// 16 left shift
int
cmdId
=
(
index
&
0x0000ffff
);
int
cmdId
=
(
index
&
0x0000ffff
);
HashNode
*
node
=
HashMapFind
(
GetGroupHashMap
(
NODE_TYPE_CMDS
),
HashNode
*
node
=
OH_
HashMapFind
(
GetGroupHashMap
(
NODE_TYPE_CMDS
),
hashCode
,
(
const
void
*
)
&
cmdId
,
CompareCmdId
);
hashCode
,
(
const
void
*
)
&
cmdId
,
CompareCmdId
);
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
return
;
return
;
...
...
services/loopevent/loop/le_loop.c
浏览文件 @
7525b21e
...
@@ -68,7 +68,7 @@ static LE_STATUS CreateLoop_(EventLoop **loop, uint32_t maxevents, uint32_t time
...
@@ -68,7 +68,7 @@ static LE_STATUS CreateLoop_(EventLoop **loop, uint32_t maxevents, uint32_t time
TaskNodeFree
,
TaskNodeFree
,
128
128
};
};
return
HashMapCreate
(
&
(
*
loop
)
->
taskMap
,
&
info
);
return
OH_
HashMapCreate
(
&
(
*
loop
)
->
taskMap
,
&
info
);
}
}
LE_STATUS
CloseLoop
(
EventLoop
*
loop
)
LE_STATUS
CloseLoop
(
EventLoop
*
loop
)
...
@@ -76,7 +76,7 @@ LE_STATUS CloseLoop(EventLoop *loop)
...
@@ -76,7 +76,7 @@ LE_STATUS CloseLoop(EventLoop *loop)
if
(
!
loop
->
stop
)
{
if
(
!
loop
->
stop
)
{
return
LE_SUCCESS
;
return
LE_SUCCESS
;
}
}
HashMapDestory
(
loop
->
taskMap
);
OH_
HashMapDestory
(
loop
->
taskMap
);
if
(
loop
->
close
)
{
if
(
loop
->
close
)
{
loop
->
close
(
loop
);
loop
->
close
(
loop
);
}
}
...
@@ -100,7 +100,7 @@ LE_STATUS ProcessEvent(const EventLoop *loop, int fd, uint32_t oper)
...
@@ -100,7 +100,7 @@ LE_STATUS ProcessEvent(const EventLoop *loop, int fd, uint32_t oper)
LE_STATUS
AddTask
(
EventLoop
*
loop
,
BaseTask
*
task
)
LE_STATUS
AddTask
(
EventLoop
*
loop
,
BaseTask
*
task
)
{
{
LoopMutexLock
(
&
loop
->
mutex
);
LoopMutexLock
(
&
loop
->
mutex
);
HashMapAdd
(
loop
->
taskMap
,
&
task
->
hashNode
);
OH_
HashMapAdd
(
loop
->
taskMap
,
&
task
->
hashNode
);
LoopMutexUnlock
(
&
loop
->
mutex
);
LoopMutexUnlock
(
&
loop
->
mutex
);
return
LE_SUCCESS
;
return
LE_SUCCESS
;
}
}
...
@@ -110,7 +110,7 @@ BaseTask *GetTaskByFd(EventLoop *loop, int fd)
...
@@ -110,7 +110,7 @@ BaseTask *GetTaskByFd(EventLoop *loop, int fd)
BaseTask
*
task
=
NULL
;
BaseTask
*
task
=
NULL
;
LoopMutexLock
(
&
loop
->
mutex
);
LoopMutexLock
(
&
loop
->
mutex
);
TaskId
id
=
{
0
,
{
fd
}};
TaskId
id
=
{
0
,
{
fd
}};
HashNode
*
node
=
HashMapGet
(
loop
->
taskMap
,
&
id
);
HashNode
*
node
=
OH_
HashMapGet
(
loop
->
taskMap
,
&
id
);
if
(
node
!=
NULL
)
{
if
(
node
!=
NULL
)
{
task
=
HASHMAP_ENTRY
(
node
,
BaseTask
,
hashNode
);
task
=
HASHMAP_ENTRY
(
node
,
BaseTask
,
hashNode
);
}
}
...
@@ -123,7 +123,7 @@ void DelTask(EventLoop *loop, BaseTask *task)
...
@@ -123,7 +123,7 @@ void DelTask(EventLoop *loop, BaseTask *task)
loop
->
delEvent
(
loop
,
task
->
taskId
.
fd
,
loop
->
delEvent
(
loop
,
task
->
taskId
.
fd
,
Event_Read
|
Event_Write
|
Event_Error
|
Event_Free
|
Event_Timeout
|
Event_Signal
);
Event_Read
|
Event_Write
|
Event_Error
|
Event_Free
|
Event_Timeout
|
Event_Signal
);
LoopMutexLock
(
&
loop
->
mutex
);
LoopMutexLock
(
&
loop
->
mutex
);
HashMapRemove
(
loop
->
taskMap
,
(
TaskId
*
)
task
);
OH_
HashMapRemove
(
loop
->
taskMap
,
(
TaskId
*
)
task
);
LoopMutexUnlock
(
&
loop
->
mutex
);
LoopMutexUnlock
(
&
loop
->
mutex
);
return
;
return
;
}
}
...
...
services/loopevent/socket/le_socket.c
浏览文件 @
7525b21e
...
@@ -80,7 +80,7 @@ static int CreatePipeSocket_(const char *server)
...
@@ -80,7 +80,7 @@ static int CreatePipeSocket_(const char *server)
return
fd
;
return
fd
;
}
}
LE_STATUS
GetSockaddrFromServer_
(
const
char
*
server
,
struct
sockaddr_in
*
addr
)
static
LE_STATUS
GetSockaddrFromServer_
(
const
char
*
server
,
struct
sockaddr_in
*
addr
)
{
{
int
ret
=
memset_s
(
addr
,
sizeof
(
struct
sockaddr_in
),
0
,
sizeof
(
struct
sockaddr_in
));
int
ret
=
memset_s
(
addr
,
sizeof
(
struct
sockaddr_in
),
0
,
sizeof
(
struct
sockaddr_in
));
LE_CHECK
(
ret
==
0
,
return
ret
,
"Failed to memory set. error: %s"
,
strerror
(
errno
));
LE_CHECK
(
ret
==
0
,
return
ret
,
"Failed to memory set. error: %s"
,
strerror
(
errno
));
...
...
services/loopevent/task/le_asynctask.c
浏览文件 @
7525b21e
...
@@ -84,7 +84,7 @@ LE_STATUS LE_CreateAsyncTask(const LoopHandle loopHandle,
...
@@ -84,7 +84,7 @@ LE_STATUS LE_CreateAsyncTask(const LoopHandle loopHandle,
task
->
stream
.
base
.
handleEvent
=
HandleAsyncEvent_
;
task
->
stream
.
base
.
handleEvent
=
HandleAsyncEvent_
;
task
->
stream
.
base
.
innerClose
=
HandleAsyncTaskClose_
;
task
->
stream
.
base
.
innerClose
=
HandleAsyncTaskClose_
;
ListInit
(
&
task
->
stream
.
buffHead
);
OH_
ListInit
(
&
task
->
stream
.
buffHead
);
LoopMutexInit
(
&
task
->
stream
.
mutex
);
LoopMutexInit
(
&
task
->
stream
.
mutex
);
task
->
processAsyncEvent
=
processAsyncEvent
;
task
->
processAsyncEvent
=
processAsyncEvent
;
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
...
...
services/loopevent/task/le_streamtask.c
浏览文件 @
7525b21e
...
@@ -195,7 +195,7 @@ LE_STATUS LE_CreateStreamClient(const LoopHandle loopHandle,
...
@@ -195,7 +195,7 @@ LE_STATUS LE_CreateStreamClient(const LoopHandle loopHandle,
return
LE_NO_MEMORY
,
"Failed to create task"
);
return
LE_NO_MEMORY
,
"Failed to create task"
);
task
->
stream
.
base
.
handleEvent
=
HandleClientEvent_
;
task
->
stream
.
base
.
handleEvent
=
HandleClientEvent_
;
task
->
stream
.
base
.
innerClose
=
HandleStreamTaskClose_
;
task
->
stream
.
base
.
innerClose
=
HandleStreamTaskClose_
;
ListInit
(
&
task
->
stream
.
buffHead
);
OH_
ListInit
(
&
task
->
stream
.
buffHead
);
LoopMutexInit
(
&
task
->
stream
.
mutex
);
LoopMutexInit
(
&
task
->
stream
.
mutex
);
task
->
connectComplete
=
info
->
connectComplete
;
task
->
connectComplete
=
info
->
connectComplete
;
...
@@ -229,7 +229,7 @@ LE_STATUS LE_AcceptStreamClient(const LoopHandle loopHandle, const TaskHandle se
...
@@ -229,7 +229,7 @@ LE_STATUS LE_AcceptStreamClient(const LoopHandle loopHandle, const TaskHandle se
task
->
sendMessageComplete
=
info
->
sendMessageComplete
;
task
->
sendMessageComplete
=
info
->
sendMessageComplete
;
task
->
recvMessage
=
info
->
recvMessage
;
task
->
recvMessage
=
info
->
recvMessage
;
task
->
serverTask
=
(
StreamServerTask
*
)
server
;
task
->
serverTask
=
(
StreamServerTask
*
)
server
;
ListInit
(
&
task
->
stream
.
buffHead
);
OH_
ListInit
(
&
task
->
stream
.
buffHead
);
LoopMutexInit
(
&
task
->
stream
.
mutex
);
LoopMutexInit
(
&
task
->
stream
.
mutex
);
if
((
info
->
baseInfo
.
flags
&
TASK_TEST
)
!=
TASK_TEST
)
{
if
((
info
->
baseInfo
.
flags
&
TASK_TEST
)
!=
TASK_TEST
)
{
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
...
...
services/loopevent/task/le_task.c
浏览文件 @
7525b21e
...
@@ -81,7 +81,7 @@ LE_Buffer *CreateBuffer(uint32_t bufferSize)
...
@@ -81,7 +81,7 @@ LE_Buffer *CreateBuffer(uint32_t bufferSize)
LE_Buffer
*
buffer
=
NULL
;
LE_Buffer
*
buffer
=
NULL
;
LE_CHECK
((
buffer
=
(
LE_Buffer
*
)
malloc
(
sizeof
(
LE_Buffer
)
+
bufferSize
))
!=
NULL
,
LE_CHECK
((
buffer
=
(
LE_Buffer
*
)
malloc
(
sizeof
(
LE_Buffer
)
+
bufferSize
))
!=
NULL
,
return
NULL
,
"Failed to alloc memory for buffer"
);
return
NULL
,
"Failed to alloc memory for buffer"
);
ListInit
(
&
buffer
->
node
);
OH_
ListInit
(
&
buffer
->
node
);
buffer
->
buffSize
=
bufferSize
;
buffer
->
buffSize
=
bufferSize
;
buffer
->
dataSize
=
0
;
buffer
->
dataSize
=
0
;
return
buffer
;
return
buffer
;
...
@@ -110,7 +110,7 @@ LE_Buffer *GetFirstBuffer(StreamTask *task)
...
@@ -110,7 +110,7 @@ LE_Buffer *GetFirstBuffer(StreamTask *task)
void
AddBuffer
(
StreamTask
*
task
,
LE_Buffer
*
buffer
)
void
AddBuffer
(
StreamTask
*
task
,
LE_Buffer
*
buffer
)
{
{
LoopMutexLock
(
&
task
->
mutex
);
LoopMutexLock
(
&
task
->
mutex
);
ListAddTail
(
&
task
->
buffHead
,
&
buffer
->
node
);
OH_
ListAddTail
(
&
task
->
buffHead
,
&
buffer
->
node
);
LoopMutexUnlock
(
&
task
->
mutex
);
LoopMutexUnlock
(
&
task
->
mutex
);
}
}
...
@@ -141,7 +141,7 @@ void FreeBuffer(const LoopHandle loop, StreamTask *task, LE_Buffer *buffer)
...
@@ -141,7 +141,7 @@ void FreeBuffer(const LoopHandle loop, StreamTask *task, LE_Buffer *buffer)
if
(
CheckTaskFlags
((
BaseTask
*
)
task
,
TASK_STREAM
|
TASK_CONNECT
)
||
if
(
CheckTaskFlags
((
BaseTask
*
)
task
,
TASK_STREAM
|
TASK_CONNECT
)
||
CheckTaskFlags
((
BaseTask
*
)
task
,
TASK_EVENT
|
TASK_ASYNC_EVENT
))
{
CheckTaskFlags
((
BaseTask
*
)
task
,
TASK_EVENT
|
TASK_ASYNC_EVENT
))
{
LoopMutexLock
(
&
task
->
mutex
);
LoopMutexLock
(
&
task
->
mutex
);
ListRemove
(
&
buffer
->
node
);
OH_
ListRemove
(
&
buffer
->
node
);
LoopMutexUnlock
(
&
task
->
mutex
);
LoopMutexUnlock
(
&
task
->
mutex
);
}
}
free
(
buffer
);
free
(
buffer
);
...
...
services/modules/bootevent/bootevent.c
浏览文件 @
7525b21e
...
@@ -41,7 +41,7 @@ static ListNode *getBootEventParaList(bool autoCreate)
...
@@ -41,7 +41,7 @@ static ListNode *getBootEventParaList(bool autoCreate)
if
(
bootEventList
==
NULL
)
{
if
(
bootEventList
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
ListInit
(
bootEventList
);
OH_
ListInit
(
bootEventList
);
return
bootEventList
;
return
bootEventList
;
}
}
...
@@ -77,7 +77,7 @@ static void BootEventParaAdd(const char *paramName)
...
@@ -77,7 +77,7 @@ static void BootEventParaAdd(const char *paramName)
}
}
// Add to list
// Add to list
ListAddTail
(
list
,
(
ListNode
*
)
item
);
OH_
ListAddTail
(
list
,
(
ListNode
*
)
item
);
}
}
static
int
BootEventParaListCompareProc
(
ListNode
*
node
,
void
*
data
)
static
int
BootEventParaListCompareProc
(
ListNode
*
node
,
void
*
data
)
...
@@ -109,15 +109,15 @@ static void BootEventParaFireByName(const char *paramName)
...
@@ -109,15 +109,15 @@ static void BootEventParaFireByName(const char *paramName)
return
;
return
;
}
}
found
=
ListFind
(
getBootEventParaList
(
false
),
(
void
*
)
paramName
,
BootEventParaListCompareProc
);
found
=
OH_
ListFind
(
getBootEventParaList
(
false
),
(
void
*
)
paramName
,
BootEventParaListCompareProc
);
if
(
found
!=
NULL
)
{
if
(
found
!=
NULL
)
{
// Remove from list
// Remove from list
ListRemove
(
found
);
OH_
ListRemove
(
found
);
BootEventParaItemDestroy
((
BOOT_EVENT_PARAM_ITEM
*
)
found
);
BootEventParaItemDestroy
((
BOOT_EVENT_PARAM_ITEM
*
)
found
);
}
}
// Check if all boot event params are fired
// Check if all boot event params are fired
if
(
ListGetCnt
(
getBootEventParaList
(
false
))
>
0
)
{
if
(
OH_
ListGetCnt
(
getBootEventParaList
(
false
))
>
0
)
{
return
;
return
;
}
}
...
...
services/param/base/param_base.c
浏览文件 @
7525b21e
...
@@ -130,10 +130,10 @@ INIT_PUBLIC_API int InitParamWorkSpace(int onlyRead)
...
@@ -130,10 +130,10 @@ INIT_PUBLIC_API int InitParamWorkSpace(int onlyRead)
WorkSpaceFree
,
WorkSpaceFree
,
HASH_BUTT
HASH_BUTT
};
};
int
ret
=
HashMapCreate
(
&
g_paramWorkSpace
.
workSpaceHashHandle
,
&
info
);
int
ret
=
OH_
HashMapCreate
(
&
g_paramWorkSpace
.
workSpaceHashHandle
,
&
info
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to create hash map for workspace"
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to create hash map for workspace"
);
WORKSPACE_INIT_LOCK
(
g_paramWorkSpace
);
WORKSPACE_INIT_LOCK
(
g_paramWorkSpace
);
ListInit
(
&
g_paramWorkSpace
.
workSpaceList
);
OH_
ListInit
(
&
g_paramWorkSpace
.
workSpaceList
);
PARAM_SET_FLAG
(
g_paramWorkSpace
.
flags
,
WORKSPACE_FLAGS_INIT
);
PARAM_SET_FLAG
(
g_paramWorkSpace
.
flags
,
WORKSPACE_FLAGS_INIT
);
ret
=
RegisterSecurityOps
(
onlyRead
);
ret
=
RegisterSecurityOps
(
onlyRead
);
...
@@ -173,7 +173,7 @@ INIT_INNER_API void CloseParamWorkSpace(void)
...
@@ -173,7 +173,7 @@ INIT_INNER_API void CloseParamWorkSpace(void)
}
}
WORKSPACE_RW_LOCK
(
g_paramWorkSpace
);
WORKSPACE_RW_LOCK
(
g_paramWorkSpace
);
if
(
g_paramWorkSpace
.
workSpaceHashHandle
!=
NULL
)
{
if
(
g_paramWorkSpace
.
workSpaceHashHandle
!=
NULL
)
{
HashMapDestory
(
g_paramWorkSpace
.
workSpaceHashHandle
);
OH_
HashMapDestory
(
g_paramWorkSpace
.
workSpaceHashHandle
);
g_paramWorkSpace
.
workSpaceHashHandle
=
NULL
;
g_paramWorkSpace
.
workSpaceHashHandle
=
NULL
;
}
}
WORKSPACE_RW_UNLOCK
(
g_paramWorkSpace
);
WORKSPACE_RW_UNLOCK
(
g_paramWorkSpace
);
...
@@ -198,7 +198,7 @@ INIT_LOCAL_API int AddWorkSpace(const char *name, int onlyRead, uint32_t spaceSi
...
@@ -198,7 +198,7 @@ INIT_LOCAL_API int AddWorkSpace(const char *name, int onlyRead, uint32_t spaceSi
const
char
*
realName
=
WORKSPACE_NAME_NORMAL
;
const
char
*
realName
=
WORKSPACE_NAME_NORMAL
;
#endif
#endif
WORKSPACE_RW_LOCK
(
g_paramWorkSpace
);
WORKSPACE_RW_LOCK
(
g_paramWorkSpace
);
HashNode
*
node
=
HashMapGet
(
g_paramWorkSpace
.
workSpaceHashHandle
,
(
const
void
*
)
realName
);
HashNode
*
node
=
OH_
HashMapGet
(
g_paramWorkSpace
.
workSpaceHashHandle
,
(
const
void
*
)
realName
);
if
(
node
!=
NULL
)
{
if
(
node
!=
NULL
)
{
WORKSPACE_RW_UNLOCK
(
g_paramWorkSpace
);
WORKSPACE_RW_UNLOCK
(
g_paramWorkSpace
);
return
0
;
return
0
;
...
@@ -212,17 +212,17 @@ INIT_LOCAL_API int AddWorkSpace(const char *name, int onlyRead, uint32_t spaceSi
...
@@ -212,17 +212,17 @@ INIT_LOCAL_API int AddWorkSpace(const char *name, int onlyRead, uint32_t spaceSi
PARAM_CHECK
(
workSpace
!=
NULL
,
break
,
"Failed to create workspace for %s"
,
realName
);
PARAM_CHECK
(
workSpace
!=
NULL
,
break
,
"Failed to create workspace for %s"
,
realName
);
workSpace
->
flags
=
0
;
workSpace
->
flags
=
0
;
workSpace
->
area
=
NULL
;
workSpace
->
area
=
NULL
;
ListInit
(
&
workSpace
->
node
);
OH_
ListInit
(
&
workSpace
->
node
);
ret
=
ParamStrCpy
(
workSpace
->
fileName
,
size
,
realName
);
ret
=
ParamStrCpy
(
workSpace
->
fileName
,
size
,
realName
);
PARAM_CHECK
(
ret
==
0
,
break
,
"Failed to copy file name %s"
,
realName
);
PARAM_CHECK
(
ret
==
0
,
break
,
"Failed to copy file name %s"
,
realName
);
HASHMAPInitNode
(
&
workSpace
->
hashNode
);
HASHMAPInitNode
(
&
workSpace
->
hashNode
);
ret
=
InitWorkSpace
(
workSpace
,
onlyRead
,
spaceSize
);
ret
=
InitWorkSpace
(
workSpace
,
onlyRead
,
spaceSize
);
PARAM_CHECK
(
ret
==
0
,
break
,
"Failed to init workspace %s"
,
realName
);
PARAM_CHECK
(
ret
==
0
,
break
,
"Failed to init workspace %s"
,
realName
);
ret
=
HashMapAdd
(
g_paramWorkSpace
.
workSpaceHashHandle
,
&
workSpace
->
hashNode
);
ret
=
OH_
HashMapAdd
(
g_paramWorkSpace
.
workSpaceHashHandle
,
&
workSpace
->
hashNode
);
PARAM_CHECK
(
ret
==
0
,
CloseWorkSpace
(
workSpace
);
PARAM_CHECK
(
ret
==
0
,
CloseWorkSpace
(
workSpace
);
workSpace
=
NULL
;
workSpace
=
NULL
;
break
,
"Failed to add hash node"
);
break
,
"Failed to add hash node"
);
ListAddTail
(
&
g_paramWorkSpace
.
workSpaceList
,
&
workSpace
->
node
);
OH_
ListAddTail
(
&
g_paramWorkSpace
.
workSpaceList
,
&
workSpace
->
node
);
ret
=
0
;
ret
=
0
;
workSpace
=
NULL
;
workSpace
=
NULL
;
}
while
(
0
);
}
while
(
0
);
...
...
services/param/base/param_comm.c
浏览文件 @
7525b21e
...
@@ -34,7 +34,7 @@ INIT_LOCAL_API WorkSpace *GetWorkSpace(const char *name)
...
@@ -34,7 +34,7 @@ INIT_LOCAL_API WorkSpace *GetWorkSpace(const char *name)
#endif
#endif
WorkSpace
*
space
=
NULL
;
WorkSpace
*
space
=
NULL
;
WORKSPACE_RD_LOCK
(
*
paramSpace
);
WORKSPACE_RD_LOCK
(
*
paramSpace
);
HashNode
*
node
=
HashMapGet
(
paramSpace
->
workSpaceHashHandle
,
(
const
void
*
)
tmpName
);
HashNode
*
node
=
OH_
HashMapGet
(
paramSpace
->
workSpaceHashHandle
,
(
const
void
*
)
tmpName
);
if
(
node
!=
NULL
)
{
if
(
node
!=
NULL
)
{
space
=
HASHMAP_ENTRY
(
node
,
WorkSpace
,
hashNode
);
space
=
HASHMAP_ENTRY
(
node
,
WorkSpace
,
hashNode
);
}
}
...
@@ -63,7 +63,7 @@ INIT_LOCAL_API ParamTrieNode *GetTrieNodeByHandle(ParamHandle handle)
...
@@ -63,7 +63,7 @@ INIT_LOCAL_API ParamTrieNode *GetTrieNodeByHandle(ParamHandle handle)
int
hashCode
=
((
handle
>>
24
)
&
0x000000ff
);
// 24 left shift
int
hashCode
=
((
handle
>>
24
)
&
0x000000ff
);
// 24 left shift
uint32_t
index
=
handle
&
0x00ffffff
;
uint32_t
index
=
handle
&
0x00ffffff
;
WORKSPACE_RD_LOCK
(
*
paramSpace
);
WORKSPACE_RD_LOCK
(
*
paramSpace
);
HashNode
*
node
=
HashMapFind
(
paramSpace
->
workSpaceHashHandle
,
hashCode
,
(
const
void
*
)
&
index
,
CompareIndex
);
HashNode
*
node
=
OH_
HashMapFind
(
paramSpace
->
workSpaceHashHandle
,
hashCode
,
(
const
void
*
)
&
index
,
CompareIndex
);
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
WORKSPACE_RW_UNLOCK
(
*
paramSpace
);
WORKSPACE_RW_UNLOCK
(
*
paramSpace
);
PARAM_LOGV
(
"Failed to get workspace for 0x%x index %d hashCode %d"
,
handle
,
index
,
hashCode
);
PARAM_LOGV
(
"Failed to get workspace for 0x%x index %d hashCode %d"
,
handle
,
index
,
hashCode
);
...
...
services/param/base/param_trie.c
浏览文件 @
7525b21e
...
@@ -124,7 +124,7 @@ INIT_LOCAL_API void CloseWorkSpace(WorkSpace *workSpace)
...
@@ -124,7 +124,7 @@ INIT_LOCAL_API void CloseWorkSpace(WorkSpace *workSpace)
free
(
workSpace
);
free
(
workSpace
);
return
;
return
;
}
}
ListRemove
(
&
workSpace
->
node
);
OH_
ListRemove
(
&
workSpace
->
node
);
PARAM_CHECK
(
workSpace
->
area
!=
NULL
,
return
,
"The workspace area is null"
);
PARAM_CHECK
(
workSpace
->
area
!=
NULL
,
return
,
"The workspace area is null"
);
#ifdef WORKSPACE_AREA_NEED_MUTEX
#ifdef WORKSPACE_AREA_NEED_MUTEX
ParamRWMutexDelete
(
&
workSpace
->
rwlock
);
ParamRWMutexDelete
(
&
workSpace
->
rwlock
);
...
...
services/param/linux/param_service.c
浏览文件 @
7525b21e
...
@@ -240,16 +240,16 @@ static int32_t AddWatchNode(struct tagTriggerNode_ *trigger, const struct Trigge
...
@@ -240,16 +240,16 @@ static int32_t AddWatchNode(struct tagTriggerNode_ *trigger, const struct Trigge
PARAM_CHECK
(
watcher
!=
NULL
,
return
-
1
,
"Failed to get param watcher data"
);
PARAM_CHECK
(
watcher
!=
NULL
,
return
-
1
,
"Failed to get param watcher data"
);
if
(
extInfo
->
type
==
TRIGGER_PARAM_WAIT
)
{
if
(
extInfo
->
type
==
TRIGGER_PARAM_WAIT
)
{
WaitNode
*
node
=
(
WaitNode
*
)
trigger
;
WaitNode
*
node
=
(
WaitNode
*
)
trigger
;
ListInit
(
&
node
->
item
);
OH_
ListInit
(
&
node
->
item
);
node
->
timeout
=
extInfo
->
info
.
waitInfo
.
timeout
;
node
->
timeout
=
extInfo
->
info
.
waitInfo
.
timeout
;
node
->
stream
=
extInfo
->
stream
;
node
->
stream
=
extInfo
->
stream
;
node
->
waitId
=
extInfo
->
info
.
waitInfo
.
waitId
;
node
->
waitId
=
extInfo
->
info
.
waitInfo
.
waitId
;
ListAddTail
(
&
watcher
->
triggerHead
,
&
node
->
item
);
OH_
ListAddTail
(
&
watcher
->
triggerHead
,
&
node
->
item
);
}
else
{
}
else
{
WatchNode
*
node
=
(
WatchNode
*
)
trigger
;
WatchNode
*
node
=
(
WatchNode
*
)
trigger
;
ListInit
(
&
node
->
item
);
OH_
ListInit
(
&
node
->
item
);
node
->
watchId
=
extInfo
->
info
.
watchInfo
.
watchId
;
node
->
watchId
=
extInfo
->
info
.
watchInfo
.
watchId
;
ListAddTail
(
&
watcher
->
triggerHead
,
&
node
->
item
);
OH_
ListAddTail
(
&
watcher
->
triggerHead
,
&
node
->
item
);
}
}
return
0
;
return
0
;
}
}
...
@@ -401,7 +401,7 @@ PARAM_STATIC int OnIncomingConnect(LoopHandle loop, TaskHandle server)
...
@@ -401,7 +401,7 @@ PARAM_STATIC int OnIncomingConnect(LoopHandle loop, TaskHandle server)
ParamWatcher
*
watcher
=
(
ParamWatcher
*
)
ParamGetTaskUserData
(
client
);
ParamWatcher
*
watcher
=
(
ParamWatcher
*
)
ParamGetTaskUserData
(
client
);
PARAM_CHECK
(
watcher
!=
NULL
,
return
-
1
,
"Failed to get watcher"
);
PARAM_CHECK
(
watcher
!=
NULL
,
return
-
1
,
"Failed to get watcher"
);
ListInit
(
&
watcher
->
triggerHead
);
OH_
ListInit
(
&
watcher
->
triggerHead
);
watcher
->
stream
=
client
;
watcher
->
stream
=
client
;
#ifdef STARTUP_INIT_TEST
#ifdef STARTUP_INIT_TEST
g_paramService
.
watcherTask
=
client
;
g_paramService
.
watcherTask
=
client
;
...
...
services/param/trigger/trigger_manager.c
浏览文件 @
7525b21e
...
@@ -93,8 +93,8 @@ static TriggerNode *AddTriggerNode_(TriggerHeader *triggerHead,
...
@@ -93,8 +93,8 @@ static TriggerNode *AddTriggerNode_(TriggerHeader *triggerHead,
return
NULL
,
"Failed to copy conditition"
);
return
NULL
,
"Failed to copy conditition"
);
node
->
type
=
type
;
node
->
type
=
type
;
node
->
flags
=
0
;
node
->
flags
=
0
;
ListInit
(
&
node
->
node
);
OH_
ListInit
(
&
node
->
node
);
ListAddTail
(
&
triggerHead
->
triggerList
,
&
node
->
node
);
OH_
ListAddTail
(
&
triggerHead
->
triggerList
,
&
node
->
node
);
triggerHead
->
triggerCount
++
;
triggerHead
->
triggerCount
++
;
return
node
;
return
node
;
}
}
...
@@ -106,7 +106,7 @@ static int32_t AddJobNode_(TriggerNode *trigger, const TriggerExtInfo *extInfo)
...
@@ -106,7 +106,7 @@ static int32_t AddJobNode_(TriggerNode *trigger, const TriggerExtInfo *extInfo)
PARAM_CHECK
(
ret
==
EOK
,
return
-
1
,
"Failed to copy name for trigger"
);
PARAM_CHECK
(
ret
==
EOK
,
return
-
1
,
"Failed to copy name for trigger"
);
node
->
firstCmd
=
NULL
;
node
->
firstCmd
=
NULL
;
node
->
lastCmd
=
NULL
;
node
->
lastCmd
=
NULL
;
ret
=
HashMapAdd
(
GetTriggerWorkSpace
()
->
hashMap
,
&
node
->
hashNode
);
ret
=
OH_
HashMapAdd
(
GetTriggerWorkSpace
()
->
hashMap
,
&
node
->
hashNode
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to add hash node"
);
PARAM_CHECK
(
ret
==
0
,
return
-
1
,
"Failed to add hash node"
);
return
0
;
return
0
;
}
}
...
@@ -153,9 +153,9 @@ static void DelJobTrigger_(const TriggerWorkSpace *workSpace, TriggerNode *trigg
...
@@ -153,9 +153,9 @@ static void DelJobTrigger_(const TriggerWorkSpace *workSpace, TriggerNode *trigg
}
}
jobNode
->
lastCmd
=
NULL
;
jobNode
->
lastCmd
=
NULL
;
jobNode
->
firstCmd
=
NULL
;
jobNode
->
firstCmd
=
NULL
;
ListRemove
(
&
trigger
->
node
);
OH_
ListRemove
(
&
trigger
->
node
);
triggerHead
->
triggerCount
--
;
triggerHead
->
triggerCount
--
;
HashMapRemove
(
workSpace
->
hashMap
,
jobNode
->
name
);
OH_
HashMapRemove
(
workSpace
->
hashMap
,
jobNode
->
name
);
if
(
!
TRIGGER_IN_QUEUE
(
trigger
))
{
if
(
!
TRIGGER_IN_QUEUE
(
trigger
))
{
free
(
jobNode
);
free
(
jobNode
);
...
@@ -203,13 +203,13 @@ static void DelWatchTrigger_(const TriggerWorkSpace *workSpace, TriggerNode *tri
...
@@ -203,13 +203,13 @@ static void DelWatchTrigger_(const TriggerWorkSpace *workSpace, TriggerNode *tri
PARAM_CHECK
(
workSpace
!=
NULL
,
return
,
"Param is null"
);
PARAM_CHECK
(
workSpace
!=
NULL
,
return
,
"Param is null"
);
TriggerHeader
*
triggerHead
=
GetTriggerHeader
(
workSpace
,
trigger
->
type
);
TriggerHeader
*
triggerHead
=
GetTriggerHeader
(
workSpace
,
trigger
->
type
);
PARAM_CHECK
(
triggerHead
!=
NULL
,
return
,
"Failed to get header %d"
,
trigger
->
type
);
PARAM_CHECK
(
triggerHead
!=
NULL
,
return
,
"Failed to get header %d"
,
trigger
->
type
);
ListRemove
(
&
trigger
->
node
);
OH_
ListRemove
(
&
trigger
->
node
);
if
(
trigger
->
type
==
TRIGGER_PARAM_WAIT
)
{
if
(
trigger
->
type
==
TRIGGER_PARAM_WAIT
)
{
WaitNode
*
node
=
(
WaitNode
*
)
trigger
;
WaitNode
*
node
=
(
WaitNode
*
)
trigger
;
ListRemove
(
&
node
->
item
);
OH_
ListRemove
(
&
node
->
item
);
}
else
if
(
trigger
->
type
==
TRIGGER_PARAM_WATCH
)
{
}
else
if
(
trigger
->
type
==
TRIGGER_PARAM_WATCH
)
{
WatchNode
*
node
=
(
WatchNode
*
)
trigger
;
WatchNode
*
node
=
(
WatchNode
*
)
trigger
;
ListRemove
(
&
node
->
item
);
OH_
ListRemove
(
&
node
->
item
);
}
}
PARAM_LOGV
(
"DelWatchTrigger_ %s count %d"
,
GetTriggerName
(
trigger
),
triggerHead
->
triggerCount
);
PARAM_LOGV
(
"DelWatchTrigger_ %s count %d"
,
GetTriggerName
(
trigger
),
triggerHead
->
triggerCount
);
triggerHead
->
triggerCount
--
;
triggerHead
->
triggerCount
--
;
...
@@ -285,7 +285,7 @@ JobNode *UpdateJobTrigger(const TriggerWorkSpace *workSpace,
...
@@ -285,7 +285,7 @@ JobNode *UpdateJobTrigger(const TriggerWorkSpace *workSpace,
JobNode
*
GetTriggerByName
(
const
TriggerWorkSpace
*
workSpace
,
const
char
*
triggerName
)
JobNode
*
GetTriggerByName
(
const
TriggerWorkSpace
*
workSpace
,
const
char
*
triggerName
)
{
{
PARAM_CHECK
(
workSpace
!=
NULL
&&
triggerName
!=
NULL
,
return
NULL
,
"Invalid param"
);
PARAM_CHECK
(
workSpace
!=
NULL
&&
triggerName
!=
NULL
,
return
NULL
,
"Invalid param"
);
HashNode
*
node
=
HashMapGet
(
workSpace
->
hashMap
,
triggerName
);
HashNode
*
node
=
OH_
HashMapGet
(
workSpace
->
hashMap
,
triggerName
);
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -313,7 +313,7 @@ void ClearTrigger(const TriggerWorkSpace *workSpace, int8_t type)
...
@@ -313,7 +313,7 @@ void ClearTrigger(const TriggerWorkSpace *workSpace, int8_t type)
FreeTrigger
(
workSpace
,
trigger
);
FreeTrigger
(
workSpace
,
trigger
);
trigger
=
next
;
trigger
=
next
;
}
}
ListInit
(
&
head
->
triggerList
);
OH_
ListInit
(
&
head
->
triggerList
);
}
}
int
ExecuteQueuePush
(
TriggerWorkSpace
*
workSpace
,
const
TriggerNode
*
trigger
)
int
ExecuteQueuePush
(
TriggerWorkSpace
*
workSpace
,
const
TriggerNode
*
trigger
)
...
@@ -565,7 +565,7 @@ static int32_t CompareData_(const struct tagTriggerNode_ *trigger, const void *d
...
@@ -565,7 +565,7 @@ static int32_t CompareData_(const struct tagTriggerNode_ *trigger, const void *d
static
void
TriggerHeadSetDefault
(
TriggerHeader
*
head
)
static
void
TriggerHeadSetDefault
(
TriggerHeader
*
head
)
{
{
ListInit
(
&
head
->
triggerList
);
OH_
ListInit
(
&
head
->
triggerList
);
head
->
triggerCount
=
0
;
head
->
triggerCount
=
0
;
head
->
cmdNodeCount
=
0
;
head
->
cmdNodeCount
=
0
;
head
->
addTrigger
=
AddJobTrigger_
;
head
->
addTrigger
=
AddJobTrigger_
;
...
@@ -633,7 +633,7 @@ void InitTriggerHead(const TriggerWorkSpace *workSpace)
...
@@ -633,7 +633,7 @@ void InitTriggerHead(const TriggerWorkSpace *workSpace)
64
64
};
};
PARAM_CHECK
(
workSpace
!=
NULL
,
return
,
"Invalid workSpace"
);
PARAM_CHECK
(
workSpace
!=
NULL
,
return
,
"Invalid workSpace"
);
int
ret
=
HashMapCreate
((
HashMapHandle
*
)
&
workSpace
->
hashMap
,
&
info
);
int
ret
=
OH_
HashMapCreate
((
HashMapHandle
*
)
&
workSpace
->
hashMap
,
&
info
);
PARAM_CHECK
(
ret
==
0
,
return
,
"Failed to create hash map"
);
PARAM_CHECK
(
ret
==
0
,
return
,
"Failed to create hash map"
);
TriggerHeader
*
head
=
(
TriggerHeader
*
)
&
workSpace
->
triggerHead
[
TRIGGER_BOOT
];
TriggerHeader
*
head
=
(
TriggerHeader
*
)
&
workSpace
->
triggerHead
[
TRIGGER_BOOT
];
...
...
services/param/watcher/proxy/watcher_manager.cpp
浏览文件 @
7525b21e
...
@@ -173,7 +173,7 @@ void WatcherManager::AddParamWatcher(const std::string &keyPrefix, WatcherGroupP
...
@@ -173,7 +173,7 @@ void WatcherManager::AddParamWatcher(const std::string &keyPrefix, WatcherGroupP
std
::
lock_guard
<
std
::
mutex
>
lock
(
watcherMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
watcherMutex_
);
groupMap_
[
keyPrefix
]
=
groupId
;
groupMap_
[
keyPrefix
]
=
groupId
;
watchers_
[
watcher
->
GetWatcherId
()]
=
watcher
;
watchers_
[
watcher
->
GetWatcherId
()]
=
watcher
;
ListAddTail
(
group
->
GetWatchers
(),
watcher
->
GetGroupNode
());
OH_
ListAddTail
(
group
->
GetWatchers
(),
watcher
->
GetGroupNode
());
if
(
watcherGroups_
.
find
(
groupId
)
!=
watcherGroups_
.
end
())
{
if
(
watcherGroups_
.
find
(
groupId
)
!=
watcherGroups_
.
end
())
{
return
;
return
;
...
@@ -184,8 +184,8 @@ void WatcherManager::AddParamWatcher(const std::string &keyPrefix, WatcherGroupP
...
@@ -184,8 +184,8 @@ void WatcherManager::AddParamWatcher(const std::string &keyPrefix, WatcherGroupP
void
WatcherManager
::
DelParamWatcher
(
ParamWatcherPtr
watcher
)
void
WatcherManager
::
DelParamWatcher
(
ParamWatcherPtr
watcher
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
watcherMutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
watcherMutex_
);
ListRemove
(
watcher
->
GetGroupNode
());
OH_
ListRemove
(
watcher
->
GetGroupNode
());
ListInit
(
watcher
->
GetGroupNode
());
OH_
ListInit
(
watcher
->
GetGroupNode
());
watchers_
.
erase
(
watcher
->
GetWatcherId
());
watchers_
.
erase
(
watcher
->
GetWatcherId
());
WATCHER_LOGV
(
"DelParamWatcher watcherId %u"
,
watcher
->
GetWatcherId
());
WATCHER_LOGV
(
"DelParamWatcher watcherId %u"
,
watcher
->
GetWatcherId
());
}
}
...
...
services/param/watcher/proxy/watcher_manager.h
浏览文件 @
7525b21e
...
@@ -67,7 +67,7 @@ public:
...
@@ -67,7 +67,7 @@ public:
ParamWatcher
(
uint32_t
watcherId
,
const
sptr
<
IWatcher
>
&
watcher
,
const
WatcherGroupPtr
&
group
)
ParamWatcher
(
uint32_t
watcherId
,
const
sptr
<
IWatcher
>
&
watcher
,
const
WatcherGroupPtr
&
group
)
:
watcherId_
(
watcherId
),
watcher_
(
watcher
),
group_
(
group
)
:
watcherId_
(
watcherId
),
watcher_
(
watcher
),
group_
(
group
)
{
{
ListInit
(
&
groupNode_
);
OH_
ListInit
(
&
groupNode_
);
}
}
~
ParamWatcher
()
=
default
;
~
ParamWatcher
()
=
default
;
...
@@ -104,7 +104,7 @@ public:
...
@@ -104,7 +104,7 @@ public:
public:
public:
WatcherGroup
(
uint32_t
groupId
,
const
std
::
string
&
key
)
:
groupId_
(
groupId
),
keyPrefix_
(
key
)
WatcherGroup
(
uint32_t
groupId
,
const
std
::
string
&
key
)
:
groupId_
(
groupId
),
keyPrefix_
(
key
)
{
{
ListInit
(
&
watchers_
);
OH_
ListInit
(
&
watchers_
);
}
}
~
WatcherGroup
()
=
default
;
~
WatcherGroup
()
=
default
;
void
AddWatcher
(
const
ParamWatcherPtr
&
watcher
);
void
AddWatcher
(
const
ParamWatcherPtr
&
watcher
);
...
...
services/utils/init_hashmap.c
浏览文件 @
7525b21e
...
@@ -27,7 +27,7 @@ typedef struct {
...
@@ -27,7 +27,7 @@ typedef struct {
}
HashTab
;
}
HashTab
;
static
uint32_t
g_tableId
=
0
;
static
uint32_t
g_tableId
=
0
;
int32_t
HashMapCreate
(
HashMapHandle
*
handle
,
const
HashInfo
*
info
)
int32_t
OH_
HashMapCreate
(
HashMapHandle
*
handle
,
const
HashInfo
*
info
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
info
!=
NULL
&&
info
->
maxBucket
>
0
,
return
-
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
info
!=
NULL
&&
info
->
maxBucket
>
0
,
return
-
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
info
->
keyHash
!=
NULL
&&
info
->
nodeHash
!=
NULL
,
return
-
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
info
->
keyHash
!=
NULL
&&
info
->
nodeHash
!=
NULL
,
return
-
1
,
"Invalid param"
);
...
@@ -71,7 +71,7 @@ static HashNode *GetHashNodeByKey(const HashTab *tab, const HashNode *root, cons
...
@@ -71,7 +71,7 @@ static HashNode *GetHashNodeByKey(const HashTab *tab, const HashNode *root, cons
return
NULL
;
return
NULL
;
}
}
int32_t
HashMapAdd
(
HashMapHandle
handle
,
HashNode
*
node
)
int32_t
OH_
HashMapAdd
(
HashMapHandle
handle
,
HashNode
*
node
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
,
return
-
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
,
return
-
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
node
!=
NULL
&&
node
->
next
==
NULL
,
return
-
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
node
!=
NULL
&&
node
->
next
==
NULL
,
return
-
1
,
"Invalid param"
);
...
@@ -89,11 +89,11 @@ int32_t HashMapAdd(HashMapHandle handle, HashNode *node)
...
@@ -89,11 +89,11 @@ int32_t HashMapAdd(HashMapHandle handle, HashNode *node)
}
}
node
->
next
=
tab
->
buckets
[
hashCode
];
node
->
next
=
tab
->
buckets
[
hashCode
];
tab
->
buckets
[
hashCode
]
=
node
;
tab
->
buckets
[
hashCode
]
=
node
;
INIT_LOGV
(
"HashMapAdd tableId %d hashCode %d node %p"
,
tab
->
tableId
,
hashCode
,
node
);
INIT_LOGV
(
"
OH_
HashMapAdd tableId %d hashCode %d node %p"
,
tab
->
tableId
,
hashCode
,
node
);
return
0
;
return
0
;
}
}
void
HashMapRemove
(
HashMapHandle
handle
,
const
void
*
key
)
void
OH_
HashMapRemove
(
HashMapHandle
handle
,
const
void
*
key
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
key
!=
NULL
,
return
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
key
!=
NULL
,
return
,
"Invalid param"
);
HashTab
*
tab
=
(
HashTab
*
)
handle
;
HashTab
*
tab
=
(
HashTab
*
)
handle
;
...
@@ -119,7 +119,7 @@ void HashMapRemove(HashMapHandle handle, const void *key)
...
@@ -119,7 +119,7 @@ void HashMapRemove(HashMapHandle handle, const void *key)
}
}
}
}
HashNode
*
HashMapGet
(
HashMapHandle
handle
,
const
void
*
key
)
HashNode
*
OH_
HashMapGet
(
HashMapHandle
handle
,
const
void
*
key
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
key
!=
NULL
,
return
NULL
,
"Invalid param %s"
,
key
);
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
key
!=
NULL
,
return
NULL
,
"Invalid param %s"
,
key
);
HashTab
*
tab
=
(
HashTab
*
)
handle
;
HashTab
*
tab
=
(
HashTab
*
)
handle
;
...
@@ -146,7 +146,7 @@ static void HashListFree(HashTab *tab, HashNode *root)
...
@@ -146,7 +146,7 @@ static void HashListFree(HashTab *tab, HashNode *root)
}
}
}
}
void
HashMapDestory
(
HashMapHandle
handle
)
void
OH_
HashMapDestory
(
HashMapHandle
handle
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
,
return
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
,
return
,
"Invalid param"
);
HashTab
*
tab
=
(
HashTab
*
)
handle
;
HashTab
*
tab
=
(
HashTab
*
)
handle
;
...
@@ -156,7 +156,7 @@ void HashMapDestory(HashMapHandle handle)
...
@@ -156,7 +156,7 @@ void HashMapDestory(HashMapHandle handle)
free
(
tab
);
free
(
tab
);
}
}
HashNode
*
HashMapFind
(
HashMapHandle
handle
,
HashNode
*
OH_
HashMapFind
(
HashMapHandle
handle
,
int
hashCode
,
const
void
*
key
,
HashKeyCompare
keyCompare
)
int
hashCode
,
const
void
*
key
,
HashKeyCompare
keyCompare
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
key
!=
NULL
,
return
NULL
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
key
!=
NULL
,
return
NULL
,
"Invalid param"
);
...
@@ -167,7 +167,7 @@ HashNode *HashMapFind(HashMapHandle handle,
...
@@ -167,7 +167,7 @@ HashNode *HashMapFind(HashMapHandle handle,
return
GetHashNodeByKey
(
tab
,
tab
->
buckets
[
hashCode
],
key
,
keyCompare
);
return
GetHashNodeByKey
(
tab
,
tab
->
buckets
[
hashCode
],
key
,
keyCompare
);
}
}
void
HashMapTraverse
(
HashMapHandle
handle
,
void
(
*
hashNodeTraverse
)(
const
HashNode
*
node
,
const
void
*
context
),
void
OH_
HashMapTraverse
(
HashMapHandle
handle
,
void
(
*
hashNodeTraverse
)(
const
HashNode
*
node
,
const
void
*
context
),
const
void
*
context
)
const
void
*
context
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
hashNodeTraverse
!=
NULL
,
return
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
&&
hashNodeTraverse
!=
NULL
,
return
,
"Invalid param"
);
...
@@ -182,7 +182,7 @@ void HashMapTraverse(HashMapHandle handle, void (*hashNodeTraverse)(const HashNo
...
@@ -182,7 +182,7 @@ void HashMapTraverse(HashMapHandle handle, void (*hashNodeTraverse)(const HashNo
}
}
}
}
int
HashMapIsEmpty
(
HashMapHandle
handle
)
int
OH_
HashMapIsEmpty
(
HashMapHandle
handle
)
{
{
INIT_ERROR_CHECK
(
handle
!=
NULL
,
return
1
,
"Invalid param"
);
INIT_ERROR_CHECK
(
handle
!=
NULL
,
return
1
,
"Invalid param"
);
HashTab
*
tab
=
(
HashTab
*
)
handle
;
HashTab
*
tab
=
(
HashTab
*
)
handle
;
...
...
services/utils/list.c
浏览文件 @
7525b21e
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
* @param head list head, make sure head is valid pointer
* @param head list head, make sure head is valid pointer
* @return None
* @return None
*/
*/
void
ListInit
(
struct
ListNode
*
node
)
void
OH_
ListInit
(
struct
ListNode
*
node
)
{
{
if
(
node
==
NULL
)
{
if
(
node
==
NULL
)
{
return
;
return
;
...
@@ -43,7 +43,7 @@ void ListInit(struct ListNode *node)
...
@@ -43,7 +43,7 @@ void ListInit(struct ListNode *node)
* @param item new node to be added
* @param item new node to be added
* @return None
* @return None
*/
*/
void
ListAddTail
(
struct
ListNode
*
head
,
struct
ListNode
*
item
)
void
OH_
ListAddTail
(
struct
ListNode
*
head
,
struct
ListNode
*
item
)
{
{
if
(
head
==
NULL
||
item
==
NULL
)
{
if
(
head
==
NULL
||
item
==
NULL
)
{
return
;
return
;
...
@@ -61,7 +61,7 @@ void ListAddTail(struct ListNode *head, struct ListNode *item)
...
@@ -61,7 +61,7 @@ void ListAddTail(struct ListNode *head, struct ListNode *item)
* This function does not free any memory within item.
* This function does not free any memory within item.
* @return None
* @return None
*/
*/
void
ListRemove
(
struct
ListNode
*
item
)
void
OH_
ListRemove
(
struct
ListNode
*
item
)
{
{
if
(
item
==
NULL
)
{
if
(
item
==
NULL
)
{
return
;
return
;
...
@@ -81,7 +81,7 @@ void ListRemove(struct ListNode *item)
...
@@ -81,7 +81,7 @@ void ListRemove(struct ListNode *item)
* respectively less than, equal to, or greater than the second.
* respectively less than, equal to, or greater than the second.
* @return None
* @return None
*/
*/
void
ListAddWithOrder
(
struct
ListNode
*
head
,
struct
ListNode
*
item
,
ListCompareProc
compareProc
)
void
OH_
ListAddWithOrder
(
struct
ListNode
*
head
,
struct
ListNode
*
item
,
ListCompareProc
compareProc
)
{
{
ListNode
*
match
;
ListNode
*
match
;
int
ret
;
int
ret
;
...
@@ -117,7 +117,7 @@ void ListAddWithOrder(struct ListNode *head, struct ListNode *item, ListCompareP
...
@@ -117,7 +117,7 @@ void ListAddWithOrder(struct ListNode *head, struct ListNode *item, ListCompareP
* @param compareProc comparing function, return 0 if matched.
* @param compareProc comparing function, return 0 if matched.
* @return the found node; return NULL if none is found.
* @return the found node; return NULL if none is found.
*/
*/
ListNode
*
ListFind
(
const
ListNode
*
head
,
void
*
data
,
ListTraversalProc
compareProc
)
ListNode
*
OH_
ListFind
(
const
ListNode
*
head
,
void
*
data
,
ListTraversalProc
compareProc
)
{
{
ListNode
*
match
;
ListNode
*
match
;
if
((
head
==
NULL
)
||
(
compareProc
==
NULL
))
{
if
((
head
==
NULL
)
||
(
compareProc
==
NULL
))
{
...
@@ -152,7 +152,7 @@ ListNode *ListFind(const ListNode *head, void *data, ListTraversalProc comparePr
...
@@ -152,7 +152,7 @@ ListNode *ListFind(const ListNode *head, void *data, ListTraversalProc comparePr
* @return return -1 for invalid input arguments.
* @return return -1 for invalid input arguments.
* when TRAVERSE_STOP_WHEN_ERROR is specified, it will return errors from traversalProc
* when TRAVERSE_STOP_WHEN_ERROR is specified, it will return errors from traversalProc
*/
*/
int
ListTraversal
(
ListNode
*
head
,
void
*
data
,
ListTraversalProc
traversalProc
,
int
flags
)
int
OH_
ListTraversal
(
ListNode
*
head
,
void
*
data
,
ListTraversalProc
traversalProc
,
int
flags
)
{
{
int
ret
;
int
ret
;
ListNode
*
match
;
ListNode
*
match
;
...
@@ -203,14 +203,14 @@ static int listDestroyTraversal(ListNode *node, void *data)
...
@@ -203,14 +203,14 @@ static int listDestroyTraversal(ListNode *node, void *data)
* @param destroyProc destroy function; if NULL, it will free each node by default.
* @param destroyProc destroy function; if NULL, it will free each node by default.
* @return None
* @return None
*/
*/
void
ListRemoveAll
(
ListNode
*
head
,
ListDestroyProc
destroyProc
)
void
OH_
ListRemoveAll
(
ListNode
*
head
,
ListDestroyProc
destroyProc
)
{
{
if
(
head
==
NULL
)
{
if
(
head
==
NULL
)
{
return
;
return
;
}
}
ListTraversal
(
head
,
(
void
*
)
destroyProc
,
listDestroyTraversal
,
0
);
OH_
ListTraversal
(
head
,
(
void
*
)
destroyProc
,
listDestroyTraversal
,
0
);
ListInit
(
head
);
OH_
ListInit
(
head
);
}
}
/**
/**
...
@@ -219,7 +219,7 @@ void ListRemoveAll(ListNode *head, ListDestroyProc destroyProc)
...
@@ -219,7 +219,7 @@ void ListRemoveAll(ListNode *head, ListDestroyProc destroyProc)
* @param head list head, make sure head is valid pointer.
* @param head list head, make sure head is valid pointer.
* @return the count of nodes in the list; return 0 if error
* @return the count of nodes in the list; return 0 if error
*/
*/
int
ListGetCnt
(
const
ListNode
*
head
)
int
OH_
ListGetCnt
(
const
ListNode
*
head
)
{
{
int
cnt
;
int
cnt
;
ListNode
*
node
;
ListNode
*
node
;
...
...
test/unittest/init/group_unittest.cpp
浏览文件 @
7525b21e
...
@@ -108,54 +108,54 @@ HashInfo g_info = {
...
@@ -108,54 +108,54 @@ HashInfo g_info = {
HWTEST_F
(
InitGroupManagerUnitTest
,
TestHashMap
,
TestSize
.
Level1
)
HWTEST_F
(
InitGroupManagerUnitTest
,
TestHashMap
,
TestSize
.
Level1
)
{
{
HashMapHandle
handle
;
HashMapHandle
handle
;
HashMapCreate
(
&
handle
,
&
g_info
);
OH_
HashMapCreate
(
&
handle
,
&
g_info
);
const
char
*
str1
=
"Test hash map node 1"
;
const
char
*
str1
=
"Test hash map node 1"
;
const
char
*
str2
=
"Test hash map node 2"
;
const
char
*
str2
=
"Test hash map node 2"
;
const
char
*
str3
=
"Test hash map node 3"
;
const
char
*
str3
=
"Test hash map node 3"
;
TestHashNode
*
node1
=
TestCreateHashNode
(
str1
);
TestHashNode
*
node1
=
TestCreateHashNode
(
str1
);
TestHashNode
*
node2
=
TestCreateHashNode
(
str2
);
TestHashNode
*
node2
=
TestCreateHashNode
(
str2
);
HashMapAdd
(
handle
,
&
node1
->
node
);
OH_
HashMapAdd
(
handle
,
&
node1
->
node
);
HashMapAdd
(
handle
,
&
node2
->
node
);
OH_
HashMapAdd
(
handle
,
&
node2
->
node
);
HashNode
*
node
=
HashMapGet
(
handle
,
(
const
void
*
)
str1
);
HashNode
*
node
=
OH_
HashMapGet
(
handle
,
(
const
void
*
)
str1
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
if
(
node
)
{
if
(
node
)
{
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
str1
),
0
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
str1
),
0
);
}
}
node
=
HashMapGet
(
handle
,
(
const
void
*
)
str2
);
node
=
OH_
HashMapGet
(
handle
,
(
const
void
*
)
str2
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
if
(
node
)
{
if
(
node
)
{
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
str2
),
0
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
str2
),
0
);
}
}
TestHashNode
*
node3
=
TestCreateHashNode
(
str3
);
TestHashNode
*
node3
=
TestCreateHashNode
(
str3
);
HashMapAdd
(
handle
,
&
node3
->
node
);
OH_
HashMapAdd
(
handle
,
&
node3
->
node
);
node3
=
TestCreateHashNode
(
"Test hash map node 4"
);
node3
=
TestCreateHashNode
(
"Test hash map node 4"
);
HashMapAdd
(
handle
,
&
node3
->
node
);
OH_
HashMapAdd
(
handle
,
&
node3
->
node
);
node3
=
TestCreateHashNode
(
"Test hash map node 5"
);
node3
=
TestCreateHashNode
(
"Test hash map node 5"
);
HashMapAdd
(
handle
,
&
node3
->
node
);
OH_
HashMapAdd
(
handle
,
&
node3
->
node
);
node
=
HashMapGet
(
handle
,
(
const
void
*
)
str3
);
node
=
OH_
HashMapGet
(
handle
,
(
const
void
*
)
str3
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
if
(
node
)
{
if
(
node
)
{
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
str3
),
0
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
str3
),
0
);
}
}
TestHashNode
*
node4
=
TestCreateHashNode
(
"pre-init"
);
TestHashNode
*
node4
=
TestCreateHashNode
(
"pre-init"
);
HashMapAdd
(
handle
,
&
node4
->
node
);
OH_
HashMapAdd
(
handle
,
&
node4
->
node
);
const
char
*
act
=
"load_persist_props_action"
;
const
char
*
act
=
"load_persist_props_action"
;
TestHashNode
*
node5
=
TestCreateHashNode
(
act
);
TestHashNode
*
node5
=
TestCreateHashNode
(
act
);
HashMapAdd
(
handle
,
&
node5
->
node
);
OH_
HashMapAdd
(
handle
,
&
node5
->
node
);
HashMapRemove
(
handle
,
"pre-init"
);
OH_
HashMapRemove
(
handle
,
"pre-init"
);
node
=
HashMapGet
(
handle
,
(
const
void
*
)
act
);
node
=
OH_
HashMapGet
(
handle
,
(
const
void
*
)
act
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
EXPECT_NE
(
node
!=
nullptr
,
0
);
if
(
node
)
{
if
(
node
)
{
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
TestHashNode
*
tmp
=
HASHMAP_ENTRY
(
node
,
TestHashNode
,
node
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
act
),
0
);
EXPECT_EQ
(
strcmp
(
tmp
->
name
,
act
),
0
);
}
}
HashMapIsEmpty
(
handle
);
OH_
HashMapIsEmpty
(
handle
);
HashMapTraverse
(
handle
,
[](
const
HashNode
*
node
,
const
void
*
context
)
{
return
;},
nullptr
);
OH_
HashMapTraverse
(
handle
,
[](
const
HashNode
*
node
,
const
void
*
context
)
{
return
;},
nullptr
);
HashMapDestory
(
handle
);
OH_
HashMapDestory
(
handle
);
}
}
HWTEST_F
(
InitGroupManagerUnitTest
,
TestInitGroupMgrInit
,
TestSize
.
Level1
)
HWTEST_F
(
InitGroupManagerUnitTest
,
TestInitGroupMgrInit
,
TestSize
.
Level1
)
...
...
test/unittest/init/loopevent_unittest.cpp
浏览文件 @
7525b21e
...
@@ -194,7 +194,7 @@ public:
...
@@ -194,7 +194,7 @@ public:
EXPECT_EQ
(
GetNextBuffer
((
StreamTask
*
)
client
,
next
),
nullptr
);
EXPECT_EQ
(
GetNextBuffer
((
StreamTask
*
)
client
,
next
),
nullptr
);
ParamWatcher
*
watcher
=
(
ParamWatcher
*
)
ParamGetTaskUserData
(
client
);
ParamWatcher
*
watcher
=
(
ParamWatcher
*
)
ParamGetTaskUserData
(
client
);
PARAM_CHECK
(
watcher
!=
nullptr
,
return
,
"Failed to get watcher"
);
PARAM_CHECK
(
watcher
!=
nullptr
,
return
,
"Failed to get watcher"
);
ListInit
(
&
watcher
->
triggerHead
);
OH_
ListInit
(
&
watcher
->
triggerHead
);
OnClose
(
client
);
OnClose
(
client
);
LE_FreeBuffer
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
client
,
nullptr
);
LE_FreeBuffer
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
client
,
nullptr
);
return
;
return
;
...
...
test/unittest/init/service_unittest.cpp
浏览文件 @
7525b21e
...
@@ -48,7 +48,7 @@ public:
...
@@ -48,7 +48,7 @@ public:
};
};
HWTEST_F
(
ServiceUnitTest
,
TestDestoryHashMap
,
TestSize
.
Level1
)
HWTEST_F
(
ServiceUnitTest
,
TestDestoryHashMap
,
TestSize
.
Level1
)
{
{
HashMapDestory
(
GetInitWorkspace
()
->
hashMap
[
0
]);
OH_
HashMapDestory
(
GetInitWorkspace
()
->
hashMap
[
0
]);
}
}
HWTEST_F
(
ServiceUnitTest
,
case01
,
TestSize
.
Level1
)
HWTEST_F
(
ServiceUnitTest
,
case01
,
TestSize
.
Level1
)
{
{
...
...
test/unittest/param/paramservice_unittest.cpp
浏览文件 @
7525b21e
...
@@ -313,7 +313,7 @@ public:
...
@@ -313,7 +313,7 @@ public:
ParamWatcher
*
watcher
=
(
ParamWatcher
*
)
ParamGetTaskUserData
(
client
);
ParamWatcher
*
watcher
=
(
ParamWatcher
*
)
ParamGetTaskUserData
(
client
);
PARAM_CHECK
(
watcher
!=
NULL
,
return
NULL
,
"Failed to get watcher"
);
PARAM_CHECK
(
watcher
!=
NULL
,
return
NULL
,
"Failed to get watcher"
);
ListInit
(
&
watcher
->
triggerHead
);
OH_
ListInit
(
&
watcher
->
triggerHead
);
watcher
->
stream
=
client
;
watcher
->
stream
=
client
;
GetParamService
()
->
watcherTask
=
client
;
GetParamService
()
->
watcherTask
=
client
;
return
GetParamService
()
->
watcherTask
;
return
GetParamService
()
->
watcherTask
;
...
...
test/unittest/param/trigger_unittest.cpp
浏览文件 @
7525b21e
...
@@ -470,7 +470,7 @@ public:
...
@@ -470,7 +470,7 @@ public:
{
{
RegisterBootStateChange
(
BootStateChange
);
RegisterBootStateChange
(
BootStateChange
);
(
void
)
AddCompleteJob
(
"param:ohos.servicectrl.display"
,
"ohos.servicectrl.display=*"
,
"display system"
);
(
void
)
AddCompleteJob
(
"param:ohos.servicectrl.display"
,
"ohos.servicectrl.display=*"
,
"display system"
);
HashMapDestory
(
GetTriggerWorkSpace
()
->
hashMap
);
OH_
HashMapDestory
(
GetTriggerWorkSpace
()
->
hashMap
);
return
0
;
return
0
;
}
}
};
};
...
...
ueventd/standard/ueventd_parameter.c
浏览文件 @
7525b21e
...
@@ -54,8 +54,8 @@ static struct DeviceUdevConf *GetFristParameter(DeviceParameterCtrl *parameterCt
...
@@ -54,8 +54,8 @@ static struct DeviceUdevConf *GetFristParameter(DeviceParameterCtrl *parameterCt
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
if
(
!
ListEmpty
(
parameterCtrl
->
parameterList
))
{
if
(
!
ListEmpty
(
parameterCtrl
->
parameterList
))
{
conf
=
ListEntry
(
parameterCtrl
->
parameterList
.
next
,
struct
DeviceUdevConf
,
paramNode
);
conf
=
ListEntry
(
parameterCtrl
->
parameterList
.
next
,
struct
DeviceUdevConf
,
paramNode
);
ListRemove
(
&
conf
->
paramNode
);
OH_
ListRemove
(
&
conf
->
paramNode
);
ListInit
(
&
conf
->
paramNode
);
OH_
ListInit
(
&
conf
->
paramNode
);
}
}
pthread_mutex_unlock
(
&
(
parameterCtrl
->
parameterLock
));
pthread_mutex_unlock
(
&
(
parameterCtrl
->
parameterLock
));
return
conf
;
return
conf
;
...
@@ -93,7 +93,7 @@ static void *ThreadRun(void *data)
...
@@ -93,7 +93,7 @@ static void *ThreadRun(void *data)
if
(
SystemSetParameter
(
config
->
parameter
,
paramValue
)
!=
0
)
{
if
(
SystemSetParameter
(
config
->
parameter
,
paramValue
)
!=
0
)
{
INIT_LOGE
(
"[uevent] SystemSetParameter %s failed"
,
config
->
parameter
);
INIT_LOGE
(
"[uevent] SystemSetParameter %s failed"
,
config
->
parameter
);
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
ListAddTail
(
&
parameterCtrl
->
parameterList
,
&
config
->
paramNode
);
OH_
ListAddTail
(
&
parameterCtrl
->
parameterList
,
&
config
->
paramNode
);
pthread_mutex_unlock
(
&
(
parameterCtrl
->
parameterLock
));
pthread_mutex_unlock
(
&
(
parameterCtrl
->
parameterLock
));
parameterCtrl
->
empty
=
1
;
parameterCtrl
->
empty
=
1
;
}
}
...
@@ -105,7 +105,7 @@ static void AddParameter(DeviceParameterCtrl *parameterCtrl, struct DeviceUdevCo
...
@@ -105,7 +105,7 @@ static void AddParameter(DeviceParameterCtrl *parameterCtrl, struct DeviceUdevCo
{
{
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
if
(
ListEmpty
(
config
->
paramNode
))
{
if
(
ListEmpty
(
config
->
paramNode
))
{
ListAddTail
(
&
parameterCtrl
->
parameterList
,
&
config
->
paramNode
);
OH_
ListAddTail
(
&
parameterCtrl
->
parameterList
,
&
config
->
paramNode
);
}
}
pthread_mutex_unlock
(
&
(
parameterCtrl
->
parameterLock
));
pthread_mutex_unlock
(
&
(
parameterCtrl
->
parameterLock
));
if
(
parameterCtrl
->
threadId
==
0
)
{
if
(
parameterCtrl
->
threadId
==
0
)
{
...
...
ueventd/ueventd_read_cfg.c
浏览文件 @
7525b21e
...
@@ -108,8 +108,8 @@ static int ParseDeviceConfig(char *p)
...
@@ -108,8 +108,8 @@ static int ParseDeviceConfig(char *p)
}
else
{
}
else
{
config
->
parameter
=
NULL
;
config
->
parameter
=
NULL
;
}
}
ListInit
(
&
config
->
paramNode
);
OH_
ListInit
(
&
config
->
paramNode
);
ListAddTail
(
&
g_devices
,
&
config
->
list
);
OH_
ListAddTail
(
&
g_devices
,
&
config
->
list
);
FreeStringVector
(
items
,
count
);
FreeStringVector
(
items
,
count
);
return
0
;
return
0
;
}
}
...
@@ -143,7 +143,7 @@ static int ParseSysfsConfig(char *p)
...
@@ -143,7 +143,7 @@ static int ParseSysfsConfig(char *p)
"Invalid mode in config file for sys path %s. use default mode"
,
config
->
sysPath
);
"Invalid mode in config file for sys path %s. use default mode"
,
config
->
sysPath
);
config
->
uid
=
(
uid_t
)
DecodeUid
(
items
[
SYS_CONFIG_UID_NUM
]);
config
->
uid
=
(
uid_t
)
DecodeUid
(
items
[
SYS_CONFIG_UID_NUM
]);
config
->
gid
=
(
gid_t
)
DecodeGid
(
items
[
SYS_CONFIG_GID_NUM
]);
config
->
gid
=
(
gid_t
)
DecodeGid
(
items
[
SYS_CONFIG_GID_NUM
]);
ListAddTail
(
&
g_sysDevices
,
&
config
->
list
);
OH_
ListAddTail
(
&
g_sysDevices
,
&
config
->
list
);
FreeStringVector
(
items
,
count
);
FreeStringVector
(
items
,
count
);
return
0
;
return
0
;
}
}
...
@@ -161,7 +161,7 @@ static int ParseFirmwareConfig(char *p)
...
@@ -161,7 +161,7 @@ static int ParseFirmwareConfig(char *p)
INIT_CHECK
(
config
!=
NULL
,
errno
=
ENOMEM
;
INIT_CHECK
(
config
!=
NULL
,
errno
=
ENOMEM
;
return
-
1
);
return
-
1
);
config
->
fmPath
=
strdup
(
p
);
config
->
fmPath
=
strdup
(
p
);
ListAddTail
(
&
g_firmwares
,
&
config
->
list
);
OH_
ListAddTail
(
&
g_firmwares
,
&
config
->
list
);
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录