pkarashchenko commented on code in PR #6976: URL: https://github.com/apache/incubator-nuttx/pull/6976#discussion_r961117930
########## fs/vfs/fs_ioctl.c: ########## @@ -67,53 +67,52 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap) ret = inode->u.i_ops->ioctl(filep, req, arg); } - /* Check for File system IOCTL commands that can be implemented via - * fcntl() - */ - - if (ret != -ENOTTY) - { - return ret; - } - switch (req) { case FIONBIO: - { - FAR int *nonblock = (FAR int *)(uintptr_t)arg; - if (nonblock && *nonblock) - { - filep->f_oflags |= O_NONBLOCK; - } - else - { - filep->f_oflags &= ~O_NONBLOCK; - } - - ret = OK; - } + if (ret == OK || ret == -ENOTTY) + { + FAR int *nonblock = (FAR int *)(uintptr_t)arg; + if (nonblock && *nonblock) + { + filep->f_oflags |= O_NONBLOCK; + } + else + { + filep->f_oflags &= ~O_NONBLOCK; + } + + ret = OK; + } break; case FIOCLEX: - filep->f_oflags |= O_CLOEXEC; - ret = OK; + if (ret == OK || ret == -ENOTTY) + { + filep->f_oflags |= O_CLOEXEC; + ret = OK; + } break; case FIONCLEX: - filep->f_oflags &= ~O_CLOEXEC; - ret = OK; + if (ret == OK || ret == -ENOTTY) + { + filep->f_oflags &= ~O_CLOEXEC; + ret = OK; + } break; case FIOC_FILEPATH: - if (!INODE_IS_MOUNTPT(inode)) + if (ret == ENOTTY && !INODE_IS_MOUNTPT(inode)) Review Comment: ```suggestion if (ret == -ENOTTY && !INODE_IS_MOUNTPT(inode)) ``` ########## fs/vfs/fs_ioctl.c: ########## @@ -67,53 +67,52 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap) ret = inode->u.i_ops->ioctl(filep, req, arg); } - /* Check for File system IOCTL commands that can be implemented via - * fcntl() - */ - - if (ret != -ENOTTY) - { - return ret; - } - switch (req) { case FIONBIO: - { - FAR int *nonblock = (FAR int *)(uintptr_t)arg; - if (nonblock && *nonblock) - { - filep->f_oflags |= O_NONBLOCK; - } - else - { - filep->f_oflags &= ~O_NONBLOCK; - } - - ret = OK; - } + if (ret == OK || ret == -ENOTTY) Review Comment: Maybe just ``` if (ret == -ENOTTY) { ret = OK; } ``` before the `switch` and then check `if (ret == OK)` in case statements? ########## fs/vfs/fs_ioctl.c: ########## @@ -67,53 +67,52 @@ int file_vioctl(FAR struct file *filep, int req, va_list ap) ret = inode->u.i_ops->ioctl(filep, req, arg); } - /* Check for File system IOCTL commands that can be implemented via - * fcntl() - */ - - if (ret != -ENOTTY) - { - return ret; - } - switch (req) { case FIONBIO: - { - FAR int *nonblock = (FAR int *)(uintptr_t)arg; - if (nonblock && *nonblock) - { - filep->f_oflags |= O_NONBLOCK; - } - else - { - filep->f_oflags &= ~O_NONBLOCK; - } - - ret = OK; - } + if (ret == OK || ret == -ENOTTY) + { + FAR int *nonblock = (FAR int *)(uintptr_t)arg; + if (nonblock && *nonblock) + { + filep->f_oflags |= O_NONBLOCK; + } + else + { + filep->f_oflags &= ~O_NONBLOCK; + } + + ret = OK; + } break; case FIOCLEX: - filep->f_oflags |= O_CLOEXEC; - ret = OK; + if (ret == OK || ret == -ENOTTY) + { + filep->f_oflags |= O_CLOEXEC; + ret = OK; + } break; case FIONCLEX: - filep->f_oflags &= ~O_CLOEXEC; - ret = OK; + if (ret == OK || ret == -ENOTTY) + { + filep->f_oflags &= ~O_CLOEXEC; + ret = OK; + } break; case FIOC_FILEPATH: - if (!INODE_IS_MOUNTPT(inode)) + if (ret == ENOTTY && !INODE_IS_MOUNTPT(inode)) { ret = inode_getpath(inode, (FAR char *)(uintptr_t)arg); } break; #ifndef CONFIG_DISABLE_MOUNTPOINT case BIOC_BLKSSZGET: - if (inode->u.i_ops != NULL && inode->u.i_ops->ioctl != NULL) + if (ret == ENOTTY && inode->u.i_ops != NULL && Review Comment: ```suggestion if (ret == -ENOTTY && inode->u.i_ops != NULL && ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org