Print this page
patch cstyle-x86

*** 21,33 **** # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # - # @(#)cstyle 1.58 98/09/09 (from shannon) - #ident "%Z%%M% %I% %E% SMI" - # # cstyle - check for some common stylistic errors. # # cstyle is a sort of "lint" for C coding style. # It attempts to check for the style used in the # kernel, sometimes known as "Bill Joy Normal Form". --- 21,30 ----
*** 482,491 **** --- 479,504 ---- # declaration. if (/\S.*\/\*/ && !/\S.*\/\*.*\*\// && !/\(\/\*/) { err("unterminated single line comment"); } + # check that #if doesn't enumerate ISA defines when there are more + # concise ways of checking. E.g., don't do: + # #if defined(__amd64) || defined(__i386) + # when there is: + # #ifdef __x86 + if (/^#if\sdefined\((.*)\)\s\|\|\sdefined\((.*)\)/) { + my $first = $1; + my $second = $2; + ($first, $second) = ($second, $first) if ($first gt $second); + + if (($first eq "__amd64") && ($second eq "__i386")) { + err("#if checking for $first or $second instead of " . + "__x86"); + } + } + if (/^(#else|#endif|#include)(.*)$/) { $prev = $line; if ($picky) { my $directive = $1; my $clause = $2;