在 2023/7/31 14:34, Dan Carpenter 写道:
Hello Peng Zhang, This is a semi-automatic email about new static checker warnings. The patch d126b5d9410f: "maple_tree: make mas_validate_gaps() to check metadata" from Jul 11, 2023, leads to the following Smatch complaint: tools/testing/radix-tree/../../../lib/maple_tree.c:6989 mas_validate_gaps() warn: variable dereferenced before check 'gaps' (see line 6983) tools/testing/radix-tree/../../../lib/maple_tree.c 6982 6983 if (gaps[offset] != max_gap) { ^^^^^ Dereferenced. 6984 pr_err("gap %p[%u] is not the largest gap %lu\n", 6985 node, offset, max_gap); 6986 MT_BUG_ON(mas->tree, 1); 6987 } 6988 6989 MT_BUG_ON(mas->tree, !gaps); ^^^^^ Checked too late. This is pointless as well. Just delete this line.
Since this is a validator, it is only used for testing, so it will not have any impact on normal functionality. I'm not going to delete this line, will move it before dereferencing. Thank you for your report. Thanks, Peng
6990 for (i++ ; i < mt_slot_count(mte); i++) { 6991 if (gaps[i] != 0) { regards, dan carpenter