All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k: add harmlessly-omitted braces
@ 2008-08-23  6:49 Jim Meyering
  2008-08-23 10:02 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Meyering @ 2008-08-23  6:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sujith.Manoharan, linville


---
Alternatively, you could remove the nowadays-useless
"if-before-kfree" test and leave the sometimes-redundant
assignment as-is: unconditional.

 drivers/net/wireless/ath9k/main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 2888778..21bef29 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -1056,9 +1056,10 @@ void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
 	if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
 		tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
 		/* free driver's private data area of tx_info */
-		if (tx_info->driver_data[0] != NULL)
+		if (tx_info->driver_data[0] != NULL) {
 			kfree(tx_info->driver_data[0]);
 			tx_info->driver_data[0] = NULL;
+		}
 	}

 	if (tx_status->flags & ATH_TX_BAR) {
--
1.6.0.90.g436ed

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

* Re: [PATCH] ath9k: add harmlessly-omitted braces
  2008-08-23  6:49 [PATCH] ath9k: add harmlessly-omitted braces Jim Meyering
@ 2008-08-23 10:02 ` Marcel Holtmann
  2008-08-23 10:25   ` [PATCH] ath9k: remove useless if-before-kfree; correct misleading indentation Jim Meyering
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2008-08-23 10:02 UTC (permalink / raw)
  To: Jim Meyering; +Cc: linux-kernel, Sujith.Manoharan, linville

Hi Jim

> Alternatively, you could remove the nowadays-useless
> "if-before-kfree" test and leave the sometimes-redundant
> assignment as-is: unconditional.

actually the later one is preferred. Just remove the NULL check.

Regards

Marcel



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

* [PATCH] ath9k: remove useless if-before-kfree; correct misleading indentation
  2008-08-23 10:02 ` Marcel Holtmann
@ 2008-08-23 10:25   ` Jim Meyering
  2008-08-23 11:03     ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Meyering @ 2008-08-23 10:25 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-kernel, Sujith.Manoharan, linville


---
Marcel Holtmann <holtmann@linux.intel.com> wrote:
> Hi Jim
>
>> Alternatively, you could remove the nowadays-useless
>> "if-before-kfree" test and leave the sometimes-redundant
>> assignment as-is: unconditional.
>
> actually the later one is preferred. Just remove the NULL check.

I prefer it, too, but the indentation suggested that
adding braces would match the author's intent.

In case anyone is interested, I have been maintaining a patch
that removes *all* useless if-before-kfree tests.  I have not
posted it because such changes have a reputation for provoking
flames on this list, but now you've provoked me ;-)

    http://meyering.net/code/remove-useless-if-before-kfree.patch
     74 files changed, 127 insertions(+), 250 deletions(-)

Here's the alternative patch:

 drivers/net/wireless/ath9k/main.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 2888778..6eb7ad7 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -1056,9 +1056,8 @@ void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
 	if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK ||
 		tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED) {
 		/* free driver's private data area of tx_info */
-		if (tx_info->driver_data[0] != NULL)
-			kfree(tx_info->driver_data[0]);
-			tx_info->driver_data[0] = NULL;
+		kfree(tx_info->driver_data[0]);
+		tx_info->driver_data[0] = NULL;
 	}

 	if (tx_status->flags & ATH_TX_BAR) {
-- 
1.6.0.90.g436ed


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

* Re: [PATCH] ath9k: remove useless if-before-kfree; correct misleading indentation
  2008-08-23 10:25   ` [PATCH] ath9k: remove useless if-before-kfree; correct misleading indentation Jim Meyering
@ 2008-08-23 11:03     ` Marcel Holtmann
  2008-08-23 11:28       ` Jim Meyering
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2008-08-23 11:03 UTC (permalink / raw)
  To: Jim Meyering; +Cc: linux-kernel, Sujith.Manoharan, linville

Hi Jim,

> >> Alternatively, you could remove the nowadays-useless
> >> "if-before-kfree" test and leave the sometimes-redundant
> >> assignment as-is: unconditional.
> >
> > actually the later one is preferred. Just remove the NULL check.
> 
> I prefer it, too, but the indentation suggested that
> adding braces would match the author's intent.
> 
> In case anyone is interested, I have been maintaining a patch
> that removes *all* useless if-before-kfree tests.  I have not
> posted it because such changes have a reputation for provoking
> flames on this list, but now you've provoked me ;-)
> 
>     http://meyering.net/code/remove-useless-if-before-kfree.patch
>      74 files changed, 127 insertions(+), 250 deletions(-)

I am all for this patch.

Even the Glibc free() function will do an "if-before-free" :)

Regards

Marcel



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

* Re: [PATCH] ath9k: remove useless if-before-kfree; correct misleading indentation
  2008-08-23 11:03     ` Marcel Holtmann
@ 2008-08-23 11:28       ` Jim Meyering
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Meyering @ 2008-08-23 11:28 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-kernel, Sujith.Manoharan, linville

Marcel Holtmann <holtmann@linux.intel.com> wrote:
>> >> Alternatively, you could remove the nowadays-useless
>> >> "if-before-kfree" test and leave the sometimes-redundant
>> >> assignment as-is: unconditional.
>> >
>> > actually the later one is preferred. Just remove the NULL check.
>>
>> I prefer it, too, but the indentation suggested that
>> adding braces would match the author's intent.
>>
>> In case anyone is interested, I have been maintaining a patch
>> that removes *all* useless if-before-kfree tests.  I have not
>> posted it because such changes have a reputation for provoking
>> flames on this list, but now you've provoked me ;-)
>>
>>     http://meyering.net/code/remove-useless-if-before-kfree.patch
>>      74 files changed, 127 insertions(+), 250 deletions(-)
>
> I am all for this patch.
>
> Even the Glibc free() function will do an "if-before-free" :)

Hi Marcel,

Thanks for the support.

Yes, with glibc, free(NULL) is a no-op, and POSIX has required that
behavior for long enough that *all* implementations of free on reasonable
porting targets are NULL-safe these days.  There has been plenty of
discussion as I've helped a few projects clean up in this regard, e.g.,

  http://thread.gmane.org/gmane.comp.version-control.git/74187
  http://thread.gmane.org/gmane.emacs.devel/98144
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712

Here are most of the projects that have endured this janitorial work:
    git
    emacs
    glibc
    gnulib
    coreutils
    freeIPA
    libvirt
    util-linux-ng
    idutils

There's even a tool to help ensure that no new useless if-before-kfree
tests sneak back in later.

    http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/useless-if-before-free

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

end of thread, other threads:[~2008-08-23 11:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-23  6:49 [PATCH] ath9k: add harmlessly-omitted braces Jim Meyering
2008-08-23 10:02 ` Marcel Holtmann
2008-08-23 10:25   ` [PATCH] ath9k: remove useless if-before-kfree; correct misleading indentation Jim Meyering
2008-08-23 11:03     ` Marcel Holtmann
2008-08-23 11:28       ` Jim Meyering

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.