* [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas [not found] ` <1554af80879a7ef2f78a4d654f23c248203500d9.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2007-08-24 0:03 ` Jesper Juhl [not found] ` <2ac91f5f0eed967cf1709cfbe476b351e536c299.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Jesper Juhl @ 2007-08-24 0:03 UTC (permalink / raw) To: Linux Kernel Mailing List Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-wireless-u79uwXL29TY76Z2rM5mHXA, Jesper Juhl kmalloc() and friends return void*, no need to cast it. Signed-off-by: Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- drivers/net/wireless/libertas/debugfs.c | 2 +- drivers/net/wireless/libertas/ethtool.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index 715cbda..6ade63e 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c @@ -1839,7 +1839,7 @@ static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf, char *p2; struct debug_data *d = (struct debug_data *)f->private_data; - pdata = (char *)kmalloc(cnt, GFP_KERNEL); + pdata = kmalloc(cnt, GFP_KERNEL); if (pdata == NULL) return 0; diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c index 96f1974..7dad493 100644 --- a/drivers/net/wireless/libertas/ethtool.c +++ b/drivers/net/wireless/libertas/ethtool.c @@ -60,8 +60,7 @@ static int libertas_ethtool_get_eeprom(struct net_device *dev, // mutex_lock(&priv->mutex); - adapter->prdeeprom = - (char *)kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL); + adapter->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL); if (!adapter->prdeeprom) return -ENOMEM; memcpy(adapter->prdeeprom, ®ctrl, sizeof(regctrl)); -- 1.5.2.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <2ac91f5f0eed967cf1709cfbe476b351e536c299.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas [not found] ` <2ac91f5f0eed967cf1709cfbe476b351e536c299.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2007-08-24 15:50 ` Dan Williams 0 siblings, 0 replies; 13+ messages in thread From: Dan Williams @ 2007-08-24 15:50 UTC (permalink / raw) To: Jesper Juhl Cc: Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, linux-wireless-u79uwXL29TY76Z2rM5mHXA On Fri, 2007-08-24 at 02:03 +0200, Jesper Juhl wrote: > kmalloc() and friends return void*, no need to cast it. Applied to libertas-2.6 'for-linville' branch, thanks. Dan > Signed-off-by: Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/net/wireless/libertas/debugfs.c | 2 +- > drivers/net/wireless/libertas/ethtool.c | 3 +-- > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c > index 715cbda..6ade63e 100644 > --- a/drivers/net/wireless/libertas/debugfs.c > +++ b/drivers/net/wireless/libertas/debugfs.c > @@ -1839,7 +1839,7 @@ static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf, > char *p2; > struct debug_data *d = (struct debug_data *)f->private_data; > > - pdata = (char *)kmalloc(cnt, GFP_KERNEL); > + pdata = kmalloc(cnt, GFP_KERNEL); > if (pdata == NULL) > return 0; > > diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c > index 96f1974..7dad493 100644 > --- a/drivers/net/wireless/libertas/ethtool.c > +++ b/drivers/net/wireless/libertas/ethtool.c > @@ -60,8 +60,7 @@ static int libertas_ethtool_get_eeprom(struct net_device *dev, > > // mutex_lock(&priv->mutex); > > - adapter->prdeeprom = > - (char *)kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL); > + adapter->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL); > if (!adapter->prdeeprom) > return -ENOMEM; > memcpy(adapter->prdeeprom, ®ctrl, sizeof(regctrl)); ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module [not found] <1554af80879a7ef2f78a4d654f23c248203500d9.1187912217.git.jesper.juhl@gmail.com> [not found] ` <1554af80879a7ef2f78a4d654f23c248203500d9.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2007-08-24 0:06 ` Jesper Juhl 2007-08-25 6:25 ` David Miller [not found] ` <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com> [not found] ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl@gmail.com> 3 siblings, 1 reply; 13+ messages in thread From: Jesper Juhl @ 2007-08-24 0:06 UTC (permalink / raw) To: Linux Kernel Mailing List; +Cc: netdev, davem, Jesper Juhl The general kernel memory allocation functions return void pointers and there is no need to cast their return values. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> --- drivers/net/bsd_comp.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c index 202d4a4..88edb98 100644 --- a/drivers/net/bsd_comp.c +++ b/drivers/net/bsd_comp.c @@ -406,8 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) * Allocate space for the dictionary. This may be more than one page in * length. */ - db->dict = (struct bsd_dict *) vmalloc (hsize * - sizeof (struct bsd_dict)); + db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); if (!db->dict) { bsd_free (db); @@ -426,8 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) */ else { - db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) * - sizeof (db->lens[0])); + db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); if (!db->lens) { bsd_free (db); -- 1.5.2.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module 2007-08-24 0:06 ` [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module Jesper Juhl @ 2007-08-25 6:25 ` David Miller 0 siblings, 0 replies; 13+ messages in thread From: David Miller @ 2007-08-25 6:25 UTC (permalink / raw) To: jesper.juhl; +Cc: linux-kernel, netdev From: Jesper Juhl <jesper.juhl@gmail.com> Date: Fri, 24 Aug 2007 02:06:58 +0200 > The general kernel memory allocation functions return void pointers > and there is no need to cast their return values. > > Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Applied. ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com>]
* Re: [PATCH 12/30] net: No point in casting kmalloc return values in Gianfar Ethernet Driver [not found] ` <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com> @ 2007-08-24 7:25 ` Kumar Gala 0 siblings, 0 replies; 13+ messages in thread From: Kumar Gala @ 2007-08-24 7:25 UTC (permalink / raw) To: Jesper Juhl Cc: Linux Kernel Mailing List, netdev, David S. Miller, Andy Fleming On Aug 23, 2007, at 6:59 PM, Jesper Juhl wrote: > kmalloc() returns a void ptr, so there's no need to cast its return > value in drivers/net/gianfar.c . > > Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Acked-by: Kumar Gala <galak@kernel.crashing.org> - k ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl@gmail.com>]
[parent not found: <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver [not found] ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2007-08-30 17:54 ` Daniel Drake [not found] ` <46D70467.1040109-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Daniel Drake @ 2007-08-30 17:54 UTC (permalink / raw) To: Jesper Juhl Cc: Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller, Ulrich Kunitz, linux-wireless-u79uwXL29TY76Z2rM5mHXA Jesper Juhl wrote: > Since kmalloc() returns a void pointer there is no reason to cast > its return value. > This patch also removes a pointless initialization of a variable. NAK: adds a sparse warning zd_chip.c:116:15: warning: implicit cast to nocast type > Signed-off-by: Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/net/wireless/zd1211rw/zd_chip.c | 5 ++--- > 1 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c > index c39f198..4942e5c 100644 > --- a/drivers/net/wireless/zd1211rw/zd_chip.c > +++ b/drivers/net/wireless/zd1211rw/zd_chip.c > @@ -106,8 +106,8 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr > { > int r; > int i; > - zd_addr_t *a16 = (zd_addr_t *)NULL; > u16 *v16; > + zd_addr_t *a16; > unsigned int count16; > > if (count > USB_MAX_IOREAD32_COUNT) > @@ -115,8 +115,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr > > /* Allocate a single memory block for values and addresses. */ > count16 = 2*count; > - a16 = (zd_addr_t *) kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), > - GFP_KERNEL); > + a16 = kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), GFP_KERNEL); > if (!a16) { > dev_dbg_f(zd_chip_dev(chip), > "error ENOMEM in allocation of a16\n"); ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <46D70467.1040109-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver [not found] ` <46D70467.1040109-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> @ 2007-08-30 20:20 ` Jesper Juhl [not found] ` <9a8748490708301320o49d8e794vc5c37ffc938006f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2007-08-30 23:47 ` Daniel Drake 0 siblings, 2 replies; 13+ messages in thread From: Jesper Juhl @ 2007-08-30 20:20 UTC (permalink / raw) To: Daniel Drake Cc: Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller, Ulrich Kunitz, linux-wireless-u79uwXL29TY76Z2rM5mHXA On 30/08/2007, Daniel Drake <dsd-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> wrote: > Jesper Juhl wrote: > > Since kmalloc() returns a void pointer there is no reason to cast > > its return value. > > This patch also removes a pointless initialization of a variable. > > NAK: adds a sparse warning > zd_chip.c:116:15: warning: implicit cast to nocast type > Ok, I must admit I didn't check with sparse since it seemed pointless - we usually never cast void pointers to other pointer types, specifically because the C language nicely guarantees that the right thing will happen without the cast. Sometimes we have to cast them to integer types, su sure we need the cast there. But what on earth makes a "zd_addr_t *" so special that we have to explicitly cast a "void *" to that type? I see it's defined as typedef u32 __nocast zd_addr_t; in drivers/net/wireless/zd1211rw/zd_types.h , but why the __nocast ? What would be wrong in applying my patch that removes the cast of the kmalloc() return value and then also remove the "__nocast" here? -- Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <9a8748490708301320o49d8e794vc5c37ffc938006f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver [not found] ` <9a8748490708301320o49d8e794vc5c37ffc938006f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2007-08-30 22:19 ` Joe Perches 2007-08-30 22:30 ` [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) Jesper Juhl 2007-08-31 9:30 ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Herbert Xu 1 sibling, 1 reply; 13+ messages in thread From: Joe Perches @ 2007-08-30 22:19 UTC (permalink / raw) To: Jesper Juhl Cc: Daniel Drake, Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller, Ulrich Kunitz, linux-wireless-u79uwXL29TY76Z2rM5mHXA On Thu, 2007-08-30 at 22:20 +0200, Jesper Juhl wrote: > Ok, I must admit I didn't check with sparse since it seemed pointless > - we usually never cast void pointers to other pointer types, > specifically because the C language nicely guarantees that the right > thing will happen without the cast. Sometimes we have to cast them to > integer types, su sure we need the cast there. But what on earth > makes a "zd_addr_t *" so special that we have to explicitly cast a > "void *" to that type? http://marc.info/?l=linux-netdev&m=117113743902549&w=1 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) 2007-08-30 22:19 ` Joe Perches @ 2007-08-30 22:30 ` Jesper Juhl [not found] ` <200708310030.31713.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Jesper Juhl @ 2007-08-30 22:30 UTC (permalink / raw) To: Joe Perches Cc: Daniel Drake, Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller, Ulrich Kunitz, linux-wireless-u79uwXL29TY76Z2rM5mHXA, Jesper Juhl On Friday 31 August 2007 00:19:53 Joe Perches wrote: > On Thu, 2007-08-30 at 22:20 +0200, Jesper Juhl wrote: > > Ok, I must admit I didn't check with sparse since it seemed pointless > > - we usually never cast void pointers to other pointer types, > > specifically because the C language nicely guarantees that the right > > thing will happen without the cast. Sometimes we have to cast them to > > integer types, su sure we need the cast there. But what on earth > > makes a "zd_addr_t *" so special that we have to explicitly cast a > > "void *" to that type? > > http://marc.info/?l=linux-netdev&m=117113743902549&w=1 > Thank you for that link Joe. I'm not sure I agree with the __nocast, but I respect that this is the maintainers choice. But, I still think the first chunk of the patch that removes the initial variable initialization makes sense. Initializing the variable to NULL is pointless since it'll never be used before the kmalloc() call. So here's a revised patch that just gets rid of that little detail. No need to initialize to NULL when variable is never used before it's assigned the return value of a kmalloc() call. Signed-off-by: Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index c39f198..30872fe 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c @@ -106,7 +106,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr { int r; int i; - zd_addr_t *a16 = (zd_addr_t *)NULL; + zd_addr_t *a16; u16 *v16; unsigned int count16; ^ permalink raw reply related [flat|nested] 13+ messages in thread
[parent not found: <200708310030.31713.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) [not found] ` <200708310030.31713.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2007-08-30 22:42 ` Randy Dunlap [not found] ` <20070830154255.6a146c21.randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 13+ messages in thread From: Randy Dunlap @ 2007-08-30 22:42 UTC (permalink / raw) To: Jesper Juhl Cc: Joe Perches, Daniel Drake, Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller, Ulrich Kunitz, linux-wireless-u79uwXL29TY76Z2rM5mHXA On Fri, 31 Aug 2007 00:30:31 +0200 Jesper Juhl wrote: > On Friday 31 August 2007 00:19:53 Joe Perches wrote: > > On Thu, 2007-08-30 at 22:20 +0200, Jesper Juhl wrote: > > > Ok, I must admit I didn't check with sparse since it seemed pointless > > > - we usually never cast void pointers to other pointer types, > > > specifically because the C language nicely guarantees that the right > > > thing will happen without the cast. Sometimes we have to cast them to > > > integer types, su sure we need the cast there. But what on earth > > > makes a "zd_addr_t *" so special that we have to explicitly cast a > > > "void *" to that type? > > > > http://marc.info/?l=linux-netdev&m=117113743902549&w=1 > > > > Thank you for that link Joe. > > I'm not sure I agree with the __nocast, but I respect that this is > the maintainers choice. > > But, I still think the first chunk of the patch that removes the > initial variable initialization makes sense. > Initializing the variable to NULL is pointless since it'll never be > used before the kmalloc() call. So here's a revised patch that just > gets rid of that little detail. BTW: http://marc.info/?l=linux-wireless&m=118831813500769&w=2 > No need to initialize to NULL when variable is never used before > it's assigned the return value of a kmalloc() call. > > Signed-off-by: Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > > diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c > index c39f198..30872fe 100644 > --- a/drivers/net/wireless/zd1211rw/zd_chip.c > +++ b/drivers/net/wireless/zd1211rw/zd_chip.c > @@ -106,7 +106,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr > { > int r; > int i; > - zd_addr_t *a16 = (zd_addr_t *)NULL; > + zd_addr_t *a16; > u16 *v16; > unsigned int count16; --- ~Randy *** Remember to use Documentation/SubmitChecklist when testing your code *** ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20070830154255.6a146c21.randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) [not found] ` <20070830154255.6a146c21.randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2007-08-30 23:04 ` Jesper Juhl 0 siblings, 0 replies; 13+ messages in thread From: Jesper Juhl @ 2007-08-30 23:04 UTC (permalink / raw) To: Randy Dunlap Cc: Joe Perches, Daniel Drake, Linux Kernel Mailing List, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller, Ulrich Kunitz, linux-wireless-u79uwXL29TY76Z2rM5mHXA On 31/08/2007, Randy Dunlap <randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote: ... > > BTW: http://marc.info/?l=linux-wireless&m=118831813500769&w=2 > ... Heh, thanks Randy. All too often patches get missed since I don't happen to include the right magic person to Cc. So I generally take a "better to have one Cc too many than miss one" approach when sending patches - otherwise I just end up resending it several times and eventually have to bother Andrew to move it through -mm. I see the point of people not getting things twice, but too many patches slip through the cracks already (and not just my patches, that's a general problem) so I'd rather inconvenience a few people with one extra email than missing the proper maintainer by not Cc'ing the right list. Picking the right list/set of people to Cc is hard! (whoops, mistakenly didn't do a reply-to-all initially; sorry Randy, now you'll get this mail twice ;) -- Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html Plain text mails only, please http://www.expita.com/nomime.html ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver [not found] ` <9a8748490708301320o49d8e794vc5c37ffc938006f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2007-08-30 22:19 ` Joe Perches @ 2007-08-31 9:30 ` Herbert Xu 1 sibling, 0 replies; 13+ messages in thread From: Herbert Xu @ 2007-08-31 9:30 UTC (permalink / raw) To: Jesper Juhl, Al Viro Cc: dsd-aBrp7R+bbdUdnm+yROfE0A, linux-kernel-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q, kune-hUSrv6EASfkEnNRfnnE9gw, linux-wireless-u79uwXL29TY76Z2rM5mHXA Jesper Juhl <jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > On 30/08/2007, Daniel Drake <dsd-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> wrote: >> Jesper Juhl wrote: >> > Since kmalloc() returns a void pointer there is no reason to cast >> > its return value. >> > This patch also removes a pointless initialization of a variable. >> >> NAK: adds a sparse warning >> zd_chip.c:116:15: warning: implicit cast to nocast type >> > Ok, I must admit I didn't check with sparse since it seemed pointless > - we usually never cast void pointers to other pointer types, > specifically because the C language nicely guarantees that the right > thing will happen without the cast. Sometimes we have to cast them to > integer types, su sure we need the cast there. But what on earth > makes a "zd_addr_t *" so special that we have to explicitly cast a > "void *" to that type? > > I see it's defined as > typedef u32 __nocast zd_addr_t; > in drivers/net/wireless/zd1211rw/zd_types.h , but why the __nocast ? Nevermind the __nocast, this looks like a bug in sparse. Just because a base type is __nocast, sparse shouldn't infer that a pointer to it should also be __nocast. Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} <herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver 2007-08-30 20:20 ` Jesper Juhl [not found] ` <9a8748490708301320o49d8e794vc5c37ffc938006f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2007-08-30 23:47 ` Daniel Drake 1 sibling, 0 replies; 13+ messages in thread From: Daniel Drake @ 2007-08-30 23:47 UTC (permalink / raw) To: Jesper Juhl Cc: Linux Kernel Mailing List, netdev, David S. Miller, Ulrich Kunitz, linux-wireless Jesper Juhl wrote: > What would be wrong in applying my patch that removes the cast of the > kmalloc() return value and then also remove the "__nocast" here? We use it as a safety measure when coding. For example the write register function takes an address and a value. We got one of these the wrong way round once, and had a non-obvious bug. nocast and sparse helps us prevent this. Daniel ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-08-31 9:30 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1554af80879a7ef2f78a4d654f23c248203500d9.1187912217.git.jesper.juhl@gmail.com>
[not found] ` <1554af80879a7ef2f78a4d654f23c248203500d9.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-24 0:03 ` [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas Jesper Juhl
[not found] ` <2ac91f5f0eed967cf1709cfbe476b351e536c299.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-24 15:50 ` Dan Williams
2007-08-24 0:06 ` [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module Jesper Juhl
2007-08-25 6:25 ` David Miller
[not found] ` <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com>
2007-08-24 7:25 ` [PATCH 12/30] net: No point in casting kmalloc return values in Gianfar Ethernet Driver Kumar Gala
[not found] ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl@gmail.com>
[not found] ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-30 17:54 ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Daniel Drake
[not found] ` <46D70467.1040109-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2007-08-30 20:20 ` Jesper Juhl
[not found] ` <9a8748490708301320o49d8e794vc5c37ffc938006f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-08-30 22:19 ` Joe Perches
2007-08-30 22:30 ` [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) Jesper Juhl
[not found] ` <200708310030.31713.jesper.juhl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2007-08-30 22:42 ` Randy Dunlap
[not found] ` <20070830154255.6a146c21.randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2007-08-30 23:04 ` Jesper Juhl
2007-08-31 9:30 ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Herbert Xu
2007-08-30 23:47 ` Daniel Drake
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).