Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp635133pxb; Thu, 25 Feb 2021 11:00:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjQcoAVunJcbTim6SsKbGVeodU+3HUdF0OKGIY4MmSvdbRpXb20Z1jvJqyTrQn2cxdQCmB X-Received: by 2002:adf:a2d3:: with SMTP id t19mr4891280wra.299.1614279647469; Thu, 25 Feb 2021 11:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614279647; cv=none; d=google.com; s=arc-20160816; b=otbLB1GKyyWTp6aYKsKNJCDZq0P2MSjz0XufyHhLE4TQl9URlxHL7rgpZP8AOs+kMV ERxmz7hh37HopPJW87mJD9e0/Fr0GefdJ0tv1+ifUzLfHUAY7H4x+8rJjokEn9DieCw8 M5Q3iw3Lf46XpOqVRTW/mYJzw0b5jWyLtsfBK9F5ItFqqKB5JRWIJ6EH+B94Y3k8wcTe MVAUqA1GLI39EVg5ly83ara77PqABJkPRGJAH9MEB1STB3kWrSmwm9mhCqJd+iHNWSfC 1v5viv4RjlZqgYIRU0Q/M/+HGuU8qlFzlJ9kA/EhA1DlR/C3zNS1tLFakkyurKZPf0DS 2h2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Jlr0mJspKRZ4zpFrq4Z9+nbzOH2E12NSX79EmButAiQ=; b=snd8nW0By3uHTdXtnSjlOP9u8HQpIEgJBu1mgDCRU9ucAdU3StW0OuSB1x68R42599 NEPAqFZwffSEuGzi6DgvDn/CcgnJQ2ULb6nFwB6Uz1elfV2Dvrj9E9R33IgfLWsVdGwD CyldpdVdmsQMojhUtsJ7cNSTEkMfu84vjdc8+pWkbttdpVa+uW6uBugcl7PsIDLmdOqJ sEf7lGXnQ7GqzXfXwiXkEnQXNYm9ZdwN03hqsYGD2/ba+C4e5jKsPiqYWg77ZdsIdn49 Cv0WURhl7zVIiApiMYuyNpZ/LKukpLwoPodvIYLz5w2Mn02XBRUZVu9japLTNkHsjRyB jAUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=kW6vYXIB; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si3316610ejd.179.2021.02.25.11.00.21; Thu, 25 Feb 2021 11:00:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=kW6vYXIB; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232686AbhBYS7Y (ORCPT + 99 others); Thu, 25 Feb 2021 13:59:24 -0500 Received: from mx4.wp.pl ([212.77.101.11]:55576 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbhBYS7Q (ORCPT ); Thu, 25 Feb 2021 13:59:16 -0500 Received: (wp-smtpd smtp.wp.pl 5472 invoked from network); 25 Feb 2021 19:51:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1614279103; bh=Jlr0mJspKRZ4zpFrq4Z9+nbzOH2E12NSX79EmButAiQ=; h=From:To:Cc:Subject; b=kW6vYXIBFSAG+UNmM40pyfcMd0GNROJzyfDRCJZx3VjGw8H8Hnza6CRyMKf4RThtJ DV2fJPgev3NYaR6XY/p3WLY0FmUk06psLEDvnB0pEUgQbUkEdyK00fn9zVKVjZCaTX iwFioTDs7sUP1Rnpz37mK644REXZOBAC0O4b34n4= Received: from unknown (HELO kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com) (kubakici@wp.pl@[163.114.132.7]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 25 Feb 2021 19:51:42 +0100 Date: Thu, 25 Feb 2021 10:51:35 -0800 From: Jakub Kicinski To: Colin King Cc: Kalle Valo , "David S . Miller" , Matthias Brugger , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mt7601u: fix always true expression Message-ID: <20210225105135.6a2e6953@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210225183241.1002129-1-colin.king@canonical.com> References: <20210225183241.1002129-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-WP-MailID: d4752f3dadd47f61a803e18d0663a885 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000001 [0TIT] Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, 25 Feb 2021 18:32:41 +0000 Colin King wrote: > From: Colin Ian King > > Currently the expression ~nic_conf1 is always true because nic_conf1 > is a u16 and according to 6.5.3.3 of the C standard the ~ operator > promotes the u16 to an integer before flipping all the bits. Thus > the top 16 bits of the integer result are all set so the expression > is always true. If the intention was to flip all the bits of nic_conf1 > then casting the integer result back to a u16 is a suitabel fix. > > Interestingly static analyzers seem to thing a bitwise ! should be > used instead of ~ for this scenario In what way? The condition is nic_conf1 != 0xffff AFAICT, how would we do that with !? > so I think the original intent > of the expression may need some extra consideration. > > Addresses-Coverity: ("Logical vs. bitwise operator") > Fixes: c869f77d6abb ("add mt7601u driver") > Signed-off-by: Colin Ian King Acked-by: Jakub Kicinski Thanks for the fix!