Re: arch/m68k/mac/oss.c:51: bad for loop ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Fri, 27 Mar 2015, David Binderman wrote:

Hello there,

arch/m68k/mac/oss.c:51:21: warning: iteration 16u invokes undefined 
behavior [-Waggressive-loop-optimizations]

    for (i = 0; i <= OSS_NUM_SOURCES; i++) {
        oss->irq_level[i] = 0;
    }

Maybe better code

    for (i = 0; i < OSS_NUM_SOURCES; i++) {
        oss->irq_level[i] = 0;
    }

I agree. A quick look at arch/m68k/include/asm/mac_oss.h suggests (if not 
confirms) that this is a bug. I will send a patch though I won't be able 
to test that on suitable hardware as I'm out-of-town.

It is interesting that the compiler needs -Waggressive-loop-optimizations 
in order to detect the out-of-bounds array access. I suppose the loop has 
to be unrolled before the array index is checked.

Thankyou for the static analysis!

-- 


Regards

David Binderman

[Index of Archives]     [Video for Linux]     [Yosemite News]     [Linux S/390]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux