Re: [PATCH] atm/nicstar: remove a bunch of pointless casts of NULL

From: Jesper Juhl
Date: Tue May 10 2005 - 16:06:03 EST


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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/