dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Gofman <pgofman@codeweavers.com>
To: Pekka Paalanen <ppaalanen@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH libdrm 2/2] include: Avoid potentially infinite loop in log2_int().
Date: Fri, 30 Oct 2020 16:07:59 +0300	[thread overview]
Message-ID: <53e2c0c8-edef-ffce-d7ae-f42fd8262000@codeweavers.com> (raw)
In-Reply-To: <20201030130739.0e6770c6@eldfell>

On 10/30/20 14:07, Pekka Paalanen wrote:
> On Wed, 28 Oct 2020 13:06:02 +0300
> Paul Gofman <pgofman@codeweavers.com> wrote:
>
>> Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
>> ---
>>  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 = 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,

    thanks, I've sent the updated patches with simplified implementation.

Regards,

    Paul.

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2020-10-30 13:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 10:06 [PATCH libdrm 1/2] include: Factor out log2_int() function Paul Gofman
2020-10-28 10:06 ` [PATCH libdrm 2/2] include: Avoid potentially infinite loop in log2_int() Paul Gofman
2020-10-30 11:07   ` Pekka Paalanen
2020-10-30 13:07     ` Paul Gofman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53e2c0c8-edef-ffce-d7ae-f42fd8262000@codeweavers.com \
    --to=pgofman@codeweavers.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ppaalanen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox