updated checkpatch.pl to last version
authorJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 7 May 2012 11:33:10 +0000 (11:33 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 7 May 2012 11:33:10 +0000 (11:33 +0000)
footer is now retrieve from a file

18 files changed:
configure
configure.ac
po/Makefile
po/Makefile.in
po/fr.po
po/ppastats.pot
src/html.c
src/io.c
src/io.h
src/lp_json.h
src/lp_ws.c
src/main.c
src/ppastats.1
tests/checkpatch.pl
www/Makefile.am
www/Makefile.in
www/footer.tpl [new file with mode: 0644]
www/footer.tpl.in [new file with mode: 0644]

index a1ff7ea..15effbb 100755 (executable)
--- a/configure
+++ b/configure
@@ -6853,7 +6853,7 @@ fi
 
 
 
-ac_config_files="$ac_config_files po/Makefile.in Makefile src/Makefile tests/Makefile www/Makefile"
+ac_config_files="$ac_config_files po/Makefile.in Makefile src/Makefile tests/Makefile www/footer.tpl www/Makefile"
 
 
 for ac_prog in help2man
@@ -7643,6 +7643,7 @@ do
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
     "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
+    "www/footer.tpl") CONFIG_FILES="$CONFIG_FILES www/footer.tpl" ;;
     "www/Makefile") CONFIG_FILES="$CONFIG_FILES www/Makefile" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
index 8cbeefd..1e6be59 100644 (file)
@@ -38,7 +38,8 @@ AC_CONFIG_FILES([ po/Makefile.in
  Makefile
  src/Makefile
  tests/Makefile
- www/Makefile
+ www/footer.tpl
+ www/Makefile 
 ])
 
 AC_CHECK_PROGS([HELP2MAN], [help2man])
index 97f7a5c..69bf449 100644 (file)
@@ -35,12 +35,12 @@ INSTALL_DATA = ${INSTALL} -m 644
 # We use $(mkdir_p).
 # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
 # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
-# ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh does not start with $(SHELL), so we add it.
+# ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh does not start with $(SHELL), so we add it.
 # In automake >= 1.10, /bin/mkdir -p is derived from ${MKDIR_P}, which is defined
 # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
 # versions, $(mkinstalldirs) and $(install_sh) are unused.
-mkinstalldirs = $(SHELL) ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh -d
-install_sh = $(SHELL) ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh
+mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh -d
+install_sh = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh
 MKDIR_P = /bin/mkdir -p
 mkdir_p = /bin/mkdir -p
 
index d9e7f1a..cbbdd55 100644 (file)
@@ -35,12 +35,12 @@ INSTALL_DATA = ${INSTALL} -m 644
 # We use $(mkdir_p).
 # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
 # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
-# ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh does not start with $(SHELL), so we add it.
+# ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh does not start with $(SHELL), so we add it.
 # In automake >= 1.10, /bin/mkdir -p is derived from ${MKDIR_P}, which is defined
 # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
 # versions, $(mkinstalldirs) and $(install_sh) are unused.
-mkinstalldirs = $(SHELL) ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh -d
-install_sh = $(SHELL) ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh
+mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh -d
+install_sh = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/ppastats/trunk/install-sh
 MKDIR_P = /bin/mkdir -p
 mkdir_p = /bin/mkdir -p
 
index 6b1efaf..8950d02 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: ppastats 0.0.x\n"
 "Report-Msgid-Bugs-To: jeanfi@gmail.com\n"
-"POT-Creation-Date: 2012-05-06 13:01+0200\n"
+"POT-Creation-Date: 2012-05-07 13:30+0200\n"
 "PO-Revision-Date: 2012-05-05 23:45+0200\n"
 "Last-Translator:  <jeanfi@gmail.com>\n"
 "Language-Team: French\n"
@@ -31,17 +31,17 @@ msgstr ""
 msgid "exceed cache capacity"
 msgstr ""
 
-#: src/html.c:392 src/html.c:417
+#: src/html.c:408 src/html.c:437
 #, c-format
 msgid "failed to open: %s"
 msgstr ""
 
-#: src/html.c:448 src/html.c:468 src/html.c:481
+#: src/html.c:471 src/html.c:491 src/html.c:504
 #, c-format
 msgid "generating %s"
 msgstr ""
 
-#: src/html.c:544
+#: src/html.c:567
 #, c-format
 msgid "copying %s %s"
 msgstr ""
@@ -51,39 +51,34 @@ msgstr ""
 msgid "Cannot open log file: %s"
 msgstr ""
 
-#: src/lp_ws.c:71
-#, c-format
-msgid "fetch_url(): %s"
+#: src/lp_ws.c:68
+msgid "initializing CURL"
 msgstr ""
 
-#: src/lp_ws.c:74
-msgid "initializing CURL"
+#: src/lp_ws.c:84
+#, c-format
+msgid "fetch_url(): %s"
 msgstr ""
 
-#: src/lp_ws.c:109
+#: src/lp_ws.c:114 src/lp_ws.c:129
 #, c-format
 msgid "Fetch failed with code %ld for URL %s"
 msgstr ""
 
-#: src/lp_ws.c:114
+#: src/lp_ws.c:119
 msgid "Wait 5s before retry"
 msgstr ""
 
-#: src/lp_ws.c:122
-#, c-format
-msgid "Fetch failed: %ld"
-msgstr ""
-
-#: src/lp_ws.c:294
+#: src/lp_ws.c:303
 msgid "cleanup CURL"
 msgstr ""
 
-#: src/main.c:102
-#, c-format
+#: src/main.c:103
+#, fuzzy, c-format
 msgid ""
 "Copyright (C) %s jeanfi@gmail.com\n"
-"License GPLv2: GNU GPL version 2 or later <http://www.gnu.org/licenses/old-"
-"licenses/gpl-2.0.html>\n"
+"License GPLv2: GNU GPL version 2 or later\n"
+"<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
 "This is free software: you are free to change and redistribute it.\n"
 "There is NO WARRANTY, to the extent permitted by law.\n"
 msgstr ""
@@ -95,26 +90,27 @@ msgstr ""
 "Ce logiciel n'est accompagné d’ABSOLUMENT AUCUNE GARANTIE, dans les limites\n"
 "autorisées par la loi applicable.\n"
 
-#: src/main.c:112
+#: src/main.c:113
 #, c-format
 msgid "Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n"
 msgstr "Utilisation: %s [OPTION]... PPA_OWNER PPA_NAME\n"
 
-#: src/main.c:114
+#: src/main.c:116
 msgid "ppastats is a command application for generating PPA statistics.\n"
 msgstr ""
 
-#: src/main.c:117
+#: src/main.c:119
 msgid ""
-"Prints number of downloads for each published packages of a PPA or generates "
+"Prints number of downloads for each published packages of a PPA or "
+"generates\n"
 "an HTML page containing a graph representation."
 msgstr ""
 
-#: src/main.c:122
+#: src/main.c:123
 msgid "Options:"
 msgstr "Options:"
 
-#: src/main.c:123
+#: src/main.c:125
 msgid ""
 "  -h, --help          display this help and exit\n"
 "  -v, --version       display version information and exit"
@@ -122,32 +118,32 @@ msgstr ""
 "  -h, --help          afficher cette aide et quitter\n"
 "  -v, --version       afficher les informations de version et quitter"
 
-#: src/main.c:129
-msgid "  -o, --output-dir=[PATH]       generates HTML pages into 'PATH'."
+#: src/main.c:131
+msgid "  -o, --output-dir=[PATH]  generates HTML pages into 'PATH'."
 msgstr ""
 
-#: src/main.c:132
+#: src/main.c:134
 msgid ""
-"  -s, --status=[STATUS]\t\tretrieves only package of the given status\n"
-"\t\t\t\t(possible values are: Pending, Published, \n"
-"\t\t\t\tSuperseded, Deleted or Obsolete)."
+"  -s, --status=[STATUS]    retrieves only package of the given status\n"
+"                           (possible values are: Pending, Published,\n"
+"                           Superseded, Deleted or Obsolete)."
 msgstr ""
 
-#: src/main.c:137
-msgid "  -S, --skip-js-css\t\tskip installation of js and css files"
+#: src/main.c:139
+msgid " -S, --skip-js-css         skip installation of js and css files"
 msgstr ""
 
-#: src/main.c:141
+#: src/main.c:142
 #, c-format
 msgid "Report bugs to: %s\n"
 msgstr ""
 
-#: src/main.c:143
+#: src/main.c:144
 #, c-format
 msgid "%s home page: <%s>\n"
 msgstr ""
 
-#: src/main.c:193
+#: src/main.c:194
 #, c-format
 msgid "Try `%s --help' for more information.\n"
 msgstr ""
index e151df2..405355a 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: ppastats 0.0.x\n"
 "Report-Msgid-Bugs-To: jeanfi@gmail.com\n"
-"POT-Creation-Date: 2012-05-06 13:01+0200\n"
+"POT-Creation-Date: 2012-05-07 13:30+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -31,17 +31,17 @@ msgstr ""
 msgid "exceed cache capacity"
 msgstr ""
 
-#: src/html.c:392 src/html.c:417
+#: src/html.c:408 src/html.c:437
 #, c-format
 msgid "failed to open: %s"
 msgstr ""
 
-#: src/html.c:448 src/html.c:468 src/html.c:481
+#: src/html.c:471 src/html.c:491 src/html.c:504
 #, c-format
 msgid "generating %s"
 msgstr ""
 
-#: src/html.c:544
+#: src/html.c:567
 #, c-format
 msgid "copying %s %s"
 msgstr ""
@@ -51,94 +51,90 @@ msgstr ""
 msgid "Cannot open log file: %s"
 msgstr ""
 
-#: src/lp_ws.c:71
-#, c-format
-msgid "fetch_url(): %s"
+#: src/lp_ws.c:68
+msgid "initializing CURL"
 msgstr ""
 
-#: src/lp_ws.c:74
-msgid "initializing CURL"
+#: src/lp_ws.c:84
+#, c-format
+msgid "fetch_url(): %s"
 msgstr ""
 
-#: src/lp_ws.c:109
+#: src/lp_ws.c:114 src/lp_ws.c:129
 #, c-format
 msgid "Fetch failed with code %ld for URL %s"
 msgstr ""
 
-#: src/lp_ws.c:114
+#: src/lp_ws.c:119
 msgid "Wait 5s before retry"
 msgstr ""
 
-#: src/lp_ws.c:122
-#, c-format
-msgid "Fetch failed: %ld"
-msgstr ""
-
-#: src/lp_ws.c:294
+#: src/lp_ws.c:303
 msgid "cleanup CURL"
 msgstr ""
 
-#: src/main.c:102
+#: src/main.c:103
 #, c-format
 msgid ""
 "Copyright (C) %s jeanfi@gmail.com\n"
-"License GPLv2: GNU GPL version 2 or later <http://www.gnu.org/licenses/old-"
-"licenses/gpl-2.0.html>\n"
+"License GPLv2: GNU GPL version 2 or later\n"
+"<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
 "This is free software: you are free to change and redistribute it.\n"
 "There is NO WARRANTY, to the extent permitted by law.\n"
 msgstr ""
 
-#: src/main.c:112
+#: src/main.c:113
 #, c-format
 msgid "Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n"
 msgstr ""
 
-#: src/main.c:114
+#: src/main.c:116
 msgid "ppastats is a command application for generating PPA statistics.\n"
 msgstr ""
 
-#: src/main.c:117
+#: src/main.c:119
 msgid ""
-"Prints number of downloads for each published packages of a PPA or generates "
+"Prints number of downloads for each published packages of a PPA or "
+"generates\n"
 "an HTML page containing a graph representation."
 msgstr ""
 
-#: src/main.c:122
+#: src/main.c:123
 msgid "Options:"
 msgstr ""
 
-#: src/main.c:123
+#: src/main.c:125
 msgid ""
 "  -h, --help          display this help and exit\n"
 "  -v, --version       display version information and exit"
 msgstr ""
 
-#: src/main.c:129
-msgid "  -o, --output-dir=[PATH]       generates HTML pages into 'PATH'."
+#: src/main.c:131
+msgid "  -o, --output-dir=[PATH]  generates HTML pages into 'PATH'."
 msgstr ""
 
-#: src/main.c:132
+#: src/main.c:134
 msgid ""
-"  -s, --status=[STATUS]\t\tretrieves only package of the given status\n"
-"\t\t\t\t(possible values are: Pending, Published, \n"
-"\t\t\t\tSuperseded, Deleted or Obsolete)."
+"  -s, --status=[STATUS]    retrieves only package of the given status\n"
+"                           (possible values are: Pending, Published,\n"
+"                           Superseded, Deleted or Obsolete)."
 msgstr ""
 
-#: src/main.c:137
-msgid "  -S, --skip-js-css\t\tskip installation of js and css files"
+#: src/main.c:139
+msgid " -S, --skip-js-css         skip installation of js and css files"
 msgstr ""
 
