From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH 1/3] VFS: apply coding standards to fs/ioctl.c Date: Sun, 28 Oct 2007 14:12:22 +0000 Message-ID: <20071028141222.GA29323@infradead.org> References: <11935266454097-git-send-email-ezk@cs.sunysb.edu> <11935266451616-git-send-email-ezk@cs.sunysb.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: hch@infradead.org, viro@ftp.linux.org.uk, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Erez Zadok Return-path: Received: from pentafluge.infradead.org ([213.146.154.40]:38080 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751004AbXJ1OMa (ORCPT ); Sun, 28 Oct 2007 10:12:30 -0400 Content-Disposition: inline In-Reply-To: <11935266451616-git-send-email-ezk@cs.sunysb.edu> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Nice, I always hated these double-indented switch statements. > + case FIBMAP: > + { > + struct address_space *mapping = filp->f_mapping; > + int res; > + /* do we support this mess? */ > + if (!mapping->a_ops->bmap) > + return -EINVAL; > + if (!capable(CAP_SYS_RAWIO)) > + return -EPERM; > + error = get_user(block, p); > + if (error) > + return error; > + lock_kernel(); > + res = mapping->a_ops->bmap(mapping, block); > + unlock_kernel(); > + return put_user(res, p); While you're at it, it's probably worth splitting this out into a small helper function. > + case FIONBIO: > + error = get_user(on, (int __user *)arg); > + if (error) > + break; > + flag = O_NONBLOCK; > #ifdef __sparc__ > + /* SunOS compatibility item. */ > + if (O_NONBLOCK != O_NDELAY) > + flag |= O_NDELAY; > #endif > + if (on) > + filp->f_flags |= flag; > + else > + filp->f_flags &= ~flag; > + break; Same here. > + case FIOASYNC: > + error = get_user(on, (int __user *)arg); > + if (error) > break; > + flag = on ? FASYNC : 0; > + > + /* Did FASYNC state change ? */ > + if ((flag ^ filp->f_flags) & FASYNC) { > + if (filp->f_op && filp->f_op->fasync) { > + lock_kernel(); > + error = filp->f_op->fasync(fd, filp, on); > + unlock_kernel(); > + } else > error = -ENOTTY; > + } > + if (error != 0) > break; > + > + if (on) > + filp->f_flags |= FASYNC; > + else > + filp->f_flags &= ~FASYNC; > + break; And here.