Obfuscated code in xserver/os/io.c ?

Alan Coopersmith alan.coopersmith at oracle.com
Tue Sep 21 12:21:16 PDT 2010


Matt Turner wrote:
> On Tue, Sep 21, 2010 at 3:09 PM, Jesse Adkins <jesserayadkins at gmail.com> wrote:
>> Syntax-wise, they're the same thing. There's nothing technically wrong
>> with it, since it goes if -> if -> statement.
>>
>> The first if sees everything in the second if as a single statement,
>> so no braces are required.
>>
>> To my knowledge, this sort of construct is only a problem if there's
>> an else in there. Most compilers will apply the else to the proper
>> branch, but some won't.
>>
>> I think the second one is more readable though, and consistent with
>> the rest of the file's coding.
> 
> The thing is, the indentation is wrong, so it's unclear whether it's
> supposed to have braces or not. I think this is what he's asking
> about--someone please confirm that the code is correct as is.

It appears that came about due to the smart scheduler addition not
re-indenting the code when it added:

#ifdef SMART_SCHEDULE
     if (SmartScheduleDisable)
#endif

before the second if statement, and then no one cleaning up further
when commit 9f9268821b13 removed the #ifdef's:

-#ifdef SMART_SCHEDULE
     if (SmartScheduleDisable)
-#endif
     if (++timesThisConnection >= MAX_TIMES_PER)
        YieldControl();


-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list