From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp2120.oracle.com ([141.146.126.78]:50994 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbfKMRjc (ORCPT ); Wed, 13 Nov 2019 12:39:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2019-08-05; bh=Iu613Vdh2MXUiuuepqL+E67kQSaCecQf/FXzOTjOvCY=; b=kWh8C/P3LufZwUXAWJOU/DWAIAFR/KajwWM/vZ7HxhDaFijXPPLtvaBSG+DhVytpgrhY GKtmaPVfms+dHZHzkMiqciv9+vnU7adZYpKjltZA9TkQ6OqtrUEAyOl/oANXuKbvKu1U xChOSquPvkBEzelIQN612aDXh0I9zZz6HZRCBjWUeF3CBLKgt7l7jXo5HKC61vd6VgzK nMK5s2Ggs3fwFP7eD/8HJqVuc0FJBSDs2o4erWqAo1BEnguht6Ek523aVBnNX/tbLQK2 blbqBO7wZN/fbP3OfFtcN/I3JD8AZvgQ4Tuj8+yWs5+zGorN98gfDBWfB6tBq4ezZyTg OQ== Date: Wed, 13 Nov 2019 20:39:13 +0300 From: Dan Carpenter Subject: Re: check_signed.c false negative Message-ID: <20191112055759.GA1959@kadam.lan> References: <20191111232115.GA19963@movementarian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191111232115.GA19963@movementarian.org> Sender: smatch-owner@vger.kernel.org List-ID: To: John Levon Cc: smatch@vger.kernel.org On Mon, Nov 11, 2019 at 11:21:15PM +0000, John Levon wrote: > > Given: > > enum ib_qp_state { > IB_QPS_RESET, > IB_QPS_INIT, > IB_QPS_RTR, > IB_QPS_RTS, > IB_QPS_SQD, > IB_QPS_SQE, > IB_QPS_ERR > }; > > int p(enum ib_qp_state cur_state, enum ib_qp_state next_state) > { > #if 0 > if (cur_state < 0 || cur_state > IB_QPS_ERR || > next_state < 0 || next_state > IB_QPS_ERR) { > return (5); > } > #else > if (next_state < 0 || next_state > IB_QPS_ERR) { > return (5); > } > #endif > > return (0); > } > > current smatch is happy. But "#if 1" above instead, and: > > jlevon@sent:~/src/smatch$ ./smatch a.c > ./smatch: a.c:15 p() warn: unsigned 'cur_state' is never less than zero. > > Why is "next_state" not reported equally? My plan was that neither one would print a warning. When people do if (foo < 0 || foo > max) then normally it's not a real life bug... Linus said at kernel summit that he doesn't like when people send patches for those. The problem is that when I wrote the code to silence the warning then I hadn't created all the expr_get_parent_expr() function so I couldn't silence it properly. regards, dan carpenter