mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Phillips <phillips@bonn-fries.net>
To: Andreas Dilger <adilger@turbolabs.com>
Cc: linux-kernel@vger.kernel.org, ext2-devel@lists.sourceforge.net,
	Arnaldo Carvalho de Melo <acme@conectiva.com.br>,
	Alexander Viro <viro@math.psu.edu>,
	Marcelo Tosatti <marcelo@conectiva.com.br>,
	Linus Torvalds <torvalds@transmeta.com>
Subject: Re: [Ext2-devel] [RFC] [PATCH] Clean up fs.h union for ext2
Date: Fri, 28 Dec 2001 02:55:09 +0100	[thread overview]
Message-ID: <E16JmEq-00007I-00@starship.berlin> (raw)
In-Reply-To: <E16JR71-0000cU-00@starship.berlin> <20011227111415.D12868@lynx.no>
In-Reply-To: <20011227111415.D12868@lynx.no>

Hi Andreas

On December 27, 2001 07:14 pm, Andreas Dilger wrote:
> On Dec 27, 2001  04:21 +0100, Daniel Phillips wrote:
> > The strategy is to abstract all references to the struct inode union through 
> > an inline function:
> > 
> > 	static inline struct ext2_inode_info *ext2_i (struct inode *inode)
> > 	{
> > 		return &(inode->u.ext2_inode_info);
> > 	}
> > 
> > There is some grist here for the mills of language lawyers here.  Note the 
> > compilation warning:
> > 
> >    ialloc.c:336: warning: passing arg 1 of `ext2_i' discards qualifiers from 
> >    pointer target type
> 
> Why not just declare ext2_i like the following?  It _should_ work:
> 
> static inline struct ext2_inode_info *ext2_i(const struct inode *inode)
> {
> 	return &(inode->u.ext2_inode_info);
> }

If that's all we do, then we get 'warning: return discards qualifiers from
pointer target type'.  Adding an explicit cast gets rid of that:

static inline struct ext2_inode_info *ext2_i (const struct inode *inode)
{
	return (struct ext2_inode_info *) &(inode->u.ext2_inode_info);
}

However, then we're lying to the compiler.  I wonder how safe that is.

> Minor nit: this is already done for the ext3 code, but it looks like:
> 
> #define EXT3_I	(&((inode)->u.ext3_i))
> 
> We already have the EXT3_SB, so I thought I would be consistent with it:
> 
> #define EXT3_SB	(&((sb)->u.ext3_sb))
> 
> Do people like the inline version better?  Either way, I would like to make
> the ext2 and ext3 codes more similar, rather than less.

An upcoming version will use an explicit cast:

	return (struct ext2_inode_info *) (inode + 1);

In other words, it doesn't rely on the union, which we're trying to get rid of.
In this case, an inline function provides type saftey and a macro wouldn't.  I
also prefer to pass the inode/sb explicitly, rather than having a macro pick it
up from context.

In the superblock patch, the inline will be 'ext2_s'.  Al seems comfortable with
this terminology, so...

--
Daniel

  reply	other threads:[~2001-12-28  1:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-27  3:21 Daniel Phillips
2001-12-27  3:28 ` Legacy Fishtank
2001-12-27  3:35   ` Arnaldo Carvalho de Melo
2001-12-27  3:52   ` Daniel Phillips
2002-01-05 14:56   ` Anton Altaparmakov
2002-01-06  3:32     ` Daniel Phillips
2002-01-07  0:30     ` Anton Altaparmakov
2002-01-07  1:27       ` Arnaldo Carvalho de Melo
2002-01-07  2:12         ` Daniel Phillips
2002-01-07  2:18           ` Arnaldo Carvalho de Melo
2002-01-07  2:22           ` Arnaldo Carvalho de Melo
2001-12-27 18:14 ` [Ext2-devel] " Andreas Dilger
2001-12-28  1:55   ` Daniel Phillips [this message]
2001-12-29 16:04   ` Oliver Xymoron
2001-12-29 21:01     ` Andreas Dilger
2001-12-29 21:30       ` Oliver Xymoron
2001-12-29 21:08     ` Andrew Morton
2002-01-02 10:26   ` Pavel Machek
2002-01-05 14:29 ` Anton Altaparmakov
2002-01-05 14:47   ` Daniel Phillips
2002-01-06  4:04   ` Anton Altaparmakov
2002-01-06 22:42     ` Daniel Phillips

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E16JmEq-00007I-00@starship.berlin \
    --to=phillips@bonn-fries.net \
    --cc=acme@conectiva.com.br \
    --cc=adilger@turbolabs.com \
    --cc=ext2-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=torvalds@transmeta.com \
    --cc=viro@math.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®