mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 09:49:21 +08:00
tools/nxstyle.c: Add logic to detect if there is a blank line following the final right brace. sched/: Applied the modified nxstyle to all C file as a test.
This commit is contained in:
parent
2be1153030
commit
b5111d2c38
14 changed files with 70 additions and 7 deletions
|
@ -178,6 +178,7 @@ static void clock_inittime(void)
|
|||
#ifndef CONFIG_RTC_HIRES
|
||||
clock_basetime(&g_basetime);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SCHED_TICKLESS
|
||||
g_system_timer = INITIAL_SYSTEM_TIMER_TICKS;
|
||||
if (g_system_timer > 0)
|
||||
|
@ -197,6 +198,7 @@ static void clock_inittime(void)
|
|||
}
|
||||
}
|
||||
#endif /* !CONFIG_SCHED_TICKLESS */
|
||||
|
||||
#else
|
||||
clock_inittimekeeping();
|
||||
#endif
|
||||
|
|
|
@ -122,6 +122,7 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
|
|||
up_rtc_settime(tp);
|
||||
}
|
||||
#endif
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
sinfo("basetime=(%ld,%lu) bias=(%ld,%lu)\n",
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Note that there cannot be more that CONFIG_MAX_TASKS tasks in total.
|
||||
* However, the number of child status structures may need to be significantly
|
||||
* larger because this number includes the maximum number of tasks that are
|
||||
|
@ -73,6 +74,7 @@
|
|||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Globals are maintained in a structure to minimize name collisions. */
|
||||
|
||||
struct child_pool_s
|
||||
|
|
|
@ -308,8 +308,9 @@ try_again:
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Normal tasking environment. */
|
||||
/* Get the TCB of the currently executing task on this CPU (avoid
|
||||
/* Normal tasking environment.
|
||||
*
|
||||
* Get the TCB of the currently executing task on this CPU (avoid
|
||||
* using this_task() which can recurse.
|
||||
*/
|
||||
|
||||
|
|
|
@ -615,6 +615,7 @@ errout_with_join:
|
|||
ptcb->joininfo = NULL;
|
||||
|
||||
errout_with_tcb:
|
||||
|
||||
/* Clear group binding */
|
||||
|
||||
if (ptcb && !group_joined)
|
||||
|
|
|
@ -117,6 +117,7 @@ int pthread_mutex_trylock(FAR pthread_mutex_t *mutex)
|
|||
mutex->nlocks = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -582,6 +582,7 @@ void sched_note_spinunlock(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
|
|||
{
|
||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_UNLOCK);
|
||||
}
|
||||
|
||||
void sched_note_spinabort(FAR struct tcb_s *tcb, FAR volatile void *spinlock)
|
||||
{
|
||||
note_spincommon(tcb, spinlock, NOTE_SPINLOCK_ABORT);
|
||||
|
|
|
@ -153,6 +153,7 @@ int nxsched_setscheduler(pid_t pid, int policy,
|
|||
DEBUGVERIFY(sched_sporadic_stop(tcb));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Save the FIFO scheduling parameters */
|
||||
|
||||
tcb->flags |= TCB_FLAG_SCHED_FIFO;
|
||||
|
@ -173,6 +174,7 @@ int nxsched_setscheduler(pid_t pid, int policy,
|
|||
DEBUGVERIFY(sched_sporadic_stop(tcb));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Save the round robin scheduling parameters */
|
||||
|
||||
tcb->flags |= TCB_FLAG_SCHED_RR;
|
||||
|
|
|
@ -676,7 +676,6 @@ static int nxsem_restoreholderprioB(FAR struct semholder_s *pholder,
|
|||
|
||||
if (pholder->htcb == rtcb)
|
||||
{
|
||||
|
||||
/* The running task has given up a count on the semaphore */
|
||||
|
||||
#if CONFIG_SEM_PREALLOCHOLDERS == 0
|
||||
|
|
|
@ -96,6 +96,7 @@ int nxsem_setprotocol(FAR sem_t *sem, int protocol)
|
|||
switch (protocol)
|
||||
{
|
||||
case SEM_PRIO_NONE:
|
||||
|
||||
/* Disable priority inheritance */
|
||||
|
||||
sem->flags |= PRIOINHERIT_FLAGS_DISABLE;
|
||||
|
@ -106,12 +107,14 @@ int nxsem_setprotocol(FAR sem_t *sem, int protocol)
|
|||
return OK;
|
||||
|
||||
case SEM_PRIO_INHERIT:
|
||||
|
||||
/* Enable priority inheritance (dangerous) */
|
||||
|
||||
sem->flags &= ~PRIOINHERIT_FLAGS_DISABLE;
|
||||
return OK;
|
||||
|
||||
case SEM_PRIO_PROTECT:
|
||||
|
||||
/* Not yet supported */
|
||||
|
||||
return -ENOSYS;
|
||||
|
|
|
@ -309,6 +309,7 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
return -ECANCELED;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Save the set of pending signals to wait for */
|
||||
|
||||
rtcb->sigwaitmask = *set;
|
||||
|
|
|
@ -92,10 +92,12 @@
|
|||
* (2) the number of symbols in that table. This information is currently
|
||||
* provided to 'exec()' from 'exec[l|v]()' via NuttX configuration settings:
|
||||
*
|
||||
* CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support
|
||||
* CONFIG_EXECFUNCS_HAVE_SYMTAB : Defined if there is a pre-defined symbol table
|
||||
* CONFIG_EXECFUNCS_SYMTAB_ARRAY : Symbol table name used by exec[l|v]
|
||||
* CONFIG_EXECFUNCS_NSYMBOLS_VAR : Variable holding number of symbols in the table
|
||||
* CONFIG_LIBC_EXECFUNCS : Enable exec[l|v] support
|
||||
* CONFIG_EXECFUNCS_HAVE_SYMTAB : Defined if there is a pre-defined
|
||||
* symbol table
|
||||
* CONFIG_EXECFUNCS_SYMTAB_ARRAY : Symbol table name used by exec[l|v]
|
||||
* CONFIG_EXECFUNCS_NSYMBOLS_VAR : Variable holding number of symbols
|
||||
* in the table
|
||||
*
|
||||
* As a result of the above, the current implementations of 'execl()' and
|
||||
* 'execv()' suffer from some incompatibilities that may or may not be
|
||||
|
|
|
@ -222,12 +222,14 @@ int wd_start(WDOG_ID wdog, int32_t delay, wdentry_t wdentry, int argc, ...)
|
|||
{
|
||||
wdog->parm[i] = va_arg(ap, wdparm_t);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
for (; i < CONFIG_MAX_WDOGPARMS; i++)
|
||||
{
|
||||
wdog->parm[i] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(ap);
|
||||
|
||||
/* Calculate delay+1, forcing the delay into a range that we can handle */
|
||||
|
|
|
@ -129,6 +129,7 @@ int main(int argc, char **argv, char **envp)
|
|||
int blank_lineno; /* Line number of the last blank line */
|
||||
int noblank_lineno; /* A blank line is not needed after this line */
|
||||
int lbrace_lineno; /* Line number of last left brace */
|
||||
int rbrace_lineno; /* Last line containing a right brace */
|
||||
int externc_lineno; /* Last line where 'extern "C"' declared */
|
||||
int linelen; /* Length of the line */
|
||||
int maxline; /* Lines longer that this generate warnings */
|
||||
|
@ -213,6 +214,7 @@ 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 */
|
||||
lbrace_lineno = -1; /* Line number of last left brace */
|
||||
rbrace_lineno = -1; /* Last line containine a right brace */
|
||||
externc_lineno = -1; /* Last line where 'extern "C"' declared */
|
||||
|
||||
/* Process each line in the input stream */
|
||||
|
@ -291,6 +293,47 @@ int main(int argc, char **argv, char **envp)
|
|||
fprintf(stderr,
|
||||
"Missing file header comment block at line 1\n");
|
||||
}
|
||||
|
||||
/* Check for a blank line following a right brace */
|
||||
|
||||
if (bfunctions && lineno == rbrace_lineno + 1)
|
||||
{
|
||||
/* Check if this line contains a right brace. A right brace
|
||||
* must be followed by 'else', 'while', 'break', a blank line,
|
||||
* another right brace, or a pre-processor directive like #endif
|
||||
*/
|
||||
|
||||
if (strchr(line, '}') == NULL && line[n] != '#' &&
|
||||
strncmp(&line[n], "else", 4) != 0 &&
|
||||
strncmp(&line[n], "while", 5) != 0 &&
|
||||
strncmp(&line[n], "break", 5) != 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Right brace must be followed by a blank line at line %d\n",
|
||||
rbrace_lineno);
|
||||
}
|
||||
|
||||
/* If the right brace is followed by a pre-proceeor command
|
||||
* like #endif (but not #else or #elif), then set the right
|
||||
* brace line number to the line number of the pre-processor
|
||||
* command (it then must be followed by a blank line)
|
||||
*/
|
||||
|
||||
if (line[n] == '#')
|
||||
{
|
||||
int ii;
|
||||
|
||||
for (ii = n + 1; line[ii] != '\0' && isspace(line[ii]); ii++)
|
||||
{
|
||||
}
|
||||
|
||||
if (strncmp(&line[ii], "else", 4) != 0 &&
|
||||
strncmp(&line[ii], "elif", 4) != 0)
|
||||
{
|
||||
rbrace_lineno = lineno;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* STEP 1: Find the indentation level and the start of real stuff on
|
||||
|
@ -1023,6 +1066,8 @@ int main(int argc, char **argv, char **envp)
|
|||
"Blank line precedes right brace at line %d\n",
|
||||
lineno);
|
||||
}
|
||||
|
||||
rbrace_lineno = lineno;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue