1 Star 0 Fork 49

yuguorui96/systemd_os

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch 2.06 KB
一键复制 编辑 原始数据 按行查看 历史
From 5209a26aa917aa54b09ee18394ad46ee601e77be Mon Sep 17 00:00:00 2001
From: Yuanhong Peng <yummypeng@linux.alibaba.com>
Date: Tue, 17 May 2022 21:34:34 +0800
Subject: [PATCH] test-catalog: Fix coredump when compiled under GCC10
According to the documentation:
https://gcc.gnu.org/gcc-9/porting_to.html#complit:
The `catalog_dirs` produced by STRV_MAKE(..) marco relies on
the extended lifetime feature which is fixed by GCC9.
Signed-off-by: Yuanhong Peng <yummypeng@linux.alibaba.com>
---
src/journal/test-catalog.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 0c4da29..2ce92af 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -201,7 +201,8 @@ static void test_catalog_file_lang(void) {
int main(int argc, char *argv[]) {
_cleanup_(unlink_tempfilep) char database[] = "/tmp/test-catalog.XXXXXX";
- _cleanup_free_ char *text = NULL, *catalog_dir = NULL;
+ _cleanup_free_ char *text = NULL;
+ char *catalog_dir = CATALOG_DIR;
int r;
setlocale(LC_ALL, "de_DE.UTF-8");
@@ -214,10 +215,9 @@ int main(int argc, char *argv[]) {
* If it is not, e.g. installed by systemd-tests package, then use installed catalogs. */
if (test_is_running_from_builddir(NULL)) {
assert_se(catalog_dir = path_join(NULL, ABS_BUILD_DIR, "catalog"));
- catalog_dirs = STRV_MAKE(catalog_dir);
- } else
- catalog_dirs = STRV_MAKE(CATALOG_DIR);
+ }
+ catalog_dirs = STRV_MAKE(catalog_dir);
assert_se(access(catalog_dirs[0], F_OK) >= 0);
log_notice("Using catalog directory '%s'", catalog_dirs[0]);
@@ -242,5 +242,9 @@ int main(int argc, char *argv[]) {
assert_se(catalog_get(database, SD_MESSAGE_COREDUMP, &text) >= 0);
printf(">>>%s<<<\n", text);
+ /* Only in this case, catalog_dir is malloced */
+ if (test_is_running_from_builddir(NULL))
+ free(catalog_dir);
+
return 0;
}
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuguorui96/systemd_os.git
git@gitee.com:yuguorui96/systemd_os.git
yuguorui96
systemd_os
systemd_os
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385