On 01/25/2013 11:10 AM, Richard Henderson wrote:
> Checkpatch doesn't work well with the pattern
>
> #ifdef SOMETHING
> if (foo) {
> bar();
> } else
> #endif
> {
> baz1();
> baz2();
> }
>
> Which is exactly the case for all three errors reported in this series.
> I know of no other good way to arrange this pattern.
#ifdef SOMETHING
# define SOMETHING_WITNESS 1
#else
# define SOMETHING_WITNESS 0
#endif
if (foo && SOMETHING_WITNESS) {
bar();
} else {
baz1();
baz2();
}
That is, hoist your #ifdeffery earlier into the file, and then you can
avoid #ifdefs inside the function body, and thus avoid the checkpatch
complaints; plus you get the benefit of testing that the code for
SOMETHING compiles cleanly even when SOMETHING is not defined.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
