Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
2fa85a2c
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2fa85a2c
编写于
12月 08, 2021
作者:
O
openharmony_ci
提交者:
Gitee
12月 08, 2021
浏览文件
操作
浏览文件
下载
差异文件
!703 fix: 解决dmesg -s参数double lock问题
Merge pull request !703 from Kiita/1109_dmesg
上级
14421486
e1512566
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
14 deletion
+35
-14
shell/full/src/cmds/dmesg.c
shell/full/src/cmds/dmesg.c
+35
-14
未找到文件。
shell/full/src/cmds/dmesg.c
浏览文件 @
2fa85a2c
...
...
@@ -177,13 +177,17 @@ STATIC INT32 OsCopyToNew(const VOID *addr, UINT32 size)
CHAR
*
newBuf
=
(
CHAR
*
)
addr
+
sizeof
(
DmesgInfo
);
UINT32
bufSize
=
size
-
sizeof
(
DmesgInfo
);
INT32
ret
;
UINT32
intSave
;
LOS_SpinLockSave
(
&
g_dmesgSpin
,
&
intSave
);
if
(
g_dmesgInfo
->
logSize
==
0
)
{
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
return
0
;
}
temp
=
(
CHAR
*
)
malloc
(
g_dmesgInfo
->
logSize
);
if
(
temp
==
NULL
)
{
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
return
-
1
;
}
...
...
@@ -195,21 +199,24 @@ STATIC INT32 OsCopyToNew(const VOID *addr, UINT32 size)
ret
=
OsDmesgRead
(
temp
,
g_dmesgInfo
->
logSize
);
if
(
ret
<=
0
)
{
PRINT_ERR
(
"%s,%d failed, err:%d!
\n
"
,
__FUNCTION__
,
__LINE__
,
ret
);
free
(
temp
);
return
-
1
;
goto
FREE_OUT
;
}
/* if new buf size smaller than logSize */
ret
=
memcpy_s
(
newBuf
,
bufSize
,
temp
+
copyStart
,
copyLen
);
if
(
ret
!=
EOK
)
{
PRINT_ERR
(
"%s,%d memcpy_s failed, err:%d!
\n
"
,
__FUNCTION__
,
__LINE__
,
ret
);
free
(
temp
);
return
-
1
;
goto
FREE_OUT
;
}
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
free
(
temp
);
return
(
INT32
)
copyLen
;
FREE_OUT:
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
PRINT_ERR
(
"%s,%d failed, err:%d!
\n
"
,
__FUNCTION__
,
__LINE__
,
ret
);
free
(
temp
);
return
-
1
;
}
STATIC
UINT32
OsDmesgResetMem
(
const
VOID
*
addr
,
UINT32
size
)
...
...
@@ -224,12 +231,13 @@ STATIC UINT32 OsDmesgResetMem(const VOID *addr, UINT32 size)
LOS_SpinLockSave
(
&
g_dmesgSpin
,
&
intSave
);
temp
=
g_dmesgInfo
;
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
copyLen
=
OsCopyToNew
(
addr
,
size
);
if
(
copyLen
<
0
)
{
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
return
LOS_NOK
;
}
LOS_SpinLockSave
(
&
g_dmesgSpin
,
&
intSave
);
g_logBufSize
=
size
-
sizeof
(
DmesgInfo
);
g_dmesgInfo
=
(
DmesgInfo
*
)
addr
;
g_dmesgInfo
->
logBuf
=
(
CHAR
*
)
addr
+
sizeof
(
DmesgInfo
);
...
...
@@ -239,12 +247,17 @@ STATIC UINT32 OsDmesgResetMem(const VOID *addr, UINT32 size)
/* if old mem came from malloc */
if
(
temp
==
g_mallocAddr
)
{
g_mallocAddr
=
NULL
;
free
(
temp
);
goto
FREE_OUT
;
}
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
return
LOS_OK
;
FREE_OUT:
g_mallocAddr
=
NULL
;
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
free
(
temp
);
return
LOS_OK
;
}
STATIC
UINT32
OsDmesgChangeSize
(
UINT32
size
)
...
...
@@ -265,14 +278,14 @@ STATIC UINT32 OsDmesgChangeSize(UINT32 size)
LOS_SpinLockSave
(
&
g_dmesgSpin
,
&
intSave
);
temp
=
g_dmesgInfo
;
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
copyLen
=
OsCopyToNew
(
newString
,
size
+
sizeof
(
DmesgInfo
));
if
(
copyLen
<
0
)
{
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
free
(
newString
);
return
LOS_NOK
;
goto
ERR_OUT
;
}
LOS_SpinLockSave
(
&
g_dmesgSpin
,
&
intSave
);
g_logBufSize
=
size
;
g_dmesgInfo
=
(
DmesgInfo
*
)
newString
;
g_dmesgInfo
->
logBuf
=
(
CHAR
*
)
newString
+
sizeof
(
DmesgInfo
);
...
...
@@ -281,13 +294,21 @@ STATIC UINT32 OsDmesgChangeSize(UINT32 size)
g_dmesgInfo
->
logHead
=
0
;
if
(
temp
==
g_mallocAddr
)
{
g_mallocAddr
=
NULL
;
free
(
temp
);
goto
FREE_OUT
;
}
g_mallocAddr
=
newString
;
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
return
LOS_OK
;
ERR_OUT:
free
(
newString
);
return
LOS_NOK
;
FREE_OUT:
g_mallocAddr
=
newString
;
LOS_SpinUnlockRestore
(
&
g_dmesgSpin
,
intSave
);
free
(
temp
);
return
LOS_OK
;
}
UINT32
OsCheckConsoleLock
(
VOID
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录