From b5e6af60ac457d306028b015f08856bed7e2c3cb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 14 Feb 2019 18:33:23 -0600 Subject: [PATCH] tools/nxstyle.c: Add check for multiple definitions of local variables on a line. --- fs/vfs/fs_open.c | 22 ++++++++++++---------- tools/nxstyle.c | 13 +++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index c28777bbf0d..f38622b4175 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -148,14 +148,14 @@ int nx_vopen(FAR const char *path, int oflags, va_list ap) #if !defined(CONFIG_DISABLE_MOUNTPOINT) && \ !defined(CONFIG_DISABLE_PSEUDOFS_OPERATIONS) - /* If the inode is block driver, then we may return a character driver - * proxy for the block driver. block_proxy() will instantiate a BCH - * character driver wrapper around the block driver, open(), then - * unlink() the character driver. On success, block_proxy() will - * return the file descriptor of the opened character driver. - * - * NOTE: This will recurse to open the character driver proxy. - */ + /* If the inode is block driver, then we may return a character driver + * proxy for the block driver. block_proxy() will instantiate a BCH + * character driver wrapper around the block driver, open(), then + * unlink() the character driver. On success, block_proxy() will + * return the file descriptor of the opened character driver. + * + * NOTE: This will recurse to open the character driver proxy. + */ if (INODE_IS_BLOCK(inode) || INODE_IS_MTD(inode)) { @@ -186,7 +186,8 @@ int nx_vopen(FAR const char *path, int oflags, va_list ap) */ #ifndef CONFIG_DISABLE_MOUNTPOINT - if ((!INODE_IS_DRIVER(inode) && !INODE_IS_MOUNTPT(inode)) || !inode->u.i_ops) + if ((!INODE_IS_DRIVER(inode) && !INODE_IS_MOUNTPT(inode)) || + !inode->u.i_ops) #else if (!INODE_IS_DRIVER(inode) || !inode->u.i_ops) #endif @@ -272,7 +273,8 @@ int nx_vopen(FAR const char *path, int oflags, va_list ap) */ fd = (int)OPEN_GETFD(ret); - DEBUGASSERT((unsigned)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)); + DEBUGASSERT((unsigned)fd < (CONFIG_NFILE_DESCRIPTORS + + CONFIG_NSOCKET_DESCRIPTORS)); } #endif diff --git a/tools/nxstyle.c b/tools/nxstyle.c index a4f1d458cf5..1359775e09f 100644 --- a/tools/nxstyle.c +++ b/tools/nxstyle.c @@ -355,6 +355,19 @@ int main(int argc, char **argv, char **envp) { declnest = 1; } + + /* Check for multiple definitions of local variables on the line. + * NOTE: Will miss multiple global variable definitions on a line, + * but this is because the heuristic is not smart enough to + * distingush a global variable from a function prototype. + */ + + if (indent > 0 && strchr(&line[indent], ',') != NULL) + { + fprintf(stderr, + "Multiple data definitions on line %d\n", + lineno); + } } /* Check for a keyword indicating the beginning of a statement.