From 1925df8faad950c02386c7f086db209071326227 Mon Sep 17 00:00:00 2001 From: Sagitta Li Date: Sat, 9 Jul 2016 06:41:39 -0600 Subject: [PATCH 1/4] Fix some recently introduced errors --- fs/smartfs/smartfs_smart.c | 2 +- fs/vfs/fs_ioctl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/smartfs/smartfs_smart.c b/fs/smartfs/smartfs_smart.c index c276eeff30..c5390d4201 100644 --- a/fs/smartfs/smartfs_smart.c +++ b/fs/smartfs/smartfs_smart.c @@ -771,7 +771,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer, if (ret < 0) { ferr("ERROR: Error %d writing sector %d data\n", - et, sf->currsector); + ret, sf->currsector); goto errout_with_semaphore; } diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index 97a5056a39..ef696a9898 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -76,7 +76,7 @@ int file_ioctl(FAR struct file *filep, int req, unsigned long arg) { FAR struct inode *inode; - int ret; + int ret = OK; /* Is a driver registered? Does it support the ioctl method? */ @@ -93,7 +93,7 @@ int file_ioctl(FAR struct file *filep, int req, unsigned long arg) } } - return OK; + return ret; } #endif /* CONFIG_NFILE_DESCRIPTORS > 0 */ From d89e062c06f790adcbec018db83442fa7b465f44 Mon Sep 17 00:00:00 2001 From: Wolfgang Reissnegger Date: Sat, 9 Jul 2016 06:50:32 -0600 Subject: [PATCH 2/4] SAM3/4 I2C: Fix reversed logic in twi_startmessage(). --- arch/arm/src/sam34/sam_twi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c index 6e4aae1427..74d0e7d6ed 100644 --- a/arch/arm/src/sam34/sam_twi.c +++ b/arch/arm/src/sam34/sam_twi.c @@ -666,7 +666,7 @@ static void twi_startwrite(struct twi_dev_s *priv, struct i2c_msg_s *msg) static void twi_startmessage(struct twi_dev_s *priv, struct i2c_msg_s *msg) { - if ((msg->flags & I2C_M_READ) == 0) + if ((msg->flags & I2C_M_READ) != 0) { twi_startread(priv, msg); } From 2689645b974ff6197ffccc3131e997aadfd46dfb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 9 Jul 2016 07:23:12 -0600 Subject: [PATCH 3/4] VFS ioctl() again. Per comments from David Sidrane, file_ioctl() should not return success if the ioctl method is not supported. It probably should return ENOTTY in that case. --- fs/vfs/fs_ioctl.c | 47 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/fs/vfs/fs_ioctl.c b/fs/vfs/fs_ioctl.c index ef696a9898..487643fb16 100644 --- a/fs/vfs/fs_ioctl.c +++ b/fs/vfs/fs_ioctl.c @@ -76,24 +76,42 @@ int file_ioctl(FAR struct file *filep, int req, unsigned long arg) { FAR struct inode *inode; - int ret = OK; + int errcode; + int ret; - /* Is a driver registered? Does it support the ioctl method? */ + DEBUGASSERT(filep != NULL); + + /* Is a driver opened? */ inode = filep->f_inode; - if (inode && inode->u.i_ops && inode->u.i_ops->ioctl) + if (!inode) { - /* Yes, then let it perform the ioctl */ + errcode = EBADF; + goto errout; + } - ret = (int)inode->u.i_ops->ioctl(filep, req, arg); - if (ret < 0) - { - set_errno(-ret); - return ERROR; - } + /* Does the driver support the ioctl method? */ + + if (inode->u.i_ops == NULL || inode->u.i_ops->ioctl == NULL) + { + errcode = ENOTTY; + goto errout; + } + + /* Yes on both accounts. Let the driver perform the ioctl command */ + + ret = (int)inode->u.i_ops->ioctl(filep, req, arg); + if (ret < 0) + { + errcode = -ret; + goto errout; } return ret; + +errout: + set_errno(errcode); + return ERROR; } #endif /* CONFIG_NFILE_DESCRIPTORS > 0 */ @@ -162,12 +180,17 @@ int ioctl(int fd, int req, unsigned long arg) filep = fs_getfilep(fd); if (!filep) { - /* The errno value has already been set */ + /* Apparently, the fd does not correspond to any open file. In the + * case of errors, the errno value has already been set by + * fs_getfilep(). + */ return ERROR; } - /* Is a driver registered? Does it support the ioctl method? */ + /* Perform the file ioctl. If file_ioctl() fails, it will set the errno + * value appropriately. + */ return file_ioctl(filep, req, arg); #else From 90917d9741660cb54a3a0903953bc6dde2eeb5e0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 9 Jul 2016 13:24:13 -0600 Subject: [PATCH 4/4] COPYING: Remove sections that do not apply to files under nuttx/ --- COPYING | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/COPYING b/COPYING index a8113ab027..2fcc3edc6a 100644 --- a/COPYING +++ b/COPYING @@ -225,44 +225,3 @@ drivers/video/ov2640 content of those tables and still retain this BSD license. I am guessing so, but I am not a copyright attorney so you should use this driver in products at your own risk. - -apps/netutils/pppd -^^^^^^^^^^^^^^^^^^ - - This implementation of PPPD has a license that is mostly compatible the - NuttX 3-clause BSD license, but includes a fourth clause that required - acknowledgement of Mike Johnson/Mycal Labs if it is built into your - product: - - Copyright (C) 2000, Mycal Labs www.mycal.com - Copyright (c) 2003, Mike Johnson, Mycal Labs, www.mycal.net - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this software - must display the following acknowledgement: - This product includes software developed by Mike Johnson/Mycal Labs - www.mycal.net. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.