From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751444AbdJDKLl (ORCPT ); Wed, 4 Oct 2017 06:11:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34128 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751198AbdJDKLk (ORCPT ); Wed, 4 Oct 2017 06:11:40 -0400 Date: Wed, 4 Oct 2017 12:11:48 +0200 From: Greg Kroah-Hartman To: Hans de Goede Cc: Christoph Hellwig , Arnd Bergmann , Michael Thayer , "Knut St . Osmundsen" , Larry Finger , linux-kernel@vger.kernel.org Subject: Re: [PATCH] virt: Add vboxguest driver for Virtual Box Guest integration Message-ID: <20171004101148.GA30855@kroah.com> References: <20171003092115.11341-1-hdegoede@redhat.com> <20171003092115.11341-2-hdegoede@redhat.com> <20171003100449.GA5491@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 04, 2017 at 11:32:23AM +0200, Hans de Goede wrote: > Hi, > > On 03-10-17 13:41, Hans de Goede wrote: > > > > > > > +#define CHECK_IOCTL_IN(req)                             \ > > > > +do {                                         \ > > > > +    if ((req)->Hdr.cbIn != (sizeof((req)->Hdr) + sizeof((req)->u.In)) || \ > > > > +        (req)->Hdr.cbOut != sizeof((req)->Hdr))                 \ > > > > +        return -EINVAL;                             \ > > > > +} while (0) > > > > > > Make these things functions instead of macros. > > > > Turning these into functions is a good idea I will do so for v2. > > Correction, I forgot that the passed in "req" macro > argument has a different type with all the calls, so > these cannot be changed into functions because they > rely on sizeof on the specific type to do the size > checks. Don't we already have built-in checks for these types of things? Surely we don't require each ioctl user in the kernel to do this by themselves... thanks, greg k-h