From c8004c7e000603dbe9f225a887773a9fbb956fc4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 5 Mar 2019 13:08:57 -0600 Subject: [PATCH] tools/nxstyle.c: Add capability to detect CamelCase identifiers. --- sched/Kconfig | 8 ++++++-- tools/nxstyle.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/sched/Kconfig b/sched/Kconfig index ba04275d16..22b5c20fdd 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -259,8 +259,12 @@ config SPINLOCK default n depends on ARCH_HAVE_TESTSET ---help--- - Enables suppport for spinlocks. Spinlocks are current used only for - SMP suppport. + Enables suppport for spinlocks. Spinlocks are used primarily for + synchronization in SMP configurations but are available for general + synchronization between CPUs. Use in a single CPU configuration would + most likely be fatal. Note, however, that this does not depend on + CONFIG_ARCH_HAVE_MULTICPU. This permits the use of spinlocks in + other novel architectures. config SPINLOCK_IRQ bool "Support Spinlocks with IRQ control" diff --git a/tools/nxstyle.c b/tools/nxstyle.c index 14c3af7ee0..ef7120afb6 100644 --- a/tools/nxstyle.c +++ b/tools/nxstyle.c @@ -1,7 +1,7 @@ /**************************************************************************** * tools/nxstyle.c * - * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2018-2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -187,6 +187,8 @@ int main(int argc, char **argv, char **envp) blank_lineno = -1; /* Line number of the last blank line */ noblank_lineno = -1; /* A blank line is not needed after this line */ + /* Process each line in the input stream */ + while (fgets(line, LINE_SIZE, instream)) { lineno++; @@ -512,7 +514,8 @@ int main(int argc, char **argv, char **envp) } else if (strncmp(&line[indent], "switch(", 7) == 0) { - fprintf(stderr, "Missing whitespace after keyword at line %d:%d\n", lineno, n); + fprintf(stderr, "Missing whitespace after keyword at line %d:%d\n", + lineno, n); bswitch = true; } @@ -523,6 +526,42 @@ int main(int argc, char **argv, char **envp) for (; line[n] != '\n' && line[n] != '\0'; n++) { + /* Skip over indentifiers */ + + if (ncomment == 0 && !bstring && (line[n] == '_' || isalpha(line[n]))) + { + bool have_upper = false; + bool have_lower = false; + int ident_index = n; + + /* Parse over the identifier. Check if it contains mixed upper- + * and lower-case characters. + */ + + do + { + have_upper |= isupper(line[n]); + have_lower |= islower(line[n]); + n++; + } + while (line[n] == '_' || isalnum(line[n])); + + if (have_upper && have_lower) + { + fprintf(stderr, "Mixed case identifier found at line %d:%d\n", + lineno, ident_index); + } + + /* Check if the identifier is the last thing on the line */ + + if (line[n] == '\n' || line[n] == '\0') + { + break; + } + } + + /* Handle comments */ + if (line[n] == '/' && !bstring) { /* Check for start of a C comment */