From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Snitzer Subject: Re: dm: remove pointless comparison Date: Tue, 7 Jan 2014 10:52:52 -0500 Message-ID: <20140107155252.GB7983@redhat.com> References: <20140107103930.GA11734@debian> Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20140107103930.GA11734@debian> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: device-mapper development , "Alasdair G. Kergon" Cc: ejt@redhat.com, Mikulas Patocka List-Id: dm-devel.ids On Tue, Jan 07 2014 at 5:39am -0500, Joe Thornber wrote: > On Mon, Jan 06, 2014 at 10:53:28PM -0500, Mikulas Patocka wrote: > > Remove pointless comparison in dm_get_from_kobject. The comparison is > > always true and the compiler optimizes it out anyway. > > > > Signed-off-by: Mikulas Patocka > > > > --- > > drivers/md/dm.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > Index: linux-3.13-rc7/drivers/md/dm.c > > =================================================================== > > --- linux-3.13-rc7.orig/drivers/md/dm.c 2014-01-07 01:28:27.000000000 +0100 > > +++ linux-3.13-rc7/drivers/md/dm.c 2014-01-07 01:28:39.000000000 +0100 > > @@ -2922,8 +2922,6 @@ struct mapped_device *dm_get_from_kobjec > > struct mapped_device *md; > > > > md = container_of(kobj, struct mapped_device, kobj); > > - if (&md->kobj != kobj) > > - return NULL; > > What were they trying to check? The compiler? > Milan's commit 784aae735d, and the current dm.c code, offers this comment above dm_get_from_kobject: /* * struct mapped_device should not be exported outside of dm.c * so use this check to verify that kobj is part of md structure */ I'm lacking the vision to _know_ why the kobject would suddenly be outside of the mapped_device without us knowing via code change.. The check does seem overly cautious/useless (if we remove it the above comment should be removed too).