* [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values
@ 2010-11-08 23:09 Jesper Juhl
2010-11-08 23:34 ` Joe Perches
2011-01-19 14:27 ` Jiri Kosina
0 siblings, 2 replies; 5+ messages in thread
From: Jesper Juhl @ 2010-11-08 23:09 UTC (permalink / raw)
To: linux-kernel
Cc: trivial, linux-scsi, osst-users, osst-users, James E.J. Bottomley,
Hannes Reinecke
Hi,
The [vk][cmz]alloc(_node) family of functions return void pointers which
it's completely unnecessary/pointless to cast to other pointer types since
that happens implicitly.
This patch removes such casts from drivers/scsi/
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
aic7xxx/aic7xxx_core.c | 2 +-
osst.c | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 3f5a542..e021b48 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -4780,7 +4780,7 @@ ahc_init_scbdata(struct ahc_softc *ahc)
SLIST_INIT(&scb_data->sg_maps);
/* Allocate SCB resources */
- scb_data->scbarray = (struct scb *)kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
+ scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
if (scb_data->scbarray == NULL)
return (ENOMEM);
memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 54de1d1..521e218 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -1484,7 +1484,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
int dbg = debugging;
#endif
- if ((buffer = (unsigned char *)vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
+ if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
return (-EIO);
printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n",
@@ -2296,7 +2296,7 @@ static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRp
if (STp->raw) return 0;
if (STp->header_cache == NULL) {
- if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
+ if ((STp->header_cache = vmalloc(sizeof(os_header_t))) == NULL) {
printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
return (-ENOMEM);
}
@@ -2484,7 +2484,7 @@ static int __osst_analyze_headers(struct osst_tape * STp, struct osst_request **
name, ppos, update_frame_cntr);
#endif
if (STp->header_cache == NULL) {
- if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
+ if ((STp->header_cache = vmalloc(sizeof(os_header_t))) == NULL) {
printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
return 0;
}
@@ -5851,9 +5851,7 @@ static int osst_probe(struct device *dev)
/* if this is the first attach, build the infrastructure */
write_lock(&os_scsi_tapes_lock);
if (os_scsi_tapes == NULL) {
- os_scsi_tapes =
- (struct osst_tape **)kmalloc(osst_max_dev * sizeof(struct osst_tape *),
- GFP_ATOMIC);
+ os_scsi_tapes = kmalloc(osst_max_dev * sizeof(struct osst_tape *), GFP_ATOMIC);
if (os_scsi_tapes == NULL) {
write_unlock(&os_scsi_tapes_lock);
printk(KERN_ERR "osst :E: Unable to allocate array for OnStream SCSI tapes.\n");
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values
2010-11-08 23:34 ` Joe Perches
@ 2010-11-08 23:30 ` Jesper Juhl
0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2010-11-08 23:30 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, trivial, linux-scsi, osst-users,
James E.J. Bottomley, Hannes Reinecke
On Mon, 8 Nov 2010, Joe Perches wrote:
> On Tue, 2010-11-09 at 00:09 +0100, Jesper Juhl wrote:
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
> []
> > @@ -4780,7 +4780,7 @@ ahc_init_scbdata(struct ahc_softc *ahc)
> > SLIST_INIT(&scb_data->sg_maps);
> >
> > /* Allocate SCB resources */
> > - scb_data->scbarray = (struct scb *)kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> > + scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> > if (scb_data->scbarray == NULL)
> > return (ENOMEM);
> > memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
>
> This would be better as:
>
> scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb), GFP_ATOMIC)
>
> without the memset.
>
True, I did notice that, and I guess I could have done that as part of
this patch series, just as there are lots of other minor improvements I
was tempted to do. But, I wanted to keep the entire patch series to a
single specific topic, then once they are merged (hopefully) I can follow
up with other cleanups.
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values
2010-11-08 23:09 [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values Jesper Juhl
@ 2010-11-08 23:34 ` Joe Perches
2010-11-08 23:30 ` Jesper Juhl
2011-01-19 14:27 ` Jiri Kosina
1 sibling, 1 reply; 5+ messages in thread
From: Joe Perches @ 2010-11-08 23:34 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-kernel, trivial, linux-scsi, osst-users,
James E.J. Bottomley, Hannes Reinecke
On Tue, 2010-11-09 at 00:09 +0100, Jesper Juhl wrote:
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
[]
> @@ -4780,7 +4780,7 @@ ahc_init_scbdata(struct ahc_softc *ahc)
> SLIST_INIT(&scb_data->sg_maps);
>
> /* Allocate SCB resources */
> - scb_data->scbarray = (struct scb *)kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> + scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> if (scb_data->scbarray == NULL)
> return (ENOMEM);
> memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
This would be better as:
scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb), GFP_ATOMIC)
without the memset.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values
2010-11-08 23:09 [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values Jesper Juhl
2010-11-08 23:34 ` Joe Perches
@ 2011-01-19 14:27 ` Jiri Kosina
2011-01-20 7:29 ` Hannes Reinecke
1 sibling, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2011-01-19 14:27 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-kernel, linux-scsi, osst-users, osst-users,
James E.J. Bottomley, Hannes Reinecke
On Tue, 9 Nov 2010, Jesper Juhl wrote:
> Hi,
>
> The [vk][cmz]alloc(_node) family of functions return void pointers which
> it's completely unnecessary/pointless to cast to other pointer types since
> that happens implicitly.
>
> This patch removes such casts from drivers/scsi/
>
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> aic7xxx/aic7xxx_core.c | 2 +-
> osst.c | 10 ++++------
> 2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
> index 3f5a542..e021b48 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_core.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
> @@ -4780,7 +4780,7 @@ ahc_init_scbdata(struct ahc_softc *ahc)
> SLIST_INIT(&scb_data->sg_maps);
>
> /* Allocate SCB resources */
> - scb_data->scbarray = (struct scb *)kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> + scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> if (scb_data->scbarray == NULL)
> return (ENOMEM);
> memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
> diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
> index 54de1d1..521e218 100644
> --- a/drivers/scsi/osst.c
> +++ b/drivers/scsi/osst.c
> @@ -1484,7 +1484,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
> int dbg = debugging;
> #endif
>
> - if ((buffer = (unsigned char *)vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
> + if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
> return (-EIO);
>
> printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n",
> @@ -2296,7 +2296,7 @@ static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRp
> if (STp->raw) return 0;
>
> if (STp->header_cache == NULL) {
> - if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
> + if ((STp->header_cache = vmalloc(sizeof(os_header_t))) == NULL) {
> printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
> return (-ENOMEM);
> }
> @@ -2484,7 +2484,7 @@ static int __osst_analyze_headers(struct osst_tape * STp, struct osst_request **
> name, ppos, update_frame_cntr);
> #endif
> if (STp->header_cache == NULL) {
> - if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
> + if ((STp->header_cache = vmalloc(sizeof(os_header_t))) == NULL) {
> printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
> return 0;
> }
> @@ -5851,9 +5851,7 @@ static int osst_probe(struct device *dev)
> /* if this is the first attach, build the infrastructure */
> write_lock(&os_scsi_tapes_lock);
> if (os_scsi_tapes == NULL) {
> - os_scsi_tapes =
> - (struct osst_tape **)kmalloc(osst_max_dev * sizeof(struct osst_tape *),
> - GFP_ATOMIC);
> + os_scsi_tapes = kmalloc(osst_max_dev * sizeof(struct osst_tape *), GFP_ATOMIC);
> if (os_scsi_tapes == NULL) {
> write_unlock(&os_scsi_tapes_lock);
> printk(KERN_ERR "osst :E: Unable to allocate array for OnStream SCSI tapes.\n");
>
Not present in linux-next as of today, taking through trivial queue.
Thanks,
--
Jiri Kosina
SUSE Labs, Novell Inc.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values
2011-01-19 14:27 ` Jiri Kosina
@ 2011-01-20 7:29 ` Hannes Reinecke
0 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2011-01-20 7:29 UTC (permalink / raw)
To: Jiri Kosina
Cc: Jesper Juhl, linux-kernel, linux-scsi, osst-users,
James E.J. Bottomley
On 01/19/2011 03:27 PM, Jiri Kosina wrote:
> On Tue, 9 Nov 2010, Jesper Juhl wrote:
>
>> Hi,
>>
>> The [vk][cmz]alloc(_node) family of functions return void pointers which
>> it's completely unnecessary/pointless to cast to other pointer types since
>> that happens implicitly.
>>
>> This patch removes such casts from drivers/scsi/
>>
>>
>> Signed-off-by: Jesper Juhl <jj@chaosbits.net>\
Acked-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-20 7:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-08 23:09 [PATCH 08/17][trivial] scsi: Remove unnecessary casts of void ptr returning alloc function return values Jesper Juhl
2010-11-08 23:34 ` Joe Perches
2010-11-08 23:30 ` Jesper Juhl
2011-01-19 14:27 ` Jiri Kosina
2011-01-20 7:29 ` Hannes Reinecke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox