mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] atm/nicstar: remove a bunch of pointless casts of NULL
@ 2005-05-10 20:06 Jesper Juhl
  2005-05-10 20:58 ` Alexey Dobriyan
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-05-10 20:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rui Prior, akpm

It doesn't make sense to cast NULL. This patch removes the pointless casts 
from drivers/atm/nicstar.c

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---

 drivers/atm/nicstar.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

--- linux-2.6.12-rc3-mm3-orig/drivers/atm/nicstar.c	2005-04-30 18:24:53.000000000 +0200
+++ linux-2.6.12-rc3-mm3/drivers/atm/nicstar.c	2005-05-10 22:02:29.000000000 +0200
@@ -676,10 +676,10 @@ static int __devinit ns_init_card(int i,
    PRINTK("nicstar%d: RSQ base at 0x%x.\n", i, (u32) card->rsq.base);
       
    /* Initialize SCQ0, the only VBR SCQ used */
-   card->scq1 = (scq_info *) NULL;
-   card->scq2 = (scq_info *) NULL;
+   card->scq1 = NULL;
+   card->scq2 = NULL;
    card->scq0 = get_scq(VBR_SCQSIZE, NS_VRSCD0);
-   if (card->scq0 == (scq_info *) NULL)
+   if (card->scq0 == NULL)
    {
       printk("nicstar%d: can't get SCQ0.\n", i);
       error = 12;
@@ -993,24 +993,24 @@ static scq_info *get_scq(int size, u32 s
    int i;
 
    if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
-      return (scq_info *) NULL;
+      return NULL;
 
    scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL);
-   if (scq == (scq_info *) NULL)
-      return (scq_info *) NULL;
+   if (scq == NULL)
+      return NULL;
    scq->org = kmalloc(2 * size, GFP_KERNEL);
    if (scq->org == NULL)
    {
       kfree(scq);
-      return (scq_info *) NULL;
+      return NULL;
    }
    scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) *
                                           (size / NS_SCQE_SIZE), GFP_KERNEL);
-   if (scq->skb == (struct sk_buff **) NULL)
+   if (scq->skb == NULL)
    {
       kfree(scq->org);
       kfree(scq);
-      return (scq_info *) NULL;
+      return NULL;
    }
    scq->num_entries = size / NS_SCQE_SIZE;
    scq->base = (ns_scqe *) ALIGN_ADDRESS(scq->org, size);
@@ -1498,7 +1498,7 @@ static int ns_open(struct atm_vcc *vcc)
          vc->cbr_scd = NS_FRSCD + frscdi * NS_FRSCD_SIZE;
 
          scq = get_scq(CBR_SCQSIZE, vc->cbr_scd);
-         if (scq == (scq_info *) NULL)
+         if (scq == NULL)
          {
             PRINTK("nicstar%d: can't get fixed rate SCQ.\n", card->index);
             card->scd2vc[frscdi] = NULL;




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] atm/nicstar: remove a bunch of pointless casts of NULL
  2005-05-10 20:06 [PATCH] atm/nicstar: remove a bunch of pointless casts of NULL Jesper Juhl
@ 2005-05-10 20:58 ` Alexey Dobriyan
  2005-05-10 21:02   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2005-05-10 20:58 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Rui Prior, akpm

On Wednesday 11 May 2005 00:06, Jesper Juhl wrote:
> It doesn't make sense to cast NULL. This patch removes the pointless casts 
> from drivers/atm/nicstar.c

> --- linux-2.6.12-rc3-mm3-orig/drivers/atm/nicstar.c
> +++ linux-2.6.12-rc3-mm3/drivers/atm/nicstar.c

>     scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL);
            ^^^^^^^^^^^^
> -   if (scq == (scq_info *) NULL)
> -      return (scq_info *) NULL;
> +   if (scq == NULL)
> +      return NULL;

>     scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) *
                 ^^^^^^^^^^^^^^^^^^^
>                                            (size / NS_SCQE_SIZE), GFP_KERNEL);
> -   if (scq->skb == (struct sk_buff **) NULL)
> +   if (scq->skb == NULL)

These are pointless too.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] atm/nicstar: remove a bunch of pointless casts of NULL
  2005-05-10 20:58 ` Alexey Dobriyan
@ 2005-05-10 21:02   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2005-05-10 21:02 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, Rui Prior, akpm

On Wed, 11 May 2005, Alexey Dobriyan wrote:

> On Wednesday 11 May 2005 00:06, Jesper Juhl wrote:
> > It doesn't make sense to cast NULL. This patch removes the pointless casts 
> > from drivers/atm/nicstar.c
> 
> > --- linux-2.6.12-rc3-mm3-orig/drivers/atm/nicstar.c
> > +++ linux-2.6.12-rc3-mm3/drivers/atm/nicstar.c
> 
> >     scq = (scq_info *) kmalloc(sizeof(scq_info), GFP_KERNEL);
>             ^^^^^^^^^^^^
> > -   if (scq == (scq_info *) NULL)
> > -      return (scq_info *) NULL;
> > +   if (scq == NULL)
> > +      return NULL;
> 
> >     scq->skb = (struct sk_buff **) kmalloc(sizeof(struct sk_buff *) *
>                  ^^^^^^^^^^^^^^^^^^^
> >                                            (size / NS_SCQE_SIZE), GFP_KERNEL);
> > -   if (scq->skb == (struct sk_buff **) NULL)
> > +   if (scq->skb == NULL)
> 
> These are pointless too.
> 
True, but I wanted the patch to only do a single well defined thing. I was 
not 100% sure what the reaction to such a patch would be, so I didn't want 
to mix other things in as well...  Actually, thinking about it a bit; will 
gcc ever generate different code for NULL pointers cast to different 
types? As far as I know it won't, but if it will, then the casts could 
actually make sense.

I can submit a second patch to remove the casts of kmalloc return values if 
wanted.

-- 
Jesper 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-10 21:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-10 20:06 [PATCH] atm/nicstar: remove a bunch of pointless casts of NULL Jesper Juhl
2005-05-10 20:58 ` Alexey Dobriyan
2005-05-10 21:02   ` Jesper Juhl

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®