From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2EE5C4363A for ; Fri, 30 Oct 2020 13:08:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2808720731 for ; Fri, 30 Oct 2020 13:08:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="aAodBY+e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2808720731 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=codeweavers.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 274AA6EDD0; Fri, 30 Oct 2020 13:08:13 +0000 (UTC) Received: from mail.codeweavers.com (mail.codeweavers.com [50.203.203.244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52AD36EDD0 for ; Fri, 30 Oct 2020 13:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=6377696661; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+nB+YwfIqb74tTrS/a6qPqfwX4fddhIL9l2y/GzfUh4=; b=aAodBY+eEDLriaQaPJMsnxtFjB 0kmO0kJofd7yoHJqapoekfeRQU9w27WcZw+iNgvFFycRmDlHbrAxXkj3C2xKKVJ+lKeBvicFGoCN0 uTG84YM4xqWZl1N9OTWkNXGPOf/1qQKzM1iToHNT0Bpma4SABJDDKQYOI8X3c66D/gxk=; Received: from [10.69.141.123] by mail.codeweavers.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kYU8V-0005Fg-Fy; Fri, 30 Oct 2020 08:08:10 -0500 Subject: Re: [PATCH libdrm 2/2] include: Avoid potentially infinite loop in log2_int(). To: Pekka Paalanen References: <20201028100602.168752-1-pgofman@codeweavers.com> <20201028100602.168752-2-pgofman@codeweavers.com> <20201030130739.0e6770c6@eldfell> From: Paul Gofman Message-ID: <53e2c0c8-edef-ffce-d7ae-f42fd8262000@codeweavers.com> Date: Fri, 30 Oct 2020 16:07:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201030130739.0e6770c6@eldfell> Content-Language: en-GB X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 10/30/20 14:07, Pekka Paalanen wrote: > On Wed, 28 Oct 2020 13:06:02 +0300 > Paul Gofman wrote: > >> Signed-off-by: Paul Gofman >> --- >> util_math.h | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/util_math.h b/util_math.h >> index e2fa95f5..f6bbe192 100644 >> --- a/util_math.h >> +++ b/util_math.h >> @@ -38,6 +38,9 @@ static inline unsigned log2_int(unsigned x) >> if (x < 2) { >> return 0; >> } >> + if (x & 0x80000000) { >> + return 31; >> + } >> for (l =3D 2; ; l++) { >> if ((unsigned)(1 << l) > x) { >> return l - 1; > Hi, > > I guess that does it, but it seems quite a lot of code that could be > a two-liner: > http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious > > > Thanks, > pq Hello, =A0=A0=A0 thanks, I've sent the updated patches with simplified implementat= ion. Regards, =A0=A0=A0 Paul. _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel