netdev
[Top] [All Lists]

[janitor] get_stats: collapse conditionals

To: netdev@xxxxxxxxxxx
Subject: [janitor] get_stats: collapse conditionals
From: "Randy.Dunlap" <rddunlap@xxxxxxxx>
Date: Sat, 24 Jan 2004 22:19:28 -0800
Cc: davem@xxxxxxxxxx
Organization: OSDL
Sender: netdev-bounce@xxxxxxxxxxx
Hi,
Please apply to 2.6.current.

Thanks,
--
~Randy


From: Domen Puncer <domen@xxxxxxxxxxxx>



Hi.

Get rid of one comparison, improve readability.

diff -puN net/core/dev.c~netdev_get_stats net/core/dev.c


 linux-262-rc1-bk1-rddunlap/net/core/dev.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff -puN net/core/dev.c~netdev_get_stats net/core/dev.c
--- linux-262-rc1-bk1/net/core/dev.c~netdev_get_stats   2004-01-23 
15:52:33.000000000 -0800
+++ linux-262-rc1-bk1-rddunlap/net/core/dev.c   2004-01-23 15:52:33.000000000 
-0800
@@ -1940,9 +1940,9 @@ void dev_seq_stop(struct seq_file *seq, 
 
 static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
 {
-       struct net_device_stats *stats = dev->get_stats ? dev->get_stats(dev) :
-                                                         NULL;
-       if (stats)
+       if (dev->get_stats) {
+               struct net_device_stats *stats = dev->get_stats(dev);
+
                seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
                                "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
                           dev->name, stats->rx_bytes, stats->rx_packets,
@@ -1960,6 +1960,7 @@ static void dev_seq_printf_stats(struct 
                             stats->tx_window_errors +
                             stats->tx_heartbeat_errors,
                           stats->tx_compressed);
+       }
        else
                seq_printf(seq, "%6s: No statistics available.\n", dev->name);
 }

_

<Prev in Thread] Current Thread [Next in Thread>