nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aguettou...@apache.org
Subject [incubator-nuttx] branch master updated: tools/nxstyle.c: Alloc MHz in pre-processor variable names.
Date Thu, 02 Apr 2020 19:29:33 GMT
This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 65739a3  tools/nxstyle.c:  Alloc MHz in pre-processor variable names.
65739a3 is described below

commit 65739a38fb6b3de886e187dfe3eed4d60a8def86
Author: Gregory Nutt <gnutt@nuttx.org>
AuthorDate: Thu Apr 2 12:57:08 2020 -0600

    tools/nxstyle.c:  Alloc MHz in pre-processor variable names.
    
    The sub-string MHz is used frequently is pre-processor variable definitions.  The section
"Lowercase Exceptions" permits reasonable use of lowercase characters in pre-processor variable
names and, given the frequency of the use of MHz (no pun intended), it certainly should qualify.
---
 tools/nxstyle.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index e6e3c67..dc9a2e1 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -1399,6 +1399,7 @@ int main(int argc, char **argv, char **envp)
                    *   IGMPv2      as an IGMP version number
                    *   [0-9]p[0-9] as a decimal point
                    *   d[0-9]      as a divisor
+                   *   MHz         for frequencies
                    */
 
                    if (!have_lower && islower(line[n]))
@@ -1439,8 +1440,8 @@ int main(int argc, char **argv, char **envp)
                              }
                            break;
 
-                         /* Sequences containing 'p' or 'd' must have been
-                          * preceded by upper case characters.
+                         /* Sequences containing 'p', 'd', or 'z' must have
+                          * been preceded by upper case characters.
                           */
 
                          case 'p':
@@ -1459,6 +1460,16 @@ int main(int argc, char **argv, char **envp)
                              }
                              break;
 
+                         case 'z':
+                           if (!have_upper || n < 2 ||
+                               line[n - 1] != 'H' ||
+                               line[n - 2] != 'M')
+                             {
+                               have_lower = true;
+                             }
+                             break;
+                           break;
+
                          default:
                            have_lower = true;
                            break;
@@ -1473,13 +1484,6 @@ int main(int argc, char **argv, char **envp)
 
               if (have_upper && have_lower)
                 {
-                  /* REVISIT:  Although pre-processor definitions are
-                   * supposed to be all upper-case, there are exceptions
-                   * such as using 'p' for a decimal point or 'MHz'.
-                   * Those will be reported here, but probably should be
-                   * considered false alarms.
-                   */
-
                   /* Ignore symbols that begin with white-listed prefixes */
 
                   if (white_prefix(&line[ident_index], lineno))


Mime
View raw message