Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 1 Jul 2020 16:44:56 -0400
From: Rich Felker <>
Cc: Valentin Ochs <>
Subject: Re: Superfluous shift in qsort()?

On Wed, Jul 01, 2020 at 08:50:26PM +0200, Markus Wichmann wrote:
> Hi all,
> I noticed something while reading code today: Near the end of qsort(),
> we have this gem:
> shl(p, 2);
> pshift -= 2;
> p[0] ^= 7;
> shr(p, 1);
> Now, I don't know if I am missing something, but don't the shl and the
> shr partially cancel out? Isn't this the same as
> shl(p, 1);
> p[0] ^= 3;
> As it is, it isn't wrong, just weird.

Assuming non-overflow, I think they're equivalent (also assuming you
keep the pshift-=2). I've CC'd the original author but we've not been
in touch for a long time so I don't know whether to expect a response.
I don't have any insight on why it was done this way.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.