All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Joe Perches <joe@perches.com>
Cc: Fabian Frederick <fabf@skynet.be>,
	linux-kernel@vger.kernel.org,
	Evgeniy Dushistov <dushistov@mail.ru>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/1] fs/ufs/super.c: remove unnecessary casting
Date: Sun, 28 Dec 2014 18:21:58 +0000	[thread overview]
Message-ID: <20141228182158.GJ22149@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1419785144.20894.10.camel@perches.com>

On Sun, Dec 28, 2014 at 08:45:44AM -0800, Joe Perches wrote:
> On Sun, 2014-12-28 at 15:33 +0000, Al Viro wrote:
> > On Sun, Dec 28, 2014 at 04:28:29PM +0100, Fabian Frederick wrote:
> > > Fix the following coccinelle warning:
> > > fs/ufs/super.c:1418:7-28: WARNING: casting value returned by memory
> > > allocation function to (struct ufs_inode_info *) is useless.
> > 
> > ... except that it makes allocations harder to grep for.
> 
> How does it do that?

search for \<struct[ 	]*$NAME[ 	]*($|[^ 	*]|[*][ 	]*[)])
generally gives a lot of interesting information (variables of that type,
members of anything having that type, sizeof, container_of, explicit casts)
with relatively little noise.

BTW, that's why I really don't like the stuff like
	struct foo *p = kmalloc(sizeof(*p), GFP_KERNEL);
It's bloody hard to spot.

In case of UFS we still catch "sizeof(struct ufs_inode_info)" in
        ufs_inode_cachep = kmem_cache_create("ufs_inode_cache",
                                             sizeof(struct ufs_inode_info),
                                             0, (SLAB_RECLAIM_ACCOUNT|
                                                SLAB_MEM_SPREAD),
                                             init_once);
which gives the obvious secondary search pattern, so it's not _that_ terrible,
but in general it's not something to do without thinking - such a cast could
be placed there exactly to make it stand out on grep.

  reply	other threads:[~2014-12-28 18:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-28 15:28 [PATCH 1/1] fs/ufs/super.c: remove unnecessary casting Fabian Frederick
2014-12-28 15:33 ` Al Viro
2014-12-28 16:45   ` Joe Perches
2014-12-28 18:21     ` Al Viro [this message]
2014-12-31  8:46       ` Fabian Frederick
2014-12-28 16:54 ` Joe Perches

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=20141228182158.GJ22149@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=dushistov@mail.ru \
    --cc=fabf@skynet.be \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.