# GDB script to list of problems using awk.
#
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 Free Software Foundation, Inc.
#
# This file is part of GDB.
#
# Make certain that the script is not running in an internationalized
# environment.
-LANG=c ; export LANG
-LC_ALL=c ; export LC_ALL
+LANG=C ; export LANG
+LC_ALL=C ; export LC_ALL
# Permanent checks take the form:
errors="${errors} error[ari_${e}] = 1;"
done
-if [ "$AWK" == "" ] ; then
+if [ "$AWK" = "" ] ; then
AWK=awk
fi
# Things in comments
-BEGIN { doc["GNU/Linux"] = "\
-Do not use `Linux'\'', instead use `Linux kernel'\'' or `GNU/Linux system'\'';\
- comments should clearly differentiate between the two (this test assumes that\
- word `Linux'\'' appears on the same line as the word `GNU'\'' or `kernel'\''\
- or a kernel version"
- category["GNU/Linux"] = ari_comment
-}
-/(^|[^_[:alnum:]])Linux([^_[:alnum:]]|$)/ \
-&& !/(^|[^_[:alnum:]])Linux\[sic\]([^_[:alnum:]]|$)/ \
-&& !/(^|[^_[:alnum:]])GNU\/Linux([^_[:alnum:]]|$)/ \
-&& !/(^|[^_[:alnum:]])Linux kernel([^_[:alnum:]]|$)/ \
-&& !/(^|[^_[:alnum:]])Linux [:digit:]\.[:digit:]+)/ {
- fail("GNU/Linux")
-}
-
BEGIN { doc["ARGSUSED"] = "\
Do not use ARGSUSED, unnecessary"
category["ARGSUSED"] = ari_regression
fail("assert.h")
}
-BEGIN { doc["dirent.h"] = "\
-Do not include dirent.h, instead include gdb_dirent.h"
- category["dirent.h"] = ari_regression
-}
-/^#[[:space:]]*include[[:space:]]*.dirent\.h./ {
- fail("dirent.h")
-}
-
BEGIN { doc["regex.h"] = "\
Do not include regex.h, instead include gdb_regex.h"
category["regex.h"] = ari_regression
fail("gnu regex.h")
}
-BEGIN { doc["stat.h"] = "\
-Do not include stat.h or sys/stat.h, instead include gdb_stat.h"
- category["stat.h"] = ari_regression
- fix("stat.h", "gdb/gdb_stat.h", 1)
-}
-/^#[[:space:]]*include[[:space:]]*.stat\.h./ \
-|| /^#[[:space:]]*include[[:space:]]*.sys\/stat\.h./ {
- fail("stat.h")
-}
-
BEGIN { doc["wait.h"] = "\
Do not include wait.h or sys/wait.h, instead include gdb_wait.h"
- fix("wait.h", "gdb/gdb_wait.h", 2);
+ fix("wait.h", "common/gdb_wait.h", 2);
category["wait.h"] = ari_regression
}
/^#[[:space:]]*include[[:space:]]*.wait\.h./ \
BEGIN { doc["__func__"] = "\
Do not use __func__, ISO C 90 does not support this macro"
category["__func__"] = ari_regression
- fix("__func__", "gdb/gdb_assert.h", 1)
+ fix("__func__", "common/gdb_assert.h", 1)
}
/(^|[^_[:alnum:]])__func__([^_[:alnum:]]|$)/ {
fail("__func__")
editCase_full_line = ""
}
(possible_editCase) {
- if (ARI_OK == "ediCase function") {
+ if (ARI_OK == "editCase function") {
possible_editCase = 0
}
# Closing brace found?
Do not use &&, or || at the end of a line"
category["OP eol"] = ari_code
}
-/(\|\||\&\&|==|!=)[[:space:]]*$/ {
+# * operator needs a special treatment as it can be a
+# valid end of line for a pointer type definition
+# Only catch case where an assignment or an opening brace is present
+/(\|\||\&\&|==|!=|[[:space:]][+\-\/])[[:space:]]*$/ \
+|| /(\(|=)[[:space:]].*[[:space:]]\*[[:space:]]*$/ {
fail("OP eol")
}
Do not use strerror(), instead use safe_strerror()"
category["strerror"] = ari_regression
fix("strerror", "gdb/gdb_string.h", 1)
- fix("strerror", "gdb/mingw-hdep.c", 1)
- fix("strerror", "gdb/posix-hdep.c", 1)
+ fix("strerror", "gdb/common/mingw-strerror.c", 1)
+ fix("strerror", "gdb/common/posix-strerror.c", 1)
}
/(^|[^_[:alnum:]])strerror[[:space:]]*\(/ {
fail("strerror")
BEGIN { doc["SOLIB_ADD"] = "\
Replace SOLIB_ADD with nothing, not needed?"
- category["SOLIB_ADD"] = ari_deprecate
+ category["SOLIB_ADD"] = ari_regression
}
/(^|[^_[:alnum:]])SOLIB_ADD([^_[:alnum:]]|$)/ {
fail("SOLIB_ADD")
BEGIN { doc["SOLIB_CREATE_INFERIOR_HOOK"] = "\
Replace SOLIB_CREATE_INFERIOR_HOOK with nothing, not needed?"
- category["SOLIB_CREATE_INFERIOR_HOOK"] = ari_deprecate
+ category["SOLIB_CREATE_INFERIOR_HOOK"] = ari_regression
}
/(^|[^_[:alnum:]])SOLIB_CREATE_INFERIOR_HOOK([^_[:alnum:]]|$)/ {
fail("SOLIB_CREATE_INFERIOR_HOOK")
BEGIN { doc["PC_SOLIB"] = "\
Replace PC_SOLIB with nothing, not needed?"
- category["PC_SOLIB"] = ari_deprecate
+ category["PC_SOLIB"] = ari_regression
}
/(^|[^_[:alnum:]])PC_SOLIB([^_[:alnum:]]|$)/ {
fail("PC_SOLIB")
category["write_pc"] = ari_deprecate
}
/(^|[^_[:alnum:]])write_pc[[:space:]]*\(/ || \
-/(^|[^_[:alnum:]])set_gdbarch_write_pc[[:space:]]*\(/ || \
/(^|[^_[:alnum:]])TARGET_WRITE_PC[[:space:]]*\(/ {
fail("write_pc")
}
BEGIN { doc["vasprintf"] = "\
Do not use vasprintf(), instead use xstrvprintf"
- fix("vasprintf", "gdb/utils.c", 1)
+ fix("vasprintf", "common/common-utils.c", 1)
category["vasprintf"] = ari_regression
}
/(^|[^_[:alnum:]])vasprintf[[:space:]]*\(/ {
fail("vasprintf")
}
-BEGIN { doc["xasprintf"] = "\
-Do not use xasprintf(), instead use xstrprintf"
- fix("xasprintf", "gdb/defs.h", 1)
- fix("xasprintf", "gdb/utils.c", 1)
- category["xasprintf"] = ari_regression
-}
-/(^|[^_[:alnum:]])xasprintf[[:space:]]*\(/ {
- fail("xasprintf")
-}
-
-BEGIN { doc["xvasprintf"] = "\
-Do not use xvasprintf(), instead use xstrvprintf"
- fix("xvasprintf", "gdb/defs.h", 1)
- fix("xvasprintf", "gdb/utils.c", 1)
- category["xvasprintf"] = ari_regression
-}
-/(^|[^_[:alnum:]])xvasprintf[[:space:]]*\(/ {
- fail("xvasprintf")
-}
-
# More generic memory operations
BEGIN { doc["bzero"] = "\
fix("var_boolean", "cli/cli-decode.c", 2)
}
/(^|[^_[:alnum:]])var_boolean([^_[:alnum:]]|$)/ {
- if ($0 !~ /(^|[^_[:alnum:]])case *var_boolean:/) {
+ if (($0 !~ /(^|[^_[:alnum:]])case *var_boolean:/) \
+ && ($0 !~ /(^|[^_[:alnum:]])[=!]= *var_boolean/)) {
fail("var_boolean")
}
}