-#: src/main.c:141
+#: src/main.c:142
 #, c-format
 msgid "Report bugs to: %s\n"
 msgstr ""
 
-#: src/main.c:143
+#: src/main.c:144
 #, c-format
 msgid "%s home page: <%s>\n"
 msgstr ""
 
-#: src/main.c:193
+#: src/main.c:194
 #, c-format
 msgid "Try `%s --help' for more information.\n"
 msgstr ""
index d969424..797b128 100644 (file)
 #include "lp_ws.h"
 #include "ppastats.h"
 
-#define HTML_FOOTER \
-" <div id=\"footer\">Generated by \
-<a href='http://wpitchoune.net/ppastats'>ppastats</a></div>\n\
-  </body>\n\
-</html>"
+static char *footer;
 
 #define HTML_PKG_TEMPLATE \
 "      <h1><span id=\"pkg_name\">N/A</span></h1>\n\
@@ -98,8 +94,7 @@ src=\"js/excanvas.js\"></script><![endif]-->\n\
        <em>Distros</em>:\n\
        <ul id=\"distros\"></ul>\n\
       </div>\n\
-    </div>\n\
-%s"
+    </div>\n"
 
 #define HTML_HEADER \
 "<html>\n\
@@ -159,6 +154,24 @@ static char *path_new(const char *dir, const char *file, const char *suffixe)
        return path;
 }
 
+
+
+static const char *get_footer()
+{
+       const char *path;
+
+       if (!footer) {
+               path = DEFAULT_WWW_DIR"/footer.tpl";
+               footer = file_get_content(path);
+
+               if (!footer)
+                       log_err("Failed to get footer template: %s", path);
+       }
+
+               
+       return footer;
+}
+
 static struct json_object *date_to_json(struct tm *tm)
 {
        json_object *json;
@@ -383,6 +396,7 @@ version_to_html(struct ppa_stats *ppa,
 {
        char *f_name, *path;
        FILE *f;
+       const char *footer;
 
        f_name = malloc(strlen(pkg->name)+1+strlen(version->version)+1);
        sprintf(f_name, "%s_%s", pkg->name, version->version);
@@ -396,8 +410,11 @@ version_to_html(struct ppa_stats *ppa,
        }
 
        fprintf(f, HTML_VERSION_TEMPLATE,
-               version_to_json(ppa, pkg, version),
-               HTML_FOOTER);
+               version_to_json(ppa, pkg, version));
+
+       footer = get_footer();
+       if (footer)
+               fputs(footer, f);
 
        fclose(f);
 
@@ -412,6 +429,7 @@ create_html(const char *path,
            const char *script)
 {
        FILE *f;
+       const char *footer;
 
        f = fopen(path, "w");
 
@@ -422,7 +440,10 @@ create_html(const char *path,
 
        fprintf(f, HTML_HEADER, title, script);
        fputs(body_template, f);
-       fputs(HTML_FOOTER, f);
+
+       footer = get_footer();
+       if (footer)
+               fputs(footer, f);
 
        fclose(f);
 }
index cb73dcc..f6d8754 100644 (file)
--- a/src/io.c
+++ b/src/io.c
@@ -27,7 +27,7 @@
 /* Directory separator is \ when cross-compiling for MS Windows
    systems */
 #if defined(__MINGW32__)
-#define DIRSEP '\\'
+#define DIRSEP ('\\')
 #else
 #define DIRSEP '/'
 #endif
@@ -118,3 +118,74 @@ void mkdirs(const char *dirs, mode_t mode)
 
        free(dir);
 }
+
+static int is_file(const char *path)
+{
+       struct stat st;
+
+       int ret = lstat(path, &st);
+
+       if (ret == 0 && S_ISREG(st.st_mode))
+               return 1;
+
+       return 0;
+}
+
+static long file_get_size(const char *path)
+{
+       FILE *fp;
+
+       if (!is_file(path))
+               return -1;
+
+       fp = fopen(path, "rb");
+       if (fp) {
+               long size;
+
+               if (fseek(fp, 0, SEEK_END) == -1)
+                       return -1;
+
+               size = ftell(fp);
+
+               fclose(fp);
+
+               return size;
+       }
+
+       return -1;
+}
+
+char *file_get_content(const char *fpath)
+{
+       long size;
+
+       char *page;
+
+       size = file_get_size(fpath);
+       if (size == -1) {
+               page = NULL;
+
+       } else if (size == 0) {
+               page = malloc(1);
+               *page = '\0';
+
+       } else {
+               FILE *fp = fopen(fpath, "rb");
+               if (fp) {
+                       page = malloc(size + 1);
+                       if (!page || size != fread(page, 1, size, fp)) {
+                               free(page);
+                               return NULL;
+                       }
+
+                       *(page + size) = '\0';
+
+                       fclose(fp);
+               } else {
+                       page = NULL;
+               }
+       }
+
+       return page;
+}
+
index 259e218..cd04023 100644 (file)
--- a/src/io.h
+++ b/src/io.h
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2011 jeanfi@gmail.com
+ * Copyright (C) 2011-2012 jeanfi@gmail.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
-
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -45,4 +45,6 @@ char *path_append(const char *odir, const char *name);
 
 void mkdirs(const char *dirs, mode_t mode);
 
+char *file_get_content(const char *fpath);
+
 #endif
index c413ea6..7f1cdab 100644 (file)
@@ -25,7 +25,7 @@
 #include "lp.h"
 
 struct binary_package_publishing_history *
-json_object_to_binary_package_publishing_history(json_object *o);
+json_object_to_binary_package_publishing_history(json_object * o);
 
 struct binary_package_publishing_history * *
 json_object_to_binary_package_publishing_history_list(json_object *o);
index 4549d92..3de408b 100644 (file)
@@ -62,15 +62,8 @@ static size_t cbk_curl(void *buffer, size_t size, size_t nmemb, void *userp)
        return realsize;
 }
 
-static char *fetch_url(const char *url)
+static void init()
 {
-       struct ucontent *content = malloc(sizeof(struct ucontent));
-       char *result;
-       long code;
-       int retries;
-
-       log_debug(_("fetch_url(): %s"), url);
-
        if (!curl) {
                log_debug(_("initializing CURL"));
                curl_global_init(CURL_GLOBAL_ALL);
@@ -79,6 +72,18 @@ static char *fetch_url(const char *url)
 
        if (!curl)
                exit(EXIT_FAILURE);
+}
+
+static char *fetch_url(const char *url)
+{
+       struct ucontent *content = malloc(sizeof(struct ucontent));
+       char *result;
+       long code;
+       int retries;
+
+       log_debug(_("fetch_url(): %s"), url);
+
+       init();
 
        result = NULL;
 
@@ -106,12 +111,11 @@ static char *fetch_url(const char *url)
                case 502:
                case 503:
                case 504:
-                       if (retries) {
-                               log_err(_("Fetch failed with code %ld "
-                                         "for URL %s"),
-                                       code,
-                                       url);
+                       log_err(_("Fetch failed with code %ld for URL %s"),
+                               code,
+                               url);
 
+                       if (retries) {
                                log_debug(_("Wait 5s before retry"));
                                sleep(5);
 
@@ -119,8 +123,12 @@ static char *fetch_url(const char *url)
                                retries--;
                                goto retrieve;
                        }
+
+                       break;
                default:
-                       log_err(_("Fetch failed: %ld"), code);
+                       log_err(_("Fetch failed with code %ld for URL %s"),
+                               code,
+                               url);
                }
        }
 
index 4f3a227..9aac447 100644 (file)
@@ -99,43 +99,44 @@ static struct option long_options[] = {
 static void print_version()
 {
        printf("ppastats %s\n", VERSION);
-       printf(_("Copyright (C) %s jeanfi@gmail.com\n\
-License GPLv2: GNU GPL version 2 or later \
-<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n"),
-                "2011-2012");
+       printf(_(
+"Copyright (C) %s jeanfi@gmail.com\n"
+"License GPLv2: GNU GPL version 2 or later\n"
+"<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
+"This is free software: you are free to change and redistribute it.\n"
+"There is NO WARRANTY, to the extent permitted by law.\n"),
+              "2011-2012");
 }
 
 static void print_help()
 {
        printf(_("Usage: %s [OPTION]... PPA_OWNER PPA_NAME\n"), program_name);
 
-       puts(_("ppastats is a command application"
-              " for generating PPA statistics.\n"));
+       puts(_(
+"ppastats is a command application for generating PPA statistics.\n"));
 
-       puts(_("Prints number of downloads for each published packages of a "
-              "PPA or generates an HTML page containing a graph "
-              "representation."));
+       puts(_(
+"Prints number of downloads for each published packages of a PPA or generates\n"
+"an HTML page containing a graph representation."));
 
        puts("");
        puts(_("Options:"));
-       puts(_("\
-  -h, --help          display this help and exit\n\
-  -v, --version       display version information and exit"));
+       puts(_(
+"  -h, --help          display this help and exit\n"
+"  -v, --version       display version information and exit"));
 
        puts("");
 
-       puts(_("\
-  -o, --output-dir=[PATH]       generates HTML pages into 'PATH'."));
+       puts(_(
+"  -o, --output-dir=[PATH]  generates HTML pages into 'PATH'."));
 
-       puts(_("\
-  -s, --status=[STATUS]                retrieves only package of the given status\n\
-                               (possible values are: Pending, Published, \n\
-                               Superseded, Deleted or Obsolete)."));
+       puts(_(
+"  -s, --status=[STATUS]    retrieves only package of the given status\n"
+"                           (possible values are: Pending, Published,\n"
+"                           Superseded, Deleted or Obsolete)."));
 
-       puts(_("\
-  -S, --skip-js-css            skip installation of js and css files"));
+       puts(_(
+" -S, --skip-js-css         skip installation of js and css files"));
        puts("");
 
        printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT);
index a8719d5..b74c034 100644 (file)
@@ -8,7 +8,8 @@ ppastats \- PPA Statistics command line tool
 .SH DESCRIPTION
 ppastats is a command application for generating PPA statistics.
 .PP
-Prints number of downloads for each published packages of a PPA or generates an HTML page containing a graph representation.
+Prints number of downloads for each published packages of a PPA or generates
+an HTML page containing a graph representation.
 .SH OPTIONS
 .TP
 \fB\-h\fR, \fB\-\-help\fR
@@ -33,7 +34,8 @@ Report bugs to: jeanfi@gmail.com
 ppastats home page: <http://wpitchoune.net/ppastats>
 .SH COPYRIGHT
 Copyright \(co 2011\-2012 jeanfi@gmail.com
-License GPLv2: GNU GPL version 2 or later <http://www.gnu.org/licenses/old\-licenses/gpl\-2.0.html>
+License GPLv2: GNU GPL version 2 or later
+<http://www.gnu.org/licenses/old\-licenses/gpl\-2.0.html>
 .br
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
index 0b0defa..faea0ec 100755 (executable)
@@ -1,11 +1,8 @@
 #!/usr/bin/perl -w
-
-# This script has been copied from Linux Kernel sources.
-#
 # (c) 2001, Dave Jones. (the file handling bit)
 # (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
 # (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
-# (c) 2008,2009, Andy Whitcroft <apw@canonical.com>
+# (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
 # Licensed under the terms of the GNU GPL License version 2
 
 use strict;
@@ -13,7 +10,7 @@ use strict;
 my $P = $0;
 $P =~ s@.*/@@g;
 
-my $V = '0.30';
+my $V = '0.32';
 
 use Getopt::Long qw(:config no_auto_abbrev);
 
@@ -29,9 +26,13 @@ my $check = 0;
 my $summary = 1;
 my $mailback = 0;
 my $summary_file = 0;
+my $show_types = 0;
 my $root;
 my %debug;
+my %ignore_type = ();
+my @ignore = ();
 my $help = 0;
+my $configuration_file = ".checkpatch.conf";
 
 sub help {
        my ($exitcode) = @_;
@@ -49,6 +50,8 @@ Options:
   --terse                    one line per report
   -f, --file                 treat FILE as regular source file
   --subjective, --strict     enable more subjective tests
+  --ignore TYPE(,TYPE2...)   ignore various comma separated message types
+  --show-types               show the message "types" in the output
   --root=PATH                PATH to the kernel tree root
   --no-summary               suppress the per-file summary
   --mailback                 only produce a report in case of warnings/errors
@@ -66,6 +69,32 @@ EOM
        exit($exitcode);
 }
 
+my $conf = which_conf($configuration_file);
+if (-f $conf) {
+       my @conf_args;
+       open(my $conffile, '<', "$conf")
+           or warn "$P: Can't find a readable $configuration_file file $!\n";
+
+       while (<$conffile>) {
+               my $line = $_;
+
+               $line =~ s/\s*\n?$//g;
+               $line =~ s/^\s*//g;
+               $line =~ s/\s+/ /g;
+
+               next if ($line =~ m/^\s*#/);
+               next if ($line =~ m/^\s*$/);
+
+               my @words = split(" ", $line);
+               foreach my $word (@words) {
+                       last if ($word =~ m/^#/);
+                       push (@conf_args, $word);
+               }
+       }
+       close($conffile);
+       unshift(@ARGV, @conf_args) if @conf_args;
+}
+
 GetOptions(
        'q|quiet+'      => \$quiet,
        'tree!'         => \$tree,
@@ -76,6 +105,8 @@ GetOptions(
        'f|file!'       => \$file,
        'subjective!'   => \$check,
        'strict!'       => \$check,
+       'ignore=s'      => \@ignore,
+       'show-types!'   => \$show_types,
        'root=s'        => \$root,
        'summary!'      => \$summary,
        'mailback!'     => \$mailback,
@@ -96,6 +127,19 @@ if ($#ARGV < 0) {
        exit(1);
 }
 
+@ignore = split(/,/, join(',',@ignore));
+foreach my $word (@ignore) {
+       $word =~ s/\s*\n?$//g;
+       $word =~ s/^\s*//g;
+       $word =~ s/\s+/ /g;
+       $word =~ tr/[a-z]/[A-Z]/;
+
+       next if ($word =~ m/^\s*#/);
+       next if ($word =~ m/^\s*$/);
+
+       $ignore_type{$word}++;
+}
+
 my $dbg_values = 0;
 my $dbg_possible = 0;
 my $dbg_type = 0;
@@ -106,6 +150,8 @@ for my $key (keys %debug) {
        die "$@" if ($@);
 }
 
+my $rpt_cleaners = 0;
+
 if ($terse) {
        $emacs = 1;
        $quiet++;
@@ -146,13 +192,28 @@ our $Sparse       = qr{
                        __must_check|
                        __init_refok|
                        __kprobes|
-                       __ref
+                       __ref|
+                       __rcu
                }x;
 
 # Notes to $Attribute:
 # We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
 our $Attribute = qr{
                        const|
+                       __percpu|
+                       __nocast|
+                       __safe|
+                       __bitwise__|
+                       __packed__|
+                       __packed2__|
+                       __naked|
+                       __maybe_unused|
+                       __always_unused|
+                       __noreturn|
+                       __used|
+                       __cold|
+                       __noclone|
+                       __deprecated|
                        __read_mostly|
                        __kprobes|
                        __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)|
@@ -166,7 +227,7 @@ our $Inline = qr{inline|__always_inline|noinline};
 our $Member    = qr{->$Ident|\.$Ident|\[[^]]*\]};
 our $Lval      = qr{$Ident(?:$Member)*};
 
-our $Constant  = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*};
+our $Constant  = qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)};
 our $Assignment        = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
 our $Compare    = qr{<=|>=|==|!=|<|>};
 our $Operators = qr{
@@ -179,9 +240,8 @@ our $NonptrType;
 our $Type;
 our $Declare;
 
-our $UTF8      = qr {
-       [\x09\x0A\x0D\x20-\x7E]              # ASCII
-       | [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
+our $NON_ASCII_UTF8    = qr{
+       [\xC2-\xDF][\x80-\xBF]               # non-overlong 2-byte
        |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
        | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
        |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
@@ -190,17 +250,32 @@ our $UTF8 = qr {
        |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
 }x;
 
+our $UTF8      = qr{
+       [\x09\x0A\x0D\x20-\x7E]              # ASCII
+       | $NON_ASCII_UTF8
+}x;
+
 our $typeTypedefs = qr{(?x:
        (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
        atomic_t
 )};
 
 our $logFunctions = qr{(?x:
-       printk|
-       pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)|
-       dev_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)|
-       WARN|
-       panic
+       printk(?:_ratelimited|_once|)|
+       [a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
+       WARN(?:_RATELIMIT|_ONCE|)|
+       panic|
+       MODULE_[A-Z_]+
+)};
+
+our $signature_tags = qr{(?xi:
+       Signed-off-by:|
+       Acked-by:|
+       Tested-by:|
+       Reviewed-by:|
+       Reported-by:|
+       To:|
+       Cc:
 )};
 
 our @typeList = (
@@ -227,6 +302,12 @@ our @modifierList = (
        qr{fastcall},
 );
 
+our $allowed_asm_includes = qr{(?x:
+       irq|
+       memory
+)};
+# memory.h: ARM has a custom one
+
 sub build_types {
        my $mods = "(?x:  \n" . join("|\n  ", @modifierList) . "\n)";
        my $all = "(?x:  \n" . join("|\n  ", @typeList) . "\n)";
@@ -234,7 +315,7 @@ sub build_types {
        $NonptrType     = qr{
                        (?:$Modifier\s+|const\s+)*
                        (?:
-                               (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)|
+                               (?:typeof|__typeof__)\s*\([^\)]*\)|
                                (?:$typeTypedefs\b)|
                                (?:${all}\b)
                        )
@@ -242,13 +323,33 @@ sub build_types {
                  }x;
        $Type   = qr{
                        $NonptrType
-                       (?:[\s\*]+\s*const|[\s\*]+|(?:\s*\[\s*\])+)?
+                       (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)?
                        (?:\s+$Inline|\s+$Modifier)*
                  }x;
        $Declare        = qr{(?:$Storage\s+)?$Type};
 }
 build_types();
 
+
+our $Typecast  = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
+
+# Using $balanced_parens, $LvalOrFunc, or $FuncArg
+# requires at least perl version v5.10.0
+# Any use must be runtime checked with $^V
+
+our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
+our $LvalOrFunc        = qr{($Lval)\s*($balanced_parens{0,1})\s*};
+our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
+
+sub deparenthesize {
+       my ($string) = @_;
+       return "" if (!defined($string));
+       $string =~ s@^\s*\(\s*@@g;
+       $string =~ s@\s*\)\s*$@@g;
+       $string =~ s@\s+@ @g;
+       return $string;
+}
+
 $chk_signoff = 0 if ($file);
 
 my @dep_includes = ();
@@ -320,6 +421,88 @@ sub top_of_kernel_tree {
                }
        }
        return 1;
+    }
+
+sub parse_email {
+       my ($formatted_email) = @_;
+
+       my $name = "";
+       my $address = "";
+       my $comment = "";
+
+       if ($formatted_email =~ /^(.*)<(\S+\@\S+)>(.*)$/) {
+               $name = $1;
+               $address = $2;
+               $comment = $3 if defined $3;
+       } elsif ($formatted_email =~ /^\s*<(\S+\@\S+)>(.*)$/) {
+               $address = $1;
+               $comment = $2 if defined $2;
+       } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) {
+               $address = $1;
+               $comment = $2 if defined $2;
+               $formatted_email =~ s/$address.*$//;
+               $name = $formatted_email;
+               $name =~ s/^\s+|\s+$//g;
+               $name =~ s/^\"|\"$//g;
+               # If there's a name left after stripping spaces and
+               # leading quotes, and the address doesn't have both
+               # leading and trailing angle brackets, the address
+               # is invalid. ie:
+               #   "joe smith joe@smith.com" bad
+               #   "joe smith <joe@smith.com" bad
+               if ($name ne "" && $address !~ /^<[^>]+>$/) {
+                       $name = "";
+                       $address = "";
+                       $comment = "";
+               }
+       }
+
+       $name =~ s/^\s+|\s+$//g;
+       $name =~ s/^\"|\"$//g;
+       $address =~ s/^\s+|\s+$//g;
+       $address =~ s/^\<|\>$//g;
+
+       if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
+               $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
+               $name = "\"$name\"";
+       }
+
+       return ($name, $address, $comment);
+}
+
+sub format_email {
+       my ($name, $address) = @_;
+
+       my $formatted_email;
+
+       $name =~ s/^\s+|\s+$//g;
+       $name =~ s/^\"|\"$//g;
+       $address =~ s/^\s+|\s+$//g;
+
+       if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
+               $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
+               $name = "\"$name\"";
+       }
+
+       if ("$name" eq "") {
+               $formatted_email = "$address";
+       } else {
+               $formatted_email = "$name <$address>";
+       }
+
+       return $formatted_email;
+}
+
+sub which_conf {
+       my ($conf) = @_;
+
+       foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
+               if (-e "$path/$conf") {
+                       return "$path/$conf";
+               }
+       }
+
+       return "";
 }
 
 sub expand_tabs {
@@ -499,6 +682,10 @@ sub ctx_statement_block {
                        if ($off >= $len) {
                                last;
                        }
+                       if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) {
+                               $level++;
+                               $type = '#';
+                       }
                }
                $p = $c;
                $c = substr($blk, $off, 1);
@@ -555,9 +742,19 @@ sub ctx_statement_block {
                        $type = ($level != 0)? '{' : '';
 
                        if ($level == 0) {
+                               if (substr($blk, $off + 1, 1) eq ';') {
+                                       $off++;
+                               }
                                last;
                        }
                }
+               # Preprocessor commands end at the newline unless escaped.
+               if ($type eq '#' && $c eq "\n" && $p ne "\\") {
+                       $level--;
+                       $type = '';
+                       $off++;
+                       last;
+               }
                $off++;
        }
        # We are truly at the end, so shuffle to the next line.
@@ -669,15 +866,15 @@ sub ctx_block_get {
                $blk .= $rawlines[$line];
 
                # Handle nested #if/#else.
-               if ($rawlines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
+               if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
                        push(@stack, $level);
-               } elsif ($rawlines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
+               } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
                        $level = $stack[$#stack - 1];
-               } elsif ($rawlines[$line] =~ /^.\s*#\s*endif\b/) {
+               } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
                        $level = pop(@stack);
                }
 
-               foreach my $c (split(//, $rawlines[$line])) {
+               foreach my $c (split(//, $lines[$line])) {
                        ##print "C<$c>L<$level><$open$close>O<$off>\n";
                        if ($off > 0) {
                                $off--;
@@ -837,7 +1034,12 @@ sub annotate_values {
                                $av_preprocessor = 0;
                        }
 
-               } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\()/) {
+               } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
+                       print "CAST($1)\n" if ($dbg_values > 1);
+                       push(@av_paren_type, $type);
+                       $type = 'c';
+
+               } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
                        print "DECLARE($1)\n" if ($dbg_values > 1);
                        $type = 'T';
 
@@ -1027,7 +1229,9 @@ sub possible {
                        case|
                        else|
                        asm|__asm__|
-                       do
+                       do|
+                       \#|
+                       \#\#|
                )(?:\s|$)|
                ^(?:typedef|struct|enum)\b
            )}x;
@@ -1059,12 +1263,21 @@ sub possible {
 
 my $prefix = '';
 
+sub show_type {
+       return !defined $ignore_type{$_[0]};
+}
+
 sub report {
-       if (defined $tst_only && $_[0] !~ /\Q$tst_only\E/) {
+       if (!show_type($_[1]) ||
+           (defined $tst_only && $_[2] !~ /\Q$tst_only\E/)) {
                return 0;
        }
-       my $line = $prefix . $_[0];
-
+       my $line;
+       if ($show_types) {
+               $line = "$prefix$_[0]:$_[1]: $_[2]\n";
+       } else {
+               $line = "$prefix$_[0]: $_[2]\n";
+       }
        $line = (split('\n', $line))[0] . "\n" if ($terse);
 
        push(our @report, $line);
@@ -1074,20 +1287,21 @@ sub report {
 sub report_dump {
        our @report;
 }
+
 sub ERROR {
-       if (report("ERROR: $_[0]\n")) {
+       if (report("ERROR", $_[0], $_[1])) {
                our $clean = 0;
                our $cnt_error++;
        }
 }
 sub WARN {
-       if (report("WARNING: $_[0]\n")) {
+       if (report("WARNING", $_[0], $_[1])) {
                our $clean = 0;
                our $cnt_warn++;
        }
 }
 sub CHK {
-       if ($check && report("CHECK: $_[0]\n")) {
+       if ($check && report("CHECK", $_[0], $_[1])) {
                our $clean = 0;
                our $cnt_chk++;
        }
@@ -1116,10 +1330,41 @@ sub check_absolute_file {
 
        ##print "prefix<$prefix>\n";
        if ($prefix ne ".../") {
-               WARN("use relative pathname instead of absolute in changelog text\n" . $herecurr);
+               WARN("USE_RELATIVE_PATH",
+                    "use relative pathname instead of absolute in changelog text\n" . $herecurr);
        }
 }
 
+sub pos_last_openparen {
+       my ($line) = @_;
+
+       my $pos = 0;
+
+       my $opens = $line =~ tr/\(/\(/;
+       my $closes = $line =~ tr/\)/\)/;
+
+       my $last_openparen = 0;
+
+       if (($opens == 0) || ($closes >= $opens)) {
+               return -1;
+       }
+
+       my $len = length($line);
+
+       for ($pos = 0; $pos < $len; $pos++) {
+               my $string = substr($line, $pos);
+               if ($string =~ /^($FuncArg|$balanced_parens)/) {
+                       $pos += length($1) - 1;
+               } elsif (substr($line, $pos, 1) eq '(') {
+                       $last_openparen = $pos;
+               } elsif (index($string, '(') == -1) {
+                       last;
+               }
+       }
+
+       return $last_openparen + 1;
+}
+
 sub process {
        my $filename = shift;
 
@@ -1138,6 +1383,9 @@ sub process {
        my $signoff = 0;
        my $is_patch = 0;
 
+       my $in_header_lines = 1;
+       my $in_commit_log = 0;          #Scanning lines before patch
+
        our @report = ();
        our $cnt_lines = 0;
        our $cnt_error = 0;
@@ -1160,6 +1408,7 @@ sub process {
        my %suppress_ifbraces;
        my %suppress_whiletrailers;
        my %suppress_export;
+       my $suppress_statement = 0;
 
        # Pre-scan the patch sanitizing the lines.
        # Pre-scan the patch looking for any __setup documentation.
@@ -1269,6 +1518,7 @@ sub process {
                        %suppress_ifbraces = ();
                        %suppress_whiletrailers = ();
                        %suppress_export = ();
+                       $suppress_statement = 0;
                        next;
 
 # track the line number as we move through the hunk, note that
@@ -1302,18 +1552,25 @@ sub process {
                $here = "#$realline: " if ($file);
 
                # extract the filename as it passes
-               if ($line=~/^\+\+\+\s+(\S+)/) {
+               if ($line =~ /^diff --git.*?(\S+)$/) {
+                       $realfile = $1;
+                       $realfile =~ s@^([^/]*)/@@;
+                       $in_commit_log = 0;
+               } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
                        $realfile = $1;
                        $realfile =~ s@^([^/]*)/@@;
+                       $in_commit_log = 0;
 
                        $p1_prefix = $1;
                        if (!$file && $tree && $p1_prefix ne '' &&
                            -e "$root/$p1_prefix") {
-                               WARN("patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
+                               WARN("PATCH_PREFIX",
+                                    "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
                        }
 
                        if ($realfile =~ m@^include/asm/@) {
-                               ERROR("do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
+                               ERROR("MODIFIED_INCLUDE_ASM",
+                                     "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
                        }
                        next;
                }
@@ -1326,23 +1583,67 @@ sub process {
 
                $cnt_lines++ if ($realcnt != 0);
 
-#check the patch for a signoff:
+# Check for incorrect file permissions
+               if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
+                       my $permhere = $here . "FILE: $realfile\n";
+                       if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
+                               ERROR("EXECUTE_PERMISSIONS",
+                                     "do not set execute permissions for source files\n" . $permhere);
+                       }
+               }
+
+# Check the patch for a signoff:
                if ($line =~ /^\s*signed-off-by:/i) {
-                       # This is a signoff, if ugly, so do not double report.
                        $signoff++;
-                       if (!($line =~ /^\s*Signed-off-by:/)) {
-                               WARN("Signed-off-by: is the preferred form\n" .
-                                       $herecurr);
+                       $in_commit_log = 0;
+               }
+
+# Check signature styles
+               if (!$in_header_lines &&
+                   $line =~ /^(\s*)($signature_tags)(\s*)(.*)/) {
+                       my $space_before = $1;
+                       my $sign_off = $2;
+                       my $space_after = $3;
+                       my $email = $4;
+                       my $ucfirst_sign_off = ucfirst(lc($sign_off));
+
+                       if (defined $space_before && $space_before ne "") {
+                               WARN("BAD_SIGN_OFF",
+                                    "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr);
                        }
-                       if ($line =~ /^\s*signed-off-by:\S/i) {
-                               WARN("space required after Signed-off-by:\n" .
-                                       $herecurr);
+                       if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
+                               WARN("BAD_SIGN_OFF",
+                                    "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr);
+                       }
+                       if (!defined $space_after || $space_after ne " ") {
+                               WARN("BAD_SIGN_OFF",
+                                    "Use a single space after $ucfirst_sign_off\n" . $herecurr);
+                       }
+
+                       my ($email_name, $email_address, $comment) = parse_email($email);
+                       my $suggested_email = format_email(($email_name, $email_address));
+                       if ($suggested_email eq "") {
+                               ERROR("BAD_SIGN_OFF",
+                                     "Unrecognized email address: '$email'\n" . $herecurr);
+                       } else {
+                               my $dequoted = $suggested_email;
+                               $dequoted =~ s/^"//;
+                               $dequoted =~ s/" </ </;
+                               # Don't force email to have quotes
+                               # Allow just an angle bracketed address
+                               if ("$dequoted$comment" ne $email &&
+                                   "<$email_address>$comment" ne $email &&
+                                   "$suggested_email$comment" ne $email) {
+                                       WARN("BAD_SIGN_OFF",
+                                            "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
+                               }
                        }
                }
 
 # Check for wrappage within a valid hunk of the file
                if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
-                       ERROR("patch seems to be corrupt (line wrapped?)\n" .
+                       ERROR("CORRUPTED_PATCH",
+                             "patch seems to be corrupt (line wrapped?)\n" .
                                $herecurr) if (!$emitted_corrupt++);
                }
 
@@ -1369,7 +1670,23 @@ sub process {
                        my $ptr = substr($blank, 0, length($utf8_prefix)) . "^";
                        my $hereptr = "$hereline$ptr\n";
 
-                       ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
+                       CHK("INVALID_UTF8",
+                           "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
+               }
+
+# Check if it's the start of a commit log
+# (not a header line and we haven't seen the patch filename)
+               if ($in_header_lines && $realfile =~ /^$/ &&
+                   $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) {
+                       $in_header_lines = 0;
+                       $in_commit_log = 1;
+               }
+
+# Still not yet in a patch, check for any UTF-8
+               if ($in_commit_log && $realfile =~ /^$/ &&
+                   $rawline =~ /$NON_ASCII_UTF8/) {
+                       CHK("UTF8_BEFORE_PATCH",
+                           "8-bit UTF-8 used in possible commit log\n" . $herecurr);
                }
 
 # ignore non-hunk lines and lines being removed
@@ -1378,26 +1695,67 @@ sub process {
 #trailing whitespace
                if ($line =~ /^\+.*\015/) {
                        my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       ERROR("DOS line endings\n" . $herevet);
+                       ERROR("DOS_LINE_ENDINGS",
+                             "DOS line endings\n" . $herevet);
 
                } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
                        my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       ERROR("trailing whitespace\n" . $herevet);
+                       ERROR("TRAILING_WHITESPACE",
+                             "trailing whitespace\n" . $herevet);
+                       $rpt_cleaners = 1;
                }
 
 # check for Kconfig help text having a real description
+# Only applies when adding the entry originally, after that we do not have
+# sufficient context to determine whether it is indeed long enough.
                if ($realfile =~ /Kconfig/ &&
-                   $line =~ /\+?\s*(---)?help(---)?$/) {
+                   $line =~ /.\s*config\s+/) {
                        my $length = 0;
-                       for (my $l = $linenr; defined($lines[$l]); $l++) {
-                               my $f = $lines[$l];
+                       my $cnt = $realcnt;
+                       my $ln = $linenr + 1;
+                       my $f;
+                       my $is_start = 0;
+                       my $is_end = 0;
+                       for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
+                               $f = $lines[$ln - 1];
+                               $cnt-- if ($lines[$ln - 1] !~ /^-/);
+                               $is_end = $lines[$ln - 1] =~ /^\+/;
+
+                               next if ($f =~ /^-/);
+
+                               if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) {
+                                       $is_start = 1;
+                               } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) {
+                                       $length = -1;
+                               }
+
+                               $f =~ s/^.//;
                                $f =~ s/#.*//;
                                $f =~ s/^\s+//;
                                next if ($f =~ /^$/);
-                               last if ($f =~ /^\s*config\s/);
+                               if ($f =~ /^\s*config\s/) {
+                                       $is_end = 1;
+                                       last;
+                               }
                                $length++;
                        }
-                       WARN("please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($length < 4);
+                       WARN("CONFIG_DESCRIPTION",
+                            "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_start && $is_end && $length < 4);
+                       #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
+               }
+
+               if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
+                   ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
+                       my $flag = $1;
+                       my $replacement = {
+                               'EXTRA_AFLAGS' =>   'asflags-y',
+                               'EXTRA_CFLAGS' =>   'ccflags-y',
+                               'EXTRA_CPPFLAGS' => 'cppflags-y',
+                               'EXTRA_LDFLAGS' =>  'ldflags-y',
+                       };
+
+                       WARN("DEPRECATED_VARIABLE",
+                            "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
                }
 
 # check we are in a valid source file if not then ignore this hunk
@@ -1406,31 +1764,52 @@ sub process {
 #80 column limit
                if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
                    $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
-                   $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ &&
+                   !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
+                   $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
                    $length > 80)
                {
-                       WARN("line over 80 characters\n" . $herecurr);
+                       WARN("LONG_LINE",
+                            "line over 80 characters\n" . $herecurr);
+               }
+
+# Check for user-visible strings broken across lines, which breaks the ability
+# to grep for the string.  Limited to strings used as parameters (those
+# following an open parenthesis), which almost completely eliminates false
+# positives, as well as warning only once per parameter rather than once per
+# line of the string.  Make an exception when the previous string ends in a
+# newline (multiple lines in one string constant) or \n\t (common in inline
+# assembly to indent the instruction on the following line).
+               if ($line =~ /^\+\s*"/ &&
+                   $prevline =~ /"\s*$/ &&
+                   $prevline =~ /\(/ &&
+                   $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
+                       WARN("SPLIT_STRING",
+                            "quoted string split across lines\n" . $hereprev);
                }
 
 # check for spaces before a quoted newline
                if ($rawline =~ /^.*\".*\s\\n/) {
-                       WARN("unnecessary whitespace before a quoted newline\n" . $herecurr);
+                       WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
+                            "unnecessary whitespace before a quoted newline\n" . $herecurr);
                }
 
 # check for adding lines without a newline.
                if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
-                       WARN("adding a line without newline at end of file\n" . $herecurr);
+                       WARN("MISSING_EOF_NEWLINE",
+                            "adding a line without newline at end of file\n" . $herecurr);
                }
 
 # Blackfin: use hi/lo macros
                if ($realfile =~ m@arch/blackfin/.*\.S$@) {
                        if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) {
                                my $herevet = "$here\n" . cat_vet($line) . "\n";
-                               ERROR("use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
+                               ERROR("LO_MACRO",
+                                     "use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
                        }
                        if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) {
                                my $herevet = "$here\n" . cat_vet($line) . "\n";
-                               ERROR("use the HI() macro, not (... >> 16)\n" . $herevet);
+                               ERROR("HI_MACRO",
+                                     "use the HI() macro, not (... >> 16)\n" . $herevet);
                        }
                }
 
@@ -1442,13 +1821,63 @@ sub process {
                if ($rawline =~ /^\+\s* \t\s*\S/ ||
                    $rawline =~ /^\+\s*        \s*/) {
                        my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       ERROR("code indent should use tabs where possible\n" . $herevet);
+                       ERROR("CODE_INDENT",
+                             "code indent should use tabs where possible\n" . $herevet);
+                       $rpt_cleaners = 1;
                }
 
 # check for space before tabs.
                if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
                        my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       WARN("please, no space before tabs\n" . $herevet);
+                       WARN("SPACE_BEFORE_TAB",
+                            "please, no space before tabs\n" . $herevet);
+               }
+
+# check for && or || at the start of a line
+               if ($rawline =~ /^\+\s*(&&|\|\|)/) {
+                       CHK("LOGICAL_CONTINUATIONS",
+                           "Logical continuations should be on the previous line\n" . $hereprev);
+               }
+
+# check multi-line statement indentation matches previous line
+               if ($^V && $^V ge 5.10.0 &&
+                   $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) {
+                       $prevline =~ /^\+(\t*)(.*)$/;
+                       my $oldindent = $1;
+                       my $rest = $2;
+
+                       my $pos = pos_last_openparen($rest);
+                       if ($pos >= 0) {
+                               $line =~ /^\+([ \t]*)/;
+                               my $newindent = $1;
+
+                               my $goodtabindent = $oldindent .
+                                       "\t" x ($pos / 8) .
+                                       " "  x ($pos % 8);
+                               my $goodspaceindent = $oldindent . " "  x $pos;
+
+                               if ($newindent ne $goodtabindent &&
+                                   $newindent ne $goodspaceindent) {
+                                       CHK("PARENTHESIS_ALIGNMENT",
+                                           "Alignment should match open parenthesis\n" . $hereprev);
+                               }
+                       }
+               }
+
+               if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) {
+                       CHK("SPACING",
+                           "No space is necessary after a cast\n" . $hereprev);
+               }
+
+# check for spaces at the beginning of a line.
+# Exceptions:
+#  1) within comments
+#  2) indented preprocessor commands
+#  3) hanging labels
+               if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/)  {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       WARN("LEADING_SPACE",
+                            "please, no spaces at the start of a line\n" . $herevet);
                }
 
 # check we are in a valid C source file if not then ignore this hunk
@@ -1456,28 +1885,43 @@ sub process {
 
 # check for RCS/CVS revision markers
                if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
-                       WARN("CVS style keyword markers, these will _not_ be updated\n". $herecurr);
+                       WARN("CVS_KEYWORD",
+                            "CVS style keyword markers, these will _not_ be updated\n". $herecurr);
                }
 
 # Blackfin: don't use __builtin_bfin_[cs]sync
                if ($line =~ /__builtin_bfin_csync/) {
                        my $herevet = "$here\n" . cat_vet($line) . "\n";
-                       ERROR("use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
+                       ERROR("CSYNC",
+                             "use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
                }
                if ($line =~ /__builtin_bfin_ssync/) {
                        my $herevet = "$here\n" . cat_vet($line) . "\n";
-                       ERROR("use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
+                       ERROR("SSYNC",
+                             "use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
                }
 
 # Check for potential 'bare' types
                my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
                    $realline_next);
-               if ($realcnt && $line =~ /.\s*\S/) {
+#print "LINE<$line>\n";
+               if ($linenr >= $suppress_statement &&
+                   $realcnt && $line =~ /.\s*\S/) {
                        ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
                                ctx_statement_block($linenr, $realcnt, 0);
                        $stat =~ s/\n./\n /g;
                        $cond =~ s/\n./\n /g;
 
+#print "linenr<$linenr> <$stat>\n";
+                       # If this statement has no statement boundaries within
+                       # it there is no point in retrying a statement scan
+                       # until we hit end of it.
+                       my $frag = $stat; $frag =~ s/;+\s*$//;
+                       if ($frag !~ /(?:{|;)/) {
+#print "skip<$line_nr_next>\n";
+                               $suppress_statement = $line_nr_next;
+                       }
+
                        # Find the real next line.
                        $realline_next = $line_nr_next;
                        if (defined $realline_next &&
@@ -1555,7 +1999,8 @@ sub process {
                                }
                        }
                        if ($err ne '') {
-                               ERROR("switch and case should be at the same indent\n$hereline$err");
+                               ERROR("SWITCH_CASE_INDENT_LEVEL",
+                                     "switch and case should be at the same indent\n$hereline$err");
                        }
                }
 
@@ -1565,6 +2010,12 @@ sub process {
                        my $pre_ctx = "$1$2";
 
                        my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
+
+                       if ($line =~ /^\+\t{6,}/) {
+                               WARN("DEEP_INDENTATION",
+                                    "Too many leading tabs - consider code refactoring\n" . $herecurr);
+                       }
+
                        my $ctx_cnt = $realcnt - $#ctx - 1;
                        my $ctx = join("\n", @ctx);
 
@@ -1583,8 +2034,9 @@ sub process {
                        #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
 
                        if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
-                               ERROR("that open brace { should be on the previous line\n" .
-                                       "$here\n$ctx\n$lines[$ctx_ln - 1]\n");
+                               ERROR("OPEN_BRACE",
+                                     "that open brace { should be on the previous line\n" .
+                                       "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
                        }
                        if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
                            $ctx =~ /\)\s*\;\s*$/ &&
@@ -1592,14 +2044,18 @@ sub process {
                        {
                                my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
                                if ($nindent > $indent) {
-                                       WARN("trailing semicolon indicates no statements, indent implies otherwise\n" .
-                                               "$here\n$ctx\n$lines[$ctx_ln - 1]\n");
+                                       WARN("TRAILING_SEMICOLON",
+                                            "trailing semicolon indicates no statements, indent implies otherwise\n" .
+                                               "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
                                }
                        }
                }
 
 # Check relative indent for conditionals and blocks.
                if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
+                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
+                               ctx_statement_block($linenr, $realcnt, 0)
+                                       if (!defined $stat);
                        my ($s, $c) = ($stat, $cond);
 
                        substr($s, 0, length($c), '');
@@ -1680,7 +2136,8 @@ sub process {
 
                        if ($check && (($sindent % 8) != 0 ||
                            ($sindent <= $indent && $s ne ''))) {
-                               WARN("suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
+                               WARN("SUSPECT_CODE_INDENT",
+                                    "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
                        }
                }
 
@@ -1703,18 +2160,22 @@ sub process {
 # TEST: allow direct testing of the type matcher.
                if ($dbg_type) {
                        if ($line =~ /^.\s*$Declare\s*$/) {
-                               ERROR("TEST: is type\n" . $herecurr);
+                               ERROR("TEST_TYPE",
+                                     "TEST: is type\n" . $herecurr);
                        } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) {
-                               ERROR("TEST: is not type ($1 is)\n". $herecurr);
+                               ERROR("TEST_NOT_TYPE",
+                                     "TEST: is not type ($1 is)\n". $herecurr);
                        }
                        next;
                }
 # TEST: allow direct testing of the attribute matcher.
                if ($dbg_attr) {
                        if ($line =~ /^.\s*$Modifier\s*$/) {
-                               ERROR("TEST: is attr\n" . $herecurr);
+                               ERROR("TEST_ATTR",
+                                     "TEST: is attr\n" . $herecurr);
                        } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) {
-                               ERROR("TEST: is not attr ($1 is)\n". $herecurr);
+                               ERROR("TEST_NOT_ATTR",
+                                     "TEST: is not attr ($1 is)\n". $herecurr);
                        }
                        next;
                }
@@ -1722,7 +2183,8 @@ sub process {
 # check for initialisation to aggregates open brace on the next line
                if ($line =~ /^.\s*{/ &&
                    $prevline =~ /(?:^|[^=])=\s*$/) {
-                       ERROR("that open brace { should be on the previous line\n" . $hereprev);
+                       ERROR("OPEN_BRACE",
+                             "that open brace { should be on the previous line\n" . $hereprev);
                }
 
 #
@@ -1733,14 +2195,16 @@ sub process {
                if ($rawline =~ m{^.\s*\#\s*include\s+[<"](.*)[">]}) {
                        my $path = $1;
                        if ($path =~ m{//}) {
-                               ERROR("malformed #include filename\n" .
+                               ERROR("MALFORMED_INCLUDE",
+                                     "malformed #include filename\n" .
                                        $herecurr);
                        }
                }
 
 # no C99 // comments
                if ($line =~ m{//}) {
-                       ERROR("do not use C99 // comments\n" . $herecurr);
+                       ERROR("C99_COMMENTS",
+                             "do not use C99 // comments\n" . $herecurr);
                }
                # Remove C99 comments.
                $line =~ s@//.*@@;
@@ -1754,8 +2218,17 @@ sub process {
                    !defined $suppress_export{$realline_next} &&
                    ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
                     $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
+                       # Handle definitions which produce identifiers with
+                       # a prefix:
+                       #   XXX(foo);
+                       #   EXPORT_SYMBOL(something_foo);
                        my $name = $1;
-                       if ($stat !~ /(?:
+                       if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
+                           $name =~ /^${Ident}_$2/) {
+#print "FOO C name<$name>\n";
+                               $suppress_export{$realline_next} = 1;
+
+                       } elsif ($stat !~ /(?:
                                \n.}\s*$|
                                ^.DEFINE_$Ident\(\Q$name\E\)|
                                ^.DECLARE_$Ident\(\Q$name\E\)|
@@ -1778,20 +2251,43 @@ sub process {
                }
                if (defined $suppress_export{$linenr} &&
                    $suppress_export{$linenr} == 2) {
-                       WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
+                       WARN("EXPORT_SYMBOL",
+                            "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
                }
 
-# check for external initialisers.
+# check for global initialisers.
                if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
-                       ERROR("do not initialise externals to 0 or NULL\n" .
+                       ERROR("GLOBAL_INITIALISERS",
+                             "do not initialise globals to 0 or NULL\n" .
                                $herecurr);
                }
 # check for static initialisers.
                if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) {
-                       ERROR("do not initialise statics to 0 or NULL\n" .
+                       ERROR("INITIALISED_STATIC",
+                             "do not initialise statics to 0 or NULL\n" .
                                $herecurr);
                }
 
+# check for static const char * arrays.
+               if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
+                       WARN("STATIC_CONST_CHAR_ARRAY",
+                            "static const char * array should probably be static const char * const\n" .
+                               $herecurr);
+               }
+
+# check for static char foo[] = "bar" declarations.
+               if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
+                       WARN("STATIC_CONST_CHAR_ARRAY",
+                            "static char array declaration should probably be static const char\n" .
+                               $herecurr);
+               }
+
+# check for declarations of struct pci_device_id
+               if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) {
+                       WARN("DEFINE_PCI_DEVICE_TABLE",
+                            "Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr);
+               }
+
 # check for new typedefs, only function parameters and sparse annotations
 # make sense.
                if ($line =~ /\btypedef\s/ &&
@@ -1799,13 +2295,15 @@ sub process {
                    $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
                    $line !~ /\b$typeTypedefs\b/ &&
                    $line !~ /\b__bitwise(?:__|)\b/) {
-                       WARN("do not add new typedefs\n" . $herecurr);
+                       WARN("NEW_TYPEDEFS",
+                            "do not add new typedefs\n" . $herecurr);
                }
 
 # * goes on variable not on type
                # (char*[ const])
-               if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) {
-                       my ($from, $to) = ($1, $1);
+               while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
+                       #print "AA<$1>\n";
+                       my ($from, $to) = ($2, $2);
 
                        # Should start with a space.
                        $to =~ s/^(\S)/ $1/;
@@ -1817,10 +2315,13 @@ sub process {
 
                        #print "from<$from> to<$to>\n";
                        if ($from ne $to) {
-                               ERROR("\"(foo$from)\" should be \"(foo$to)\"\n" .  $herecurr);
+                               ERROR("POINTER_LOCATION",
+                                     "\"(foo$from)\" should be \"(foo$to)\"\n" .  $herecurr);
                        }
-               } elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) {
-                       my ($from, $to, $ident) = ($1, $1, $2);
+               }
+               while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
+                       #print "BB<$1>\n";
+                       my ($from, $to, $ident) = ($2, $2, $3);
 
                        # Should start with a space.
                        $to =~ s/^(\S)/ $1/;
@@ -1834,7 +2335,8 @@ sub process {
 
                        #print "from<$from> to<$to> ident<$ident>\n";
                        if ($from ne $to && $ident !~ /^$Modifier$/) {
-                               ERROR("\"foo${from}bar\" should be \"foo${to}bar\"\n" .  $herecurr);
+                               ERROR("POINTER_LOCATION",
+                                     "\"foo${from}bar\" should be \"foo${to}bar\"\n" .  $herecurr);
                        }
                }
 
@@ -1846,19 +2348,26 @@ sub process {
 #              }
 
                if ($line =~ /\bLINUX_VERSION_CODE\b/) {
-                       WARN("LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
+                       WARN("LINUX_VERSION_CODE",
+                            "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
+               }
+
+# check for uses of printk_ratelimit
+               if ($line =~ /\bprintk_ratelimit\s*\(/) {
+                       WARN("PRINTK_RATELIMITED",
+"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
                }
 
 # printk should use KERN_* levels.  Note that follow on printk's on the
 # same line do not need a level, so we use the current block context
 # to try and find and validate the current printk.  In summary the current
-# printk includes all preceeding printk's which have no newline on the end.
+# printk includes all preceding printk's which have no newline on the end.
 # we assume the first bad printk is the one to report.
                if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
                        my $ok = 0;
                        for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
                                #print "CHECK<$lines[$ln - 1]\n";
-                               # we have a preceeding printk if it ends
+                               # we have a preceding printk if it ends
                                # with "\n" ignore it, else it is to blame
                                if ($lines[$ln - 1] =~ m{\bprintk\(}) {
                                        if ($rawlines[$ln - 1] !~ m{\\n"}) {
@@ -1868,7 +2377,8 @@ sub process {
                                }
                        }
                        if ($ok == 0) {
-                               WARN("printk() should include KERN_ facility level\n" . $herecurr);
+                               WARN("PRINTK_WITHOUT_KERN_LEVEL",
+                                    "printk() should include KERN_ facility level\n" . $herecurr);
                        }
                }
 
@@ -1876,13 +2386,21 @@ sub process {
 # or if closed on same line
                if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
                    !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
-                       ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
+                       ERROR("OPEN_BRACE",
+                             "open brace '{' following function declarations go on the next line\n" . $herecurr);
                }
 
 # open braces for enum, union and struct go on the same line.
                if ($line =~ /^.\s*{/ &&
                    $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
-                       ERROR("open brace '{' following $1 go on the same line\n" . $hereprev);
+                       ERROR("OPEN_BRACE",
+                             "open brace '{' following $1 go on the same line\n" . $hereprev);
+               }
+
+# missing space after union, struct or enum definition
+               if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) {
+                   WARN("SPACING",
+                        "missing space after $1 definition\n" . $herecurr);
                }
 
 # check for spacing round square brackets; allowed:
@@ -1893,8 +2411,9 @@ sub process {
                        my ($where, $prefix) = ($-[1], $1);
                        if ($prefix !~ /$Type\s+$/ &&
                            ($where != 0 || $prefix !~ /^.\s+$/) &&
-                           $prefix !~ /{\s+$/) {
-                               ERROR("space prohibited before open square bracket '['\n" . $herecurr);
+                           $prefix !~ /[{,]\s+$/) {
+                               ERROR("BRACKET_SPACE",
+                                     "space prohibited before open square bracket '['\n" . $herecurr);
                        }
                }
 
@@ -1925,7 +2444,8 @@ sub process {
                        } elsif ($ctx =~ /$Type$/) {
 
                        } else {
-                               WARN("space prohibited between function name and open parenthesis '('\n" . $herecurr);
+                               WARN("SPACING",
+                                    "space prohibited between function name and open parenthesis '('\n" . $herecurr);
                        }
                }
 # Check operator spacing.
@@ -1945,7 +2465,7 @@ sub process {
                        for (my $n = 0; $n < $#elements; $n += 2) {
                                $off += length($elements[$n]);
 
-                               # Pick up the preceeding and succeeding characters.
+                               # Pick up the preceding and succeeding characters.
                                my $ca = substr($opline, 0, $off);
                                my $cc = '';
                                if (length($opline) >= ($off + length($elements[$n + 1]))) {
@@ -1999,7 +2519,8 @@ sub process {
                                } elsif ($op eq ';') {
                                        if ($ctx !~ /.x[WEBC]/ &&
                                            $cc !~ /^\\/ && $cc !~ /^;/) {
-                                               ERROR("space required after that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space required after that '$op' $at\n" . $hereptr);
                                        }
 
                                # // is a comment
@@ -2010,13 +2531,15 @@ sub process {
                                #   :   when part of a bitfield
                                } elsif ($op eq '->' || $opv eq ':B') {
                                        if ($ctx =~ /Wx.|.xW/) {
-                                               ERROR("spaces prohibited around that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "spaces prohibited around that '$op' $at\n" . $hereptr);
                                        }
 
                                # , must have a space on the right.
                                } elsif ($op eq ',') {
                                        if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
-                                               ERROR("space required after that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space required after that '$op' $at\n" . $hereptr);
                                        }
 
                                # '*' as part of a type definition -- reported already.
@@ -2030,26 +2553,31 @@ sub process {
                                         $opv eq '*U' || $opv eq '-U' ||
                                         $opv eq '&U' || $opv eq '&&U') {
                                        if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
-                                               ERROR("space required before that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space required before that '$op' $at\n" . $hereptr);
                                        }
                                        if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
                                                # A unary '*' may be const
 
                                        } elsif ($ctx =~ /.xW/) {
-                                               ERROR("space prohibited after that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space prohibited after that '$op' $at\n" . $hereptr);
                                        }
 
                                # unary ++ and unary -- are allowed no space on one side.
                                } elsif ($op eq '++' or $op eq '--') {
                                        if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) {
-                                               ERROR("space required one side of that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space required one side of that '$op' $at\n" . $hereptr);
                                        }
                                        if ($ctx =~ /Wx[BE]/ ||
                                            ($ctx =~ /Wx./ && $cc =~ /^;/)) {
-                                               ERROR("space prohibited before that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space prohibited before that '$op' $at\n" . $hereptr);
                                        }
                                        if ($ctx =~ /ExW/) {
-                                               ERROR("space prohibited after that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space prohibited after that '$op' $at\n" . $hereptr);
                                        }
 
 
@@ -2061,7 +2589,8 @@ sub process {
                                         $op eq '%')
                                {
                                        if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
-                                               ERROR("need consistent spacing around '$op' $at\n" .
+                                               ERROR("SPACING",
+                                                     "need consistent spacing around '$op' $at\n" .
                                                        $hereptr);
                                        }
 
@@ -2069,7 +2598,8 @@ sub process {
                                # terminating a case value or a label.
                                } elsif ($opv eq ':C' || $opv eq ':L') {
                                        if ($ctx =~ /Wx./) {
-                                               ERROR("space prohibited before that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "space prohibited before that '$op' $at\n" . $hereptr);
                                        }
 
                                # All the others need spaces both sides.
@@ -2092,7 +2622,8 @@ sub process {
                                        }
 
                                        if ($ok == 0) {
-                                               ERROR("spaces required around that '$op' $at\n" . $hereptr);
+                                               ERROR("SPACING",
+                                                     "spaces required around that '$op' $at\n" . $hereptr);
                                        }
                                }
                                $off += length($elements[$n + 1]);
@@ -2101,7 +2632,8 @@ sub process {
 
 # check for multiple assignments
                if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
-                       CHK("multiple assignments should be avoided\n" . $herecurr);
+                       CHK("MULTIPLE_ASSIGNMENTS",
+                           "multiple assignments should be avoided\n" . $herecurr);
                }
 
 ## # check for multiple declarations, allowing for a function declaration
@@ -2115,45 +2647,53 @@ sub process {
 ##                     while ($ln =~ s/\([^\(\)]*\)//g) {
 ##                     }
 ##                     if ($ln =~ /,/) {
-##                             WARN("declaring multiple variables together should be avoided\n" . $herecurr);
+##                             WARN("MULTIPLE_DECLARATION",
+##                                  "declaring multiple variables together should be avoided\n" . $herecurr);
 ##                     }
 ##             }
 
 #need space before brace following if, while, etc
                if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
                    $line =~ /do{/) {
-                       ERROR("space required before the open brace '{'\n" . $herecurr);
+                       ERROR("SPACING",
+                             "space required before the open brace '{'\n" . $herecurr);
                }
 
 # closing brace should have a space following it when it has anything
 # on the line
                if ($line =~ /}(?!(?:,|;|\)))\S/) {
-                       ERROR("space required after that close brace '}'\n" . $herecurr);
+                       ERROR("SPACING",
+                             "space required after that close brace '}'\n" . $herecurr);
                }
 
 # check spacing on square brackets
                if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
-                       ERROR("space prohibited after that open square bracket '['\n" . $herecurr);
+                       ERROR("SPACING",
+                             "space prohibited after that open square bracket '['\n" . $herecurr);
                }
                if ($line =~ /\s\]/) {
-                       ERROR("space prohibited before that close square bracket ']'\n" . $herecurr);
+                       ERROR("SPACING",
+                             "space prohibited before that close square bracket ']'\n" . $herecurr);
                }
 
 # check spacing on parentheses
                if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
                    $line !~ /for\s*\(\s+;/) {
-                       ERROR("space prohibited after that open parenthesis '('\n" . $herecurr);
+                       ERROR("SPACING",
+                             "space prohibited after that open parenthesis '('\n" . $herecurr);
                }
                if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
                    $line !~ /for\s*\(.*;\s+\)/ &&
                    $line !~ /:\s+\)/) {
-                       ERROR("space prohibited before that close parenthesis ')'\n" . $herecurr);
+                       ERROR("SPACING",
+                             "space prohibited before that close parenthesis ')'\n" . $herecurr);
                }
 
 #goto labels aren't indented, allow a single space however
                if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
                   !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
-                       WARN("labels should not be indented\n" . $herecurr);
+                       WARN("INDENTED_LABEL",
+                            "labels should not be indented\n" . $herecurr);
                }
 
 # Return is not a function.
@@ -2162,30 +2702,44 @@ sub process {
                        my $value = $2;
 
                        # Flatten any parentheses
-                       $value =~ s/\)\(/\) \(/g;
-                       while ($value =~ s/\[[^\{\}]*\]/1/ ||
+                       $value =~ s/\(/ \(/g;
+                       $value =~ s/\)/\) /g;
+                       while ($value =~ s/\[[^\[\]]*\]/1/ ||
                               $value !~ /(?:$Ident|-?$Constant)\s*
                                             $Compare\s*
                                             (?:$Ident|-?$Constant)/x &&
                               $value =~ s/\([^\(\)]*\)/1/) {
                        }
-
-                       if ($value =~ /^(?:$Ident|-?$Constant)$/) {
-                               ERROR("return is not a function, parentheses are not required\n" . $herecurr);
+#print "value<$value>\n";
+                       if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
+                               ERROR("RETURN_PARENTHESES",
+                                     "return is not a function, parentheses are not required\n" . $herecurr);
 
                        } elsif ($spacing !~ /\s+/) {
-                               ERROR("space required before the open parenthesis '('\n" . $herecurr);
+                               ERROR("SPACING",
+                                     "space required before the open parenthesis '('\n" . $herecurr);
+                       }
+               }
+# Return of what appears to be an errno should normally be -'ve
+               if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
+                       my $name = $1;
+                       if ($name ne 'EOF' && $name ne 'ERROR') {
+                               WARN("USE_NEGATIVE_ERRNO",
+                                    "return of an errno should typically be -ve (return -$1)\n" . $herecurr);
                        }
                }
 
 # Need a space before open parenthesis after if, while etc
                if ($line=~/\b(if|while|for|switch)\(/) {
-                       ERROR("space required before the open parenthesis '('\n" . $herecurr);
+                       ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr);
                }
 
 # Check for illegal assignment in if conditional -- and check for trailing
 # statements after the conditional.
                if ($line =~ /do\s*(?!{)/) {
+                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
+                               ctx_statement_block($linenr, $realcnt, 0)
+                                       if (!defined $stat);
                        my ($stat_next) = ctx_statement_block($line_nr_next,
                                                $remain_next, $off_next);
                        $stat_next =~ s/\n./\n /g;
@@ -2208,7 +2762,8 @@ sub process {
                        my ($s, $c) = ($stat, $cond);
 
                        if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) {
-                               ERROR("do not use assignment in if condition\n" . $herecurr);
+                               ERROR("ASSIGN_IN_IF",
+                                     "do not use assignment in if condition\n" . $herecurr);
                        }
 
                        # Find out what is on the end of the line after the
@@ -2230,7 +2785,8 @@ sub process {
                                        $stat_real = "[...]\n$stat_real";
                                }
 
-                               ERROR("trailing statements should be on next line\n" . $herecurr . $stat_real);
+                               ERROR("TRAILING_STATEMENTS",
+                                     "trailing statements should be on next line\n" . $herecurr . $stat_real);
                        }
                }
 
@@ -2246,7 +2802,8 @@ sub process {
                                (?:\&\&|\|\||\)|\])
                        )/x)
                {
-                       WARN("boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr);
+                       WARN("HEXADECIMAL_BOOLEAN_TEST",
+                            "boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr);
                }
 
 # if and else should not have general statements after it
@@ -2254,12 +2811,14 @@ sub process {
                        my $s = $1;
                        $s =~ s/$;//g;  # Remove any comments
                        if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) {
-                               ERROR("trailing statements should be on next line\n" . $herecurr);
+                               ERROR("TRAILING_STATEMENTS",
+                                     "trailing statements should be on next line\n" . $herecurr);
                        }
                }
 # if should not continue a brace
                if ($line =~ /}\s*if\b/) {
-                       ERROR("trailing statements should be on next line\n" .
+                       ERROR("TRAILING_STATEMENTS",
+                             "trailing statements should be on next line\n" .
                                $herecurr);
                }
 # case and default should not have general statements after them
@@ -2269,14 +2828,16 @@ sub process {
                        \s*return\s+
                    )/xg)
                {
-                       ERROR("trailing statements should be on next line\n" . $herecurr);
+                       ERROR("TRAILING_STATEMENTS",
+                             "trailing statements should be on next line\n" . $herecurr);
                }
 
                # Check for }<nl>else {, these must be at the same
                # indent level to be relevant to each other.
                if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and
                                                $previndent == $indent) {
-                       ERROR("else should follow close brace '}'\n" . $hereprev);
+                       ERROR("ELSE_AFTER_BRACE",
+                             "else should follow close brace '}'\n" . $hereprev);
                }
 
                if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and
@@ -2289,7 +2850,8 @@ sub process {
                        $s =~ s/\n.*//g;
 
                        if ($s =~ /^\s*;/) {
-                               ERROR("while should follow close brace '}'\n" . $hereprev);
+                               ERROR("WHILE_AFTER_BRACE",
+                                     "while should follow close brace '}'\n" . $hereprev);
                        }
                }
 
@@ -2302,7 +2864,8 @@ sub process {
 
 #no spaces allowed after \ in define
                if ($line=~/\#\s*define.*\\\s$/) {
-                       WARN("Whitepspace after \\ makes next lines useless\n" . $herecurr);
+                       WARN("WHITESPACE_AFTER_LINE_CONTINUATION",
+                            "Whitepspace after \\ makes next lines useless\n" . $herecurr);
                }
 
 #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
@@ -2311,12 +2874,14 @@ sub process {
                        my $checkfile = "include/linux/$file";
                        if (-f "$root/$checkfile" &&
                            $realfile ne $checkfile &&
-                           $1 ne 'irq')
+                           $1 !~ /$allowed_asm_includes/)
                        {
                                if ($realfile =~ m{^arch/}) {
-                                       CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+                                       CHK("ARCH_INCLUDE_LINUX",
+                                           "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
                                } else {
-                                       WARN("Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+                                       WARN("INCLUDE_LINUX",
+                                            "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
                                }
                        }
                }
@@ -2330,47 +2895,13 @@ sub process {
                        my $cnt = $realcnt;
                        my ($off, $dstat, $dcond, $rest);
                        my $ctx = '';
-
-                       my $args = defined($1);
-
-                       # Find the end of the macro and limit our statement
-                       # search to that.
-                       while ($cnt > 0 && defined $lines[$ln - 1] &&
-                               $lines[$ln - 1] =~ /^(?:-|..*\\$)/)
-                       {
-                               $ctx .= $rawlines[$ln - 1] . "\n";
-                               $cnt-- if ($lines[$ln - 1] !~ /^-/);
-                               $ln++;
-                       }
-                       $ctx .= $rawlines[$ln - 1];
-
                        ($dstat, $dcond, $ln, $cnt, $off) =
-                               ctx_statement_block($linenr, $ln - $linenr + 1, 0);
+                               ctx_statement_block($linenr, $realcnt, 0);
+                       $ctx = $dstat;
                        #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n";
                        #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
 
-                       # Extract the remainder of the define (if any) and
-                       # rip off surrounding spaces, and trailing \'s.
-                       $rest = '';
-                       while ($off != 0 || ($cnt > 0 && $rest =~ /\\\s*$/)) {
-                               #print "ADDING cnt<$cnt> $off <" . substr($lines[$ln - 1], $off) . "> rest<$rest>\n";
-                               if ($off != 0 || $lines[$ln - 1] !~ /^-/) {
-                                       $rest .= substr($lines[$ln - 1], $off) . "\n";
-                                       $cnt--;
-                               }
-                               $ln++;
-                               $off = 0;
-                       }
-                       $rest =~ s/\\\n.//g;
-                       $rest =~ s/^\s*//s;
-                       $rest =~ s/\s*$//s;
-
-                       # Clean up the original statement.
-                       if ($args) {
-                               substr($dstat, 0, length($dcond), '');
-                       } else {
-                               $dstat =~ s/^.\s*\#\s*define\s+$Ident\s*//;
-                       }
+                       $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//;
                        $dstat =~ s/$;//g;
                        $dstat =~ s/\\\n.//g;
                        $dstat =~ s/^\s*//s;
@@ -2379,7 +2910,13 @@ sub process {
                        # Flatten any parentheses and braces
                        while ($dstat =~ s/\([^\(\)]*\)/1/ ||
                               $dstat =~ s/\{[^\{\}]*\}/1/ ||
-                              $dstat =~ s/\[[^\{\}]*\]/1/)
+                              $dstat =~ s/\[[^\[\]]*\]/1/)
+                       {
+                       }
+
+                       # Flatten any obvious string concatentation.
+                       while ($dstat =~ s/("X*")\s*$Ident/$1/ ||
+                              $dstat =~ s/$Ident\s*("X*")/$1/)
                        {
                        }
 
@@ -2395,22 +2932,34 @@ sub process {
                                \.$Ident\s*=\s*|
                                ^\"|\"$
                        }x;
-                       #print "REST<$rest> dstat<$dstat>\n";
-                       if ($rest ne '') {
-                               if ($rest !~ /while\s*\(/ &&
-                                   $dstat !~ /$exceptions/)
-                               {
-                                       ERROR("Macros with multiple statements should be enclosed in a do - while loop\n" . "$here\n$ctx\n");
+                       #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
+                       if ($dstat ne '' &&
+                           $dstat !~ /^(?:$Ident|-?$Constant),$/ &&                    # 10, // foo(),
+                           $dstat !~ /^(?:$Ident|-?$Constant);$/ &&                    # foo();
+                           $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ &&         # 10 // foo() // !foo // ~foo // -foo
+                           $dstat !~ /^'X'$/ &&                                        # character constants
+                           $dstat !~ /$exceptions/ &&
+                           $dstat !~ /^\.$Ident\s*=/ &&                                # .foo =
+                           $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ &&       # do {...} while (...); // do {...} while (...)
+                           $dstat !~ /^for\s*$Constant$/ &&                            # for (...)
+                           $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ &&   # for (...) bar()
+                           $dstat !~ /^do\s*{/ &&                                      # do {...
+                           $dstat !~ /^\({/)                                           # ({...
+                       {
+                               $ctx =~ s/\n*$//;
+                               my $herectx = $here . "\n";
+                               my $cnt = statement_rawlines($ctx);
+
+                               for (my $n = 0; $n < $cnt; $n++) {
+                                       $herectx .= raw_line($linenr, $n) . "\n";
                                }
 
-                       } elsif ($ctx !~ /;/) {
-                               if ($dstat ne '' &&
-                                   $dstat !~ /^(?:$Ident|-?$Constant)$/ &&
-                                   $dstat !~ /$exceptions/ &&
-                                   $dstat !~ /^\.$Ident\s*=/ &&
-                                   $dstat =~ /$Operators/)
-                               {
-                                       ERROR("Macros with complex values should be enclosed in parenthesis\n" . "$here\n$ctx\n");
+                               if ($dstat =~ /;/) {
+                                       ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
+                                             "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
+                               } else {
+                                       ERROR("COMPLEX_MACRO",
+                                             "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
                                }
                        }
                }
@@ -2421,7 +2970,8 @@ sub process {
 #      ALIGN(...)
 #      VMLINUX_SYMBOL(...)
                if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) {
-                       WARN("vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr);
+                       WARN("MISSING_VMLINUX_SYMBOL",
+                            "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr);
                }
 
 # check for redundant bracing round if etc
@@ -2431,7 +2981,8 @@ sub process {
                        #print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n";
                        #print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n";
                        if ($#chunks > 0 && $level == 0) {
-                               my $allowed = 0;
+                               my @allowed = ();
+                               my $allow = 0;
                                my $seen = 0;
                                my $herectx = $here . "\n";
                                my $ln = $linenr - 1;
@@ -2442,6 +2993,7 @@ sub process {
                                        my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
                                        my $offset = statement_rawlines($whitespace) - 1;
 
+                                       $allowed[$allow] = 0;
                                        #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n";
 
                                        # We have looked at and allowed this specific line.
@@ -2454,22 +3006,34 @@ sub process {
 
                                        $seen++ if ($block =~ /^\s*{/);
 
-                                       #print "cond<$cond> block<$block> allowed<$allowed>\n";
+                                       #print "cond<$cond> block<$block> allowed<$allowed[$allow]>\n";
                                        if (statement_lines($cond) > 1) {
                                                #print "APW: ALLOWED: cond<$cond>\n";
-                                               $allowed = 1;
+                                               $allowed[$allow] = 1;
                                        }
                                        if ($block =~/\b(?:if|for|while)\b/) {
                                                #print "APW: ALLOWED: block<$block>\n";
-                                               $allowed = 1;
+                                               $allowed[$allow] = 1;
                                        }
                                        if (statement_block_size($block) > 1) {
                                                #print "APW: ALLOWED: lines block<$block>\n";
-                                               $allowed = 1;
+                                               $allowed[$allow] = 1;
                                        }
+                                       $allow++;
                                }
-                               if ($seen && !$allowed) {
-                                       WARN("braces {} are not necessary for any arm of this statement\n" . $herectx);
+                               if ($seen) {
+                                       my $sum_allowed = 0;
+                                       foreach (@allowed) {
+                                               $sum_allowed += $_;
+                                       }
+                                       if ($sum_allowed == 0) {
+                                               WARN("BRACES",
+                                                    "braces {} are not necessary for any arm of this statement\n" . $herectx);
+                                       } elsif ($sum_allowed != $allow &&
+                                                $seen != $allow) {
+                                               CHK("BRACES",
+                                                   "braces {} should be used on all arms of this statement\n" . $herectx);
+                                       }
                                }
                        }
                }
@@ -2516,45 +3080,45 @@ sub process {
                                }
                        }
                        if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) {
-                               my $herectx = $here . "\n";;
+                               my $herectx = $here . "\n";
                                my $cnt = statement_rawlines($block);
 
                                for (my $n = 0; $n < $cnt; $n++) {
-                                       $herectx .= raw_line($linenr, $n) . "\n";;
+                                       $herectx .= raw_line($linenr, $n) . "\n";
                                }
 
-                               WARN("braces {} are not necessary for single statement blocks\n" . $herectx);
+                               WARN("BRACES",
+                                    "braces {} are not necessary for single statement blocks\n" . $herectx);
                        }
                }
 
 # don't include deprecated include files (uses RAW line)
                for my $inc (@dep_includes) {
                        if ($rawline =~ m@^.\s*\#\s*include\s*\<$inc>@) {
-                               ERROR("Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr);
+                               ERROR("DEPRECATED_INCLUDE",
+                                     "Don't use <$inc>: see Documentation/feature-removal-schedule.txt\n" . $herecurr);
                        }
                }
 
 # don't use deprecated functions
                for my $func (@dep_functions) {
                        if ($line =~ /\b$func\b/) {
-                               ERROR("Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr);
+                               ERROR("DEPRECATED_FUNCTION",
+                                     "Don't use $func(): see Documentation/feature-removal-schedule.txt\n" . $herecurr);
                        }
                }
 
 # no volatiles please
                my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
                if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
-                       WARN("Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
-               }
-
-# SPIN_LOCK_UNLOCKED & RW_LOCK_UNLOCKED are deprecated
-               if ($line =~ /\b(SPIN_LOCK_UNLOCKED|RW_LOCK_UNLOCKED)/) {
-                       ERROR("Use of $1 is deprecated: see Documentation/spinlocks.txt\n" . $herecurr);
+                       WARN("VOLATILE",
+                            "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
                }
 
 # warn about #if 0
                if ($line =~ /^.\s*\#\s*if\s+0\b/) {
-                       CHK("if this code is redundant consider removing it\n" .
+                       CHK("REDUNDANT_CODE",
+                           "if this code is redundant consider removing it\n" .
                                $herecurr);
                }
 
@@ -2562,14 +3126,33 @@ sub process {
                if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
                        my $expr = $1;
                        if ($line =~ /\bkfree\(\Q$expr\E\);/) {
-                               WARN("kfree(NULL) is safe this check is probably not required\n" . $hereprev);
+                               WARN("NEEDLESS_KFREE",
+                                    "kfree(NULL) is safe this check is probably not required\n" . $hereprev);
                        }
                }
 # check for needless usb_free_urb() checks
                if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
                        my $expr = $1;
                        if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) {
-                               WARN("usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev);
+                               WARN("NEEDLESS_USB_FREE_URB",
+                                    "usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev);
+                       }
+               }
+
+# prefer usleep_range over udelay
+               if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) {
+                       # ignore udelay's < 10, however
+                       if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) {
+                               CHK("USLEEP_RANGE",
+                                   "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
+                       }
+               }
+
+# warn about unexpectedly long msleep's
+               if ($line =~ /\bmsleep\s*\((\d+)\);/) {
+                       if ($1 < 20) {
+                               WARN("MSLEEP",
+                                    "msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line);
                        }
                }
 
@@ -2582,7 +3165,8 @@ sub process {
 
 # warn about spacing in #ifdefs
                if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
-                       ERROR("exactly one space required after that #$1\n" . $herecurr);
+                       ERROR("SPACING",
+                             "exactly one space required after that #$1\n" . $herecurr);
                }
 
 # check for spinlock_t definitions without a comment.
@@ -2590,40 +3174,119 @@ sub process {
                    $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
                        my $which = $1;
                        if (!ctx_has_comment($first_line, $linenr)) {
-                               CHK("$1 definition without comment\n" . $herecurr);
+                               CHK("UNCOMMENTED_DEFINITION",
+                                   "$1 definition without comment\n" . $herecurr);
                        }
                }
 # check for memory barriers without a comment.
                if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
                        if (!ctx_has_comment($first_line, $linenr)) {
-                               CHK("memory barrier without comment\n" . $herecurr);
+                               CHK("MEMORY_BARRIER",
+                                   "memory barrier without comment\n" . $herecurr);
                        }
                }
 # check of hardware specific defines
                if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
-                       CHK("architecture specific defines should be avoided\n" .  $herecurr);
+                       CHK("ARCH_DEFINES",
+                           "architecture specific defines should be avoided\n" .  $herecurr);
                }
 
 # Check that the storage class is at the beginning of a declaration
                if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) {
-                       WARN("storage class should be at the beginning of the declaration\n" . $herecurr)
+                       WARN("STORAGE_CLASS",
+                            "storage class should be at the beginning of the declaration\n" . $herecurr)
                }
 
 # check the location of the inline attribute, that it is between
 # storage class and type.
                if ($line =~ /\b$Type\s+$Inline\b/ ||
                    $line =~ /\b$Inline\s+$Storage\b/) {
-                       ERROR("inline keyword should sit between storage class and type\n" . $herecurr);
+                       ERROR("INLINE_LOCATION",
+                             "inline keyword should sit between storage class and type\n" . $herecurr);
                }
 
 # Check for __inline__ and __inline, prefer inline
                if ($line =~ /\b(__inline__|__inline)\b/) {
-                       WARN("plain inline is preferred over $1\n" . $herecurr);
+                       WARN("INLINE",
+                            "plain inline is preferred over $1\n" . $herecurr);
+               }
+
+# Check for __attribute__ packed, prefer __packed
+               if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
+                       WARN("PREFER_PACKED",
+                            "__packed is preferred over __attribute__((packed))\n" . $herecurr);
+               }
+
+# Check for __attribute__ aligned, prefer __aligned
+               if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
+                       WARN("PREFER_ALIGNED",
+                            "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
+               }
+
+# Check for __attribute__ format(printf, prefer __printf
+               if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
+                       WARN("PREFER_PRINTF",
+                            "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr);
+               }
+
+# Check for __attribute__ format(scanf, prefer __scanf
+               if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
+                       WARN("PREFER_SCANF",
+                            "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr);
                }
 
 # check for sizeof(&)
                if ($line =~ /\bsizeof\s*\(\s*\&/) {
-                       WARN("sizeof(& should be avoided\n" . $herecurr);
+                       WARN("SIZEOF_ADDRESS",
+                            "sizeof(& should be avoided\n" . $herecurr);
+               }
+
+# check for line continuations in quoted strings with odd counts of "
+               if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
+                       WARN("LINE_CONTINUATIONS",
+                            "Avoid line continuations in quoted strings\n" . $herecurr);
+               }
+
+# Check for misused memsets
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) {
+
+                       my $ms_addr = $2;
+                       my $ms_val = $7;
+                       my $ms_size = $12;
+
+                       if ($ms_size =~ /^(0x|)0$/i) {
+                               ERROR("MEMSET",
+                                     "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n");
+                       } elsif ($ms_size =~ /^(0x|)1$/i) {
+                               WARN("MEMSET",
+                                    "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . "$here\n$stat\n");
+                       }
+               }
+
+# typecasts on min/max could be min_t/max_t
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) {
+                       if (defined $2 || defined $7) {
+                               my $call = $1;
+                               my $cast1 = deparenthesize($2);
+                               my $arg1 = $3;
+                               my $cast2 = deparenthesize($7);
+                               my $arg2 = $8;
+                               my $cast;
+
+                               if ($cast1 ne "" && $cast2 ne "" && $cast1 ne $cast2) {
+                                       $cast = "$cast1 or $cast2";
+                               } elsif ($cast1 ne "") {
+                                       $cast = $cast1;
+                               } else {
+                                       $cast = $cast2;
+                               }
+                               WARN("MINMAX",
+                                    "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . "$here\n$stat\n");
+                       }
                }
 
 # check for new externs in .c files.
@@ -2640,17 +3303,20 @@ sub process {
                        if ($s =~ /^\s*;/ &&
                            $function_name ne 'uninitialized_var')
                        {
-                               WARN("externs should be avoided in .c files\n" .  $herecurr);
+                               WARN("AVOID_EXTERNS",
+                                    "externs should be avoided in .c files\n" .  $herecurr);
                        }
 
                        if ($paren_space =~ /\n/) {
-                               WARN("arguments for function declarations should follow identifier\n" . $herecurr);
+                               WARN("FUNCTION_ARGUMENTS",
+                                    "arguments for function declarations should follow identifier\n" . $herecurr);
                        }
 
                } elsif ($realfile =~ /\.c$/ && defined $stat &&
                    $stat =~ /^.\s*extern\s+/)
                {
-                       WARN("externs should be avoided in .c files\n" .  $herecurr);
+                       WARN("AVOID_EXTERNS",
+                            "externs should be avoided in .c files\n" .  $herecurr);
                }
 
 # checks for new __setup's
@@ -2658,37 +3324,53 @@ sub process {
                        my $name = $1;
 
                        if (!grep(/$name/, @setup_docs)) {
-                               CHK("__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr);
+                               CHK("UNDOCUMENTED_SETUP",
+                                   "__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr);
                        }
                }
 
 # check for pointless casting of kmalloc return
-               if ($line =~ /\*\s*\)\s*k[czm]alloc\b/) {
-                       WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
+               if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) {
+                       WARN("UNNECESSARY_CASTS",
+                            "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
+               }
+
+# check for multiple semicolons
+               if ($line =~ /;\s*;\s*$/) {
+                   WARN("ONE_SEMICOLON",
+                        "Statements terminations use 1 semicolon\n" . $herecurr);
                }
 
 # check for gcc specific __FUNCTION__
                if ($line =~ /__FUNCTION__/) {
-                       WARN("__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
+                       WARN("USE_FUNC",
+                            "__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
                }
 
-# check for semaphores used as mutexes
-               if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) {
-                       WARN("mutexes are preferred for single holder semaphores\n" . $herecurr);
+# check for use of yield()
+               if ($line =~ /\byield\s*\(\s*\)/) {
+                       WARN("YIELD",
+                            "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n"  . $herecurr);
                }
-# check for semaphores used as mutexes
-               if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) {
-                       WARN("consider using a completion\n" . $herecurr);
 
+# check for semaphores initialized locked
+               if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
+                       WARN("CONSIDER_COMPLETION",
+                            "consider using a completion\n" . $herecurr);
                }
-# recommend strict_strto* over simple_strto*
-               if ($line =~ /\bsimple_(strto.*?)\s*\(/) {
-                       WARN("consider using strict_$1 in preference to simple_$1\n" . $herecurr);
+
+# recommend kstrto* over simple_strto* and strict_strto*
+               if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
+                       WARN("CONSIDER_KSTRTO",
+                            "$1 is obsolete, use k$3 instead\n" . $herecurr);
                }
+
 # check for __initcall(), use device_initcall() explicitly please
                if ($line =~ /^.\s*__initcall\s*\(/) {
-                       WARN("please use device_initcall() instead of __initcall()\n" . $herecurr);
+                       WARN("USE_DEVICE_INITCALL",
+                            "please use device_initcall() instead of __initcall()\n" . $herecurr);
                }
+
 # check for various ops structs, ensure they are const.
                my $struct_ops = qr{acpi_dock_ops|
                                address_space_operations|
@@ -2729,7 +3411,8 @@ sub process {
                                wd_ops}x;
                if ($line !~ /\bconst\b/ &&
                    $line =~ /\bstruct\s+($struct_ops)\b/) {
-                       WARN("struct $1 should normally be const\n" .
+                       WARN("CONST_STRUCT",
+                            "struct $1 should normally be const\n" .
                                $herecurr);
                }
 
@@ -2742,7 +3425,8 @@ sub process {
                    $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ &&
                    $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/)
                {
-                       WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
+                       WARN("NR_CPUS",
+                            "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
                }
 
 # check for %L{u,d,i} in strings
@@ -2751,7 +3435,8 @@ sub process {
                        $string = substr($rawline, $-[1], $+[1] - $-[1]);
                        $string =~ s/%%/__/g;
                        if ($string =~ /(?<!%)%L[udi]/) {
-                               WARN("\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
+                               WARN("PRINTF_L",
+                                    "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
                                last;
                        }
                }
@@ -2759,9 +3444,11 @@ sub process {
 # whine mightly about in_atomic
                if ($line =~ /\bin_atomic\s*\(/) {
                        if ($realfile =~ m@^drivers/@) {
-                               ERROR("do not use in_atomic in drivers\n" . $herecurr);
+                               ERROR("IN_ATOMIC",
+                                     "do not use in_atomic in drivers\n" . $herecurr);
                        } elsif ($realfile !~ m@^kernel/@) {
-                               WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
+                               WARN("IN_ATOMIC",
+                                    "use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
                        }
                }
 
@@ -2771,9 +3458,16 @@ sub process {
                        if ($realfile !~ m@^kernel/lockdep@ &&
                            $realfile !~ m@^include/linux/lockdep@ &&
                            $realfile !~ m@^drivers/base/core@) {
-                               ERROR("lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
+                               ERROR("LOCKDEP",
+                                     "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
                        }
                }
+
+               if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
+                   $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
+                       WARN("EXPORTED_WORLD_WRITABLE",
+                            "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
+               }
        }
 
        # If we have no input at all, then there is nothing to report on
@@ -2795,10 +3489,12 @@ sub process {
        }
 
        if (!$is_patch) {
-               ERROR("Does not appear to be a unified-diff format patch\n");
+               ERROR("NOT_UNIFIED_DIFF",
+                     "Does not appear to be a unified-diff format patch\n");
        }
        if ($is_patch && $chk_signoff && $signoff == 0) {
-               ERROR("Missing Signed-off-by: line(s)\n");
+               ERROR("MISSING_SIGN_OFF",
+                     "Missing Signed-off-by: line(s)\n");
        }
 
        print report_dump();
@@ -2810,13 +3506,40 @@ sub process {
                print "\n" if ($quiet == 0);
        }
 
+       if ($quiet == 0) {
+
+               if ($^V lt 5.10.0) {
+                       print("NOTE: perl $^V is not modern enough to detect all possible issues.\n");
+                       print("An upgrade to at least perl v5.10.0 is suggested.\n\n");
+               }
+
+               # If there were whitespace errors which cleanpatch can fix
+               # then suggest that.
+               if ($rpt_cleaners) {
+                       print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n";
+                       print "      scripts/cleanfile\n\n";
+                       $rpt_cleaners = 0;
+               }
+       }
+
+       if ($quiet == 0 && keys %ignore_type) {
+           print "NOTE: Ignored message types:";
+           foreach my $ignore (sort keys %ignore_type) {
+               print " $ignore";
+           }
+           print "\n\n";
+       }
+
        if ($clean == 1 && $quiet == 0) {
                print "$vname has no obvious style problems and is ready for submission.\n"
        }
        if ($clean == 0 && $quiet == 0) {
-               print "$vname has style problems, please review.  If any of these errors\n";
-               print "are false positives report them to the maintainer, see\n";
-               print "CHECKPATCH in MAINTAINERS.\n";
+               print << "EOM";
+$vname has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see CHECKPATCH in MAINTAINERS.
+EOM
        }
 
        return $clean;
index 6f4a40f..aea4cc5 100644 (file)
@@ -1,5 +1,6 @@
 defaultwwwdir = $(pkgdatadir)/www
 defaultwww_DATA = \
+       footer.tpl\
        js/excanvas.js\
        js/jquery.min.js\
        js/ppastats.js\
index 935af87..1b3f3db 100644 (file)
@@ -35,7 +35,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = www
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(srcdir)/footer.tpl.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
        $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
@@ -47,7 +48,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = footer.tpl
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
 DIST_SOURCES =
@@ -204,6 +205,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 defaultwwwdir = $(pkgdatadir)/www
 defaultwww_DATA = \
+       footer.tpl\
        js/excanvas.js\
        js/jquery.min.js\
        js/ppastats.js\
@@ -246,6 +248,8 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+footer.tpl: $(top_builddir)/config.status $(srcdir)/footer.tpl.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 install-defaultwwwDATA: $(defaultwww_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(defaultwwwdir)" || $(MKDIR_P) "$(DESTDIR)$(defaultwwwdir)"
diff --git a/www/footer.tpl b/www/footer.tpl
new file mode 100644 (file)
index 0000000..b0feb3a
--- /dev/null
@@ -0,0 +1,5 @@
+    <div id="footer">
+      Generated by <a href='http://wpitchoune.net/ppastats'>ppastats</a> v0.0.x
+    </div>
+  </body>
+</html>
diff --git a/www/footer.tpl.in b/www/footer.tpl.in
new file mode 100644 (file)
index 0000000..1c75569
--- /dev/null
@@ -0,0 +1,5 @@
+    <div id="footer">
+      Generated by <a href='http://wpitchoune.net/ppastats'>ppastats</a> v@VERSION@
+    </div>
+  </body>
+</html>