From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933067AbdDEJzz (ORCPT ); Wed, 5 Apr 2017 05:55:55 -0400 Received: from mga03.intel.com ([134.134.136.65]:12030 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932343AbdDEJyj (ORCPT ); Wed, 5 Apr 2017 05:54:39 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,278,1486454400"; d="scan'208";a="1115737096" From: "Dilger, Andreas" To: Dan Carpenter CC: Pushkar Jambhlekar , "devel@driverdev.osuosl.org" , "Drokin, Oleg" , Al Viro , Greg Kroah-Hartman , LKML , Andrew Perepechko , lustre-devel Subject: Re: [lustre-devel] [PATCH] drivers/staging/lustre: Coding-guideline: Missing a blank line after declarations Thread-Topic: [lustre-devel] [PATCH] drivers/staging/lustre: Coding-guideline: Missing a blank line after declarations Thread-Index: AQHSrSQoKsLfvpiLMUaTXjfBS4YWkqG1aZoAgAGWtoA= Date: Wed, 5 Apr 2017 09:54:37 +0000 Message-ID: <83E1BF85-E9B7-44D4-96A0-2D6C41DFC6A6@intel.com> References: <1491297326-28973-1-git-send-email-pushkar.iit@gmail.com> <20170404093851.GB4521@mwanda> In-Reply-To: <20170404093851.GB4521@mwanda> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.252.139.200] Content-Type: text/plain; charset="us-ascii" Content-ID: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v359vZ0O014090 On Apr 4, 2017, at 03:38, Dan Carpenter wrote: > > On Tue, Apr 04, 2017 at 02:45:26PM +0530, Pushkar Jambhlekar wrote: >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> index cd9a40c..71fcc4c 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> @@ -482,6 +482,7 @@ void cl_page_disown0(const struct lu_env *env, >> int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io) >> { >> struct cl_io *top = cl_io_top((struct cl_io *)io); >> + >> LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj)); >> return pg->cp_state == CPS_OWNED && pg->cp_owner == top; >> } > > This is not related to the patch but I don't understand CLOBINVRNT() and > LINVRNT(). > > # define LINVRNT(exp) LASSERT(exp) > # define LINVRNT(exp) ((void)sizeof !!(exp)) > > Why do we do the sizeof() instead of just an empty define? The compiler > calculates the size at compile time and doesn't execute the expression > so it's the same as an empty define so far as I can tell. Even though sizeof() is evaluated at compile time and not runtime, it will at least evaluate the expression "exp" at compile time. This is useful to avoid "unused variable" warnings, syntax errors, etc. in that code when the more expensive LINVRNT() checking is enabled, but is disabled most of the time. With an empty expression this wouldn't happen at all, and errors may creep in. Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dilger, Andreas Date: Wed, 5 Apr 2017 09:54:37 +0000 Subject: [lustre-devel] [PATCH] drivers/staging/lustre: Coding-guideline: Missing a blank line after declarations In-Reply-To: <20170404093851.GB4521@mwanda> References: <1491297326-28973-1-git-send-email-pushkar.iit@gmail.com> <20170404093851.GB4521@mwanda> Message-ID: <83E1BF85-E9B7-44D4-96A0-2D6C41DFC6A6@intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Carpenter Cc: Pushkar Jambhlekar , "devel@driverdev.osuosl.org" , "Drokin, Oleg" , Al Viro , Greg Kroah-Hartman , LKML , Andrew Perepechko , lustre-devel On Apr 4, 2017, at 03:38, Dan Carpenter wrote: > > On Tue, Apr 04, 2017 at 02:45:26PM +0530, Pushkar Jambhlekar wrote: >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> index cd9a40c..71fcc4c 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c >> +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c >> @@ -482,6 +482,7 @@ void cl_page_disown0(const struct lu_env *env, >> int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io) >> { >> struct cl_io *top = cl_io_top((struct cl_io *)io); >> + >> LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj)); >> return pg->cp_state == CPS_OWNED && pg->cp_owner == top; >> } > > This is not related to the patch but I don't understand CLOBINVRNT() and > LINVRNT(). > > # define LINVRNT(exp) LASSERT(exp) > # define LINVRNT(exp) ((void)sizeof !!(exp)) > > Why do we do the sizeof() instead of just an empty define? The compiler > calculates the size at compile time and doesn't execute the expression > so it's the same as an empty define so far as I can tell. Even though sizeof() is evaluated at compile time and not runtime, it will at least evaluate the expression "exp" at compile time. This is useful to avoid "unused variable" warnings, syntax errors, etc. in that code when the more expensive LINVRNT() checking is enabled, but is disabled most of the time. With an empty expression this wouldn't happen at all, and errors may creep in. Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation