scws icon indicating copy to clipboard operation
scws copied to clipboard

编译报错may be used uninitialized in this function

Open longforrich opened this issue 2 years ago • 1 comments

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 avatar Nov 14 '22 06:11 longforrich

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

longforrich avatar Nov 14 '22 06:11 longforrich