diff options
| author | Paolo Bonzini | 2022-04-06 14:27:52 +0200 |
|---|---|---|
| committer | Paolo Bonzini | 2022-05-12 12:07:05 +0200 |
| commit | dfdb4f3c28737879685398c4a610a220e1ecf9c2 (patch) | |
| tree | 4084a329f1bb8d72bf1e31f8eea4eb0de75c86d8 /scripts | |
| parent | target/i386: do not consult nonexistent host leaves (diff) | |
| download | qemu-dfdb4f3c28737879685398c4a610a220e1ecf9c2.tar.gz qemu-dfdb4f3c28737879685398c4a610a220e1ecf9c2.tar.xz qemu-dfdb4f3c28737879685398c4a610a220e1ecf9c2.zip | |
checkpatch: fix g_malloc check
Use the string equality operator "eq", and ensure that $1 is defined by
using "(try|)" instead of "(try)?". The alternative "((?:try)?)" is
longer and less readable.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4763d02ae7..d900d18048 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2831,8 +2831,8 @@ sub process { } # check for pointless casting of g_malloc return - if ($line =~ /\*\s*\)\s*g_(try)?(m|re)alloc(0?)(_n)?\b/) { - if ($2 == 'm') { + if ($line =~ /\*\s*\)\s*g_(try|)(m|re)alloc(0?)(_n)?\b/) { + if ($2 eq 'm') { ERROR("unnecessary cast may hide bugs, use g_$1new$3 instead\n" . $herecurr); } else { ERROR("unnecessary cast may hide bugs, use g_$1renew$3 instead\n" . $herecurr); |
