From: Andries Brouwer <aebr@win.tue.nl>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [RFC][PATCH] 2.5 hosts.c and scsi_host list cleanup
Date: Thu, 5 Sep 2002 01:26:24 +0200 [thread overview]
Message-ID: <20020904232624.GA10227@win.tue.nl> (raw)
In-Reply-To: <20020905000158.A14644@infradead.org>
On Thu, Sep 05, 2002 at 12:01:58AM +0100, Christoph Hellwig wrote:
+ shost_name = (Scsi_Host_Name *) kmalloc(sizeof(Scsi_Host_Name),
+ GFP_KERNEL);
Cast isn't really needed again.
It is true that the cast is not needed, but it belongs to the good casts.
Usually a cast is bad because it disables checks.
In this case the cast is a good one, it enables checks.
[Indeed, a void * can be assigned to any pointer, so without the cast
gcc will only check that shost_name is a pointer. With the cast it
will check that it is a pointer of the right type.
foo = (type *) kmalloc(N*sizeof(type), ...)
is a good coding habit. Of course using sizeof(*foo) is an alternative.]
Andries
next prev parent reply other threads:[~2002-09-04 23:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-04 20:43 [RFC][PATCH] 2.5 hosts.c and scsi_host list cleanup Mike Anderson
2002-09-04 23:01 ` Christoph Hellwig
2002-09-04 23:26 ` Andries Brouwer [this message]
2002-09-05 5:45 ` Mike Anderson
2002-09-05 5:43 ` Mike Anderson
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=20020904232624.GA10227@win.tue.nl \
--to=aebr@win.tue.nl \
--cc=hch@infradead.org \
--cc=linux-scsi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox