From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Linux kernel netdev mailing list <netdev@vger.kernel.org>
Subject: any reason for "!!netif_carrier_ok" and "!!netif_dormant" in net-sysfs.c?
Date: Mon, 27 Aug 2018 04:55:29 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.2.21.1808270448030.28019@localhost.localdomain> (raw)
another pedantic oddity -- is there a reason for these two double
negations in net/core/net-sysfs.c?
static ssize_t carrier_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
if (netif_running(netdev))
return sprintf(buf, fmt_dec, !!netif_carrier_ok(netdev));
...
static ssize_t dormant_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct net_device *netdev = to_net_dev(dev);
if (netif_running(netdev))
return sprintf(buf, fmt_dec, !!netif_dormant(netdev));
i understand the normal rationale for !! in assuring a final boolean
value of precisely either 0 or 1 (here for the sake of printing), but
given that those two routines are declared with a return value of
"bool" in netdevice.h, i don't see any way that they can return
anything *other* than 0 or 1. i realize it can't possibly hurt, but
whenever i see this construct, i normally assume there's a *reason*
for it, but i can't see what it's doing in those two places.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca/dokuwiki
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
next reply other threads:[~2018-08-27 12:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-27 8:55 Robert P. J. Day [this message]
2018-08-27 16:04 ` any reason for "!!netif_carrier_ok" and "!!netif_dormant" in net-sysfs.c? David Miller
2018-08-27 16:16 ` rpjday
2018-08-27 16:45 ` Eric Dumazet
2018-08-27 16:50 ` rpjday
2018-08-27 16:54 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.21.1808270448030.28019@localhost.localdomain \
--to=rpjday@crashcourse.ca \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox