Prev: Usage of checkpatch.pl for other projects
Next: perf: Move arch specific code into separate arch directory
From: David Miller on 13 Apr 2010 04:50 From: "Ian Munsie" <imunsie(a)au1.ibm.com> Date: Tue, 13 Apr 2010 18:37:33 +1000 > From: Ian Munsie <imunsie(a)au.ibm.com> > > Parsing an option from the command line with OPT_BOOLEAN on a bool data > type would not work on a big-endian machine due to the manner in which > the boolean was being cast into an int and incremented. For example, > running 'perf probe --list' on a PowerPC machine would fail to properly > set the list_events bool and would therefore print out the usage > information and terminate. > > This patch makes OPT_BOOLEAN work as expected with a bool datatype. For > cases where the original OPT_BOOLEAN was intentionally being used to > increment an int each time it was passed in on the command line, this > patch introduces OPT_INCR with the old behaviour of OPT_BOOLEAN (the > verbose variable is currently the only such example of this). > > I have reviewed every use of OPT_BOOLEAN to verify that a true C99 bool > was passed. Where integers were used, I verified that they were only > being used for boolean logic and changed them to bools to ensure that > they would not be mistakenly used as ints. The major exception was the > verbose variable which now uses OPT_INCR instead of OPT_BOOLEAN. > > Signed-off-by: Ian Munsie <imunsie(a)au.ibm.com> Thanks for finding and fixing this bug. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Ingo Molnar on 14 Apr 2010 05:30 * David Miller <davem(a)davemloft.net> wrote: > From: "Ian Munsie" <imunsie(a)au1.ibm.com> > Date: Tue, 13 Apr 2010 18:37:33 +1000 > > > From: Ian Munsie <imunsie(a)au.ibm.com> > > > > Parsing an option from the command line with OPT_BOOLEAN on a bool data > > type would not work on a big-endian machine due to the manner in which > > the boolean was being cast into an int and incremented. For example, > > running 'perf probe --list' on a PowerPC machine would fail to properly > > set the list_events bool and would therefore print out the usage > > information and terminate. > > > > This patch makes OPT_BOOLEAN work as expected with a bool datatype. For > > cases where the original OPT_BOOLEAN was intentionally being used to > > increment an int each time it was passed in on the command line, this > > patch introduces OPT_INCR with the old behaviour of OPT_BOOLEAN (the > > verbose variable is currently the only such example of this). > > > > I have reviewed every use of OPT_BOOLEAN to verify that a true C99 bool > > was passed. Where integers were used, I verified that they were only > > being used for boolean logic and changed them to bools to ensure that > > they would not be mistakenly used as ints. The major exception was the > > verbose variable which now uses OPT_INCR instead of OPT_BOOLEAN. > > > > Signed-off-by: Ian Munsie <imunsie(a)au.ibm.com> > > Thanks for finding and fixing this bug. Nice fix! Btw., perf got the option parser from the Git project - i'm wondering how the Git folks solved this endianness problem? Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Jeff King on 14 Apr 2010 06:10
On Wed, Apr 14, 2010 at 11:28:43AM +0200, Ingo Molnar wrote: > > > Parsing an option from the command line with OPT_BOOLEAN on a bool data > > > type would not work on a big-endian machine due to the manner in which > > > the boolean was being cast into an int and incremented. For example, > > > running 'perf probe --list' on a PowerPC machine would fail to properly > > > set the list_events bool and would therefore print out the usage > > > information and terminate. > [...] > > Nice fix! > > Btw., perf got the option parser from the Git project - i'm wondering how the > Git folks solved this endianness problem? We didn't. We pass only actual ints for the value field in all cases. We don't use C99 bools at all. We do use bit-fields, but the compiler catches the error, since OPT_BOOLEAN tries to take its address. -Peff -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |