From: Julia Suvorova <jus...@mail.ru>

g_path_get_* do the same as g_strdup(basename/dirname(...)) but
without modifying the argument.

Signed-off-by: Julia Suvorova <jus...@mail.ru>
Message-Id: <1519987399-19160-1-git-send-email-jus...@mail.ru>
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1b4b812..a88af61 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2584,6 +2584,11 @@ sub process {
                        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
                if ($line =~ /\b(strto[^kd].*?)\s*\(/) {
                        ERROR("consider using qemu_$1 in preference to $1\n" . 
$herecurr);
-- 
1.8.3.1



Reply via email to