checkpatch: warn about uses of strcmp()/g_strcmp0()

Using strcmp()/g_strcmp0() for checking for string equality is hard
to read. We should prefer our streq variants -- unless, you really
mean cmp.
This commit is contained in:
Thomas Haller 2021-04-26 09:51:45 +02:00
parent 4d3de2721d
commit 23a200d19e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -190,6 +190,7 @@ complain ("XXX marker are reserved for development while work-in-progress. Use T
complain ("This gtk-doc annotation looks wrong") if $line =~ /\*.*\( *(transfer-(none|container|full)|allow none) *\) *(:|\()/;
complain ("Prefer nm_assert() or g_return*() to g_assert*()") if $line =~ /g_assert/ and (not $filename =~ /\/tests\//) and (not $filename =~ /\/nm-test-/);
complain ("Use gs_free_error with GError variables") if $line =~ /\bgs_free\b +GError *\*/;
complain ("Don't use strcmp/g_strcmp0 unless you need to sort. Consider nm_streq()/nm_streq0(),NM_IN_STRSET() for testing equality") if $line =~ /\b(strcmp|g_strcmp0)\b/;
#complain ("Use spaces instead of tabs") if $line =~ /\t/;
# Further on we process stuff without comments.