Randy Fishel wrote:
> On Thu, 19 Jun 2008, Mark Haywood wrote:
>
>   
>> Bill Holler wrote:
>>     
>>> Line 325: the comma in the condition clause looks suspicious.
>>> Should "i < obj->Package.Count, cnt > 0" instead be
>>> "i < obj->Package.Count && cnt > 0" ?
>>>       
>> BTW. Can anybody think of any reason that lint shouldn't have caught my 
>> syntax mistake here? I can't think of any reason you'd ever want to use 
>> that syntax in the conditional clause?
>>     
>
>   Possibly because a comma is valid syntax in a for statement.  
> However, the test for termination would only occur on 'cnt > 0'.
>   

Sure, but the 'i < obj->Package.Count' part of the statement, though 
evaluated, has no effect on the for loop. For example:

int
main(int argc, char **argv)
{
        int i, j;

        for (i = 0, j = 0; i < 2, j < 5; i++, j++)
                printf("i = %d and j = %d\n", i, j);

        return (0);
}

results in the following output:

i = 0 and j = 0
i = 1 and j = 1
i = 2 and j = 2
i = 3 and j = 3
i = 4 and j = 4

I understand that the syntax isn't necessarily illegal, but as far as I 
can see executing i < 2 serves no useful purpose. That seems to me, to 
be the kind of thing lint is meant to catch. lint(1) says "lint detects 
features of C program files which are likely to be bugs, non-portable, 
or wasteful." I think this falls under the definition of "wasteful" and 
is likely to be a bug.

Mark
>       ---- Randy
>
>   
>> Mark
>>
>>     
>>> Bill
>>>
>>>
>>> Mark Haywood wrote:
>>>       
>>>> Hi,
>>>>
>>>> An OpenSolaris user reported a problem with SpeedStep support on his 
>>>> laptop. His problem was that OpenSolaris was not finding the 
>>>> supported P-states. After a few email exchanges, we found that his 
>>>> _PSS table had a strangely defined set of P-states (see the attached 
>>>> stbl.dsl). There are 10 P-states returned by the _PSS, but the first 
>>>> 9 are duplicates. So, really there are only 2 uniquely defined 
>>>> P-states. The current P-state parsing code in Solaris doesn't allow 
>>>> for duplicates in the middle of the table (it does handle them at the 
>>>> end of the table since we've seen that case before). Though I 
>>>> consider this to be a questionable _PSS defintion, I think we can 
>>>> support it easy enough by ignoring consecutive duplicates altogether.
>>>>
>>>> I placed a webrev of the fix at:
>>>>
>>>> http://cr.opensolaris.org/~mhaywood/6716347/
>>>>
>>>> And  I welcome any comments.
>>>>
>>>> Thanks!
>>>> Mark
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> tesla-dev mailing list
>>>> tesla-dev at opensolaris.org
>>>> http://mail.opensolaris.org/mailman/listinfo/tesla-dev
>>>>         
>> _______________________________________________
>> tesla-dev mailing list
>> tesla-dev at opensolaris.org
>> http://mail.opensolaris.org/mailman/listinfo/tesla-dev
>>
>>     
> _______________________________________________
> tesla-dev mailing list
> tesla-dev at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/tesla-dev
>   


Reply via email to