Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译报错may be used uninitialized in this function #76

Open
longforrich opened this issue Nov 14, 2022 · 1 comment
Open

编译报错may be used uninitialized in this function #76

longforrich opened this issue Nov 14, 2022 · 1 comment

Comments

@longforrich
Copy link

rule.c:190:17: error: ‘rtail may be used uninitialized in this function [-Werror=maybe-uninitialized]
rtail->next = a;
~~~~~~~~~~~~^~~

从代码里看
scws/libscws/rule.c@scws_rule_new里
rule_attr_t a, rtail; // 此处rtail未做初始化
...
/* append to the chain list */
if (r->attr == NULL)
r->attr = rtail = a;
else
{
rtail->next = a; // 此处使用了未初始化的变量
rtail = a;
}
建议改成:
rule_attr_t a, rtail = NULL;
...
else
{
if (rtail)
rtail->next = a;
rtail = a;
}

@longforrich
Copy link
Author

暂时通过增加编译参数-no-undefined绕过

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant