]> Savannah Git Hosting - gnulib.git/commitdiff
useless-if-before-free: Check for nullptr.
authorCollin Funk <collin.funk1@gmail.com>
Mon, 17 Jun 2024 03:45:33 +0000 (20:45 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Mon, 17 Jun 2024 03:45:33 +0000 (20:45 -0700)
* build-aux/useless-if-before-free (is_NULL): Add nullptr to the
condition.
(foo): Add nullptr to the regular expressions.

ChangeLog
build-aux/useless-if-before-free

index 52c07bde4f8d1c5097f816f6fd9f03b6bf6f20f3..7cff764b3822f341744e8e3f394ef31ecd09a1de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-06-16  Collin Funk  <collin.funk1@gmail.com>
+
+       useless-if-before-free: Check for nullptr.
+       * build-aux/useless-if-before-free (is_NULL): Add nullptr to the
+       condition.
+       (foo): Add nullptr to the regular expressions.
+
 2024-06-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        nstrftime: omit never-used code
index ac9c890170c9ea7a8181e540a3cc61ab08ea0561..968e53062cbe1dfb5e23af838fc44ce00b010fac 100755 (executable)
@@ -36,7 +36,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2022-01-27 18:51'; # UTC
+my $VERSION = '2024-06-17 03:44'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -106,7 +106,7 @@ EOF
 sub is_NULL ($)
 {
   my ($expr) = @_;
-  return ($expr eq 'NULL' || $expr eq '0');
+  return ($expr eq 'NULL' || $expr eq 'nullptr' || $expr eq '0');
 }
 
 {
@@ -211,7 +211,7 @@ free=xfree
 git grep -l -z "$free *(" \
   | xargs -0 useless-if-before-free -l --name="$free" \
   | xargs -0 perl -0x3b -pi -e \
-   's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s'
+   's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL|nullptr))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s'
 
 # Use the following to remove redundant uses of kfree inside braces.
 # Note that -0777 puts perl in slurp-whole-file mode;
@@ -220,7 +220,7 @@ free=kfree
 git grep -l -z "$free *(" \
   | xargs -0 useless-if-before-free -l --name="$free" \
   | xargs -0 perl -0777 -pi -e \
-     's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s*\{\s*('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\);)\s*\}[^\n]*$/$2/gms'
+     's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL|nullptr))?\s*\)\s*\{\s*('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\);)\s*\}[^\n]*$/$2/gms'
 
 Be careful that the result of the above transformation is valid.
 If the matched string is followed by "else", then obviously, it won't be.