From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Robert P. J. Day" Subject: any reason for "!!netif_carrier_ok" and "!!netif_dormant" in net-sysfs.c? Date: Mon, 27 Aug 2018 04:55:29 -0400 (EDT) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII To: Linux kernel netdev mailing list Return-path: Received: from cpanel4.indieserve.net ([199.212.143.9]:54762 "EHLO cpanel4.indieserve.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbeH0Mnn (ORCPT ); Mon, 27 Aug 2018 08:43:43 -0400 Received: from cpef81d0f814063-cmf81d0f814060.cpe.net.cable.rogers.com ([174.114.57.56]:34444 helo=localhost.localdomain) by cpanel4.indieserve.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fuDLP-00CrvI-Uv for netdev@vger.kernel.org; Mon, 27 Aug 2018 04:57:57 -0400 Sender: netdev-owner@vger.kernel.org List-ID: 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 ========================================================================