From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:25606 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233363AbhGLOBG (ORCPT ); Mon, 12 Jul 2021 10:01:06 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16CDv2eq019656 for ; Mon, 12 Jul 2021 13:58:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=corp-2020-01-29; bh=CI6LBTfyvrf48OPgtiYI+CYK/WPTgk5kKYpB2x7sOgE=; b=LzvjroStwmbHze2IcRQrTMoVdtTXO7dIL8Gw0PvEZW1lvNQA2AXzlih1c8RChE3xQFD/ vZR2RMtgFr3Ld6lfzXbMl+UWCgpW/BKWsJvC7pa4cZBYyChjMZDn+sYpeC9kvIfP7O8Y 3SSY0Q3I0esZ1iT+ZRHdBkEOE6lJz+NrP/oOsBBW/oBwoAqBMajFeX158NP4K3XCK1Vp QHvarS26PbhBsiXpqn5aaAelD4np1fIYSNYxKlWcfG1kZiDjLlMCe9vUyqRvC9sMOhT0 sK/pZqqy41J8HCdfHasmIb3TmVdLfcJlUkZeyYiVcGMh+KGgE4stJH3o1fvQqx1f7LP4 7g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39q43t2reh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 12 Jul 2021 13:58:17 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 16CDsnvs066655 for ; Mon, 12 Jul 2021 13:58:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by aserp3030.oracle.com with ESMTP id 39qycrtbba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 12 Jul 2021 13:58:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CI6LBTfyvrf48OPgtiYI+CYK/WPTgk5kKYpB2x7sOgE=; b=fkrWOIdV5THAK8qvioA5qLhJcUbzIgjmz31t0gudtGhNExc9216lkOj1oPZmWCTgqKlEBUDgPWXLcb/9XvCjfL31ZzATKfDYQkkavx8iV7mId0ubQhLAlT7OnNLCOaCgEFV2uZFkDD+eHfF9yDgVavmKXrJ8AeFUs5KOcfgcTLk= Date: Mon, 12 Jul 2021 16:57:54 +0300 From: Dan Carpenter Subject: Re: [PATCH 2/2] [PATCH 2/2] Fix handle_bit_test so that null set condition is taken care of Message-ID: <20210712135754.GI1931@kadam> References: <20210712125428.30186-1-harshvardhan.jha@oracle.com> <20210712125428.30186-2-harshvardhan.jha@oracle.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210712125428.30186-2-harshvardhan.jha@oracle.com> MIME-Version: 1.0 List-ID: To: Harshvardhan Jha Cc: smatch@vger.kernel.org On Mon, Jul 12, 2021 at 06:24:28PM +0530, Harshvardhan Jha wrote: > --- > smatch_extra.c | 17 +++++++++-------- > validation/sm_bits2.c | 28 ++++++++++++++++++++++++++++ > 2 files changed, 37 insertions(+), 8 deletions(-) > create mode 100644 validation/sm_bits2.c > > diff --git a/smatch_extra.c b/smatch_extra.c > index e864646a..27bf5a02 100644 > --- a/smatch_extra.c > +++ b/smatch_extra.c > @@ -2061,7 +2061,7 @@ static void match_comparison(struct expression *expr) > > static bool handle_bit_test(struct expression *expr) > { > - struct range_list *orig_rl, *rl; > + struct range_list *orig_rl, *rl, *true_rl, *false_rl; > struct expression *shift, *mask, *var; > struct bit_info *bit_info; > sval_t sval; > @@ -2083,23 +2083,24 @@ static bool handle_bit_test(struct expression *expr) > bit_info = get_bit_info(mask); > if (!bit_info) > return false; > - if (!bit_info->possible) > + if (!bit_info->possible){ > + set_true_false_states_expr(my_id, var, alloc_estate_empty(), NULL); > return false; > + } > > get_absolute_rl(var, &orig_rl); > if (sval_is_negative(rl_min(orig_rl)) || > rl_max(orig_rl).uvalue > type_bits(get_type(shift->left))) > return false; > > - low.value = ffsll(bit_info->possible); > - high.value = sm_fls64(bit_info->possible); > + low.value = ffsll(bit_info->possible) - 1; > + high.value = sm_fls64(bit_info->possible) - 1; > rl = alloc_rl(low, high); > rl = cast_rl(get_type(var), rl); > - rl = rl_intersection(orig_rl, rl); > - if (!rl) > - return false; > + true_rl = rl_intersection(orig_rl, rl); > + false_rl = rl_filter(orig_rl, rl); The false_rl isn't correct. For the false_side we should use bit_info->set instead of bit_info->possible. It doesn't matter in the test code because the value of mask is known so the possibly set and the definitely set are the same. In other words there can be some overlap between the potential values on the true path and the false path. regards, dan carpenter