提交 fb8446d9 编写于 作者: J Julia Suvorova 提交者: Paolo Bonzini

checkpatch: add a warning for basename/dirname

g_path_get_* do the same as g_strdup(basename/dirname(...)) but
without modifying the argument.
Signed-off-by: NJulia Suvorova <jusual@mail.ru>
Message-Id: <1519987399-19160-1-git-send-email-jusual@mail.ru>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 db84fd97
...@@ -2584,6 +2584,11 @@ sub process { ...@@ -2584,6 +2584,11 @@ sub process {
ERROR("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); ERROR("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr);
} }
# recommend g_path_get_* over g_strdup(basename/dirname(...))
if ($line =~ /\bg_strdup\s*\(\s*(basename|dirname)\s*\(/) {
WARN("consider using g_path_get_$1() in preference to g_strdup($1())\n" . $herecurr);
}
# recommend qemu_strto* over strto* for numeric conversions # recommend qemu_strto* over strto* for numeric conversions
if ($line =~ /\b(strto[^kd].*?)\s*\(/) { if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr); ERROR("consider using qemu_$1 in preference to $1\n" . $herecurr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册