04 Apr, 2014

22 commits

  • This test prevents code from being aligned around the : for easy visual
    counting of bitfield lengths.

    ie:
    int foo : 1,
    int bar : 2,
    int foobar :29;

    should be acceptable so remove the test.

    Signed-off-by: Joe Perches
    Suggested-by: Dan Carpenter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Currently the parenthesis alignment test works only on misalignments of
    if statements like

    if (foo(bar,
    baz)

    Expand the test to find misalignments like:

    static inline int foo(int bar,
    int baz)

    and

    foo(bar,
    baz);

    and

    foo = bar(baz,
    qux);

    Expand the $Inline keyword for __inline and __inline__ too.
    Add $Inline to $Declare so it also matches "static inline ".

    These checks are only performed with --strict.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • A commit hook for the Gerrit code review server [1] inserts change
    identifiers so Gerrit can track patches through multiple revisions.
    These identifiers are noise in the context of the upstream kernel.
    (Many Gerrit servers are private. Even given a public instance, given
    only a Change-Id, one must guess which server a change was tracked on.
    Patches submitted to the Linux kernel mailing lists should be able to
    stand on their own. If it's truly useful to reference code review on a
    Gerrit server, a URL is a much clearer way to do so.) Thus, issue an
    error when a Change-Id line is encountered before the Signed-off-by.

    1. https://gerrit.googlesource.com/gerrit/+/master/gerrit-server/src/main/resources/com/google/gerrit/server/tools/root/hooks/commit-msg

    Signed-off-by: Christopher Covington
    Cc: Joe Perches
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christopher Covington
     
  • Revert commit 7e4915e78992 ("checkpatch: add warning of future
    __GFP_NOFAIL use").

    There are no plans to remove __GFP_NOFAIL.

    __GFP_NOFAIL exists to

    a) centralise the retry-allocation-for-ever operation into the core
    allocator, which is the appropriate implementation site and

    b) permit us to identify code sites which aren't handling memory
    exhaustion appropriately.

    Cc: David Rientjes
    Cc: Joe Perches
    Cc: Theodore Ts'o
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Networking prefers this style, so warn when it's not used.

    Networking uses:

    void foo(int bar)
    {
    int baz;

    code...
    }

    not

    void foo(int bar)
    {
    int baz;
    code...
    }

    There are a limited number of false positives when using macros to
    declare variables like:

    WARNING: networking uses a blank line after declarations
    #330: FILE: net/ipv4/inet_hashtables.c:330:
    + int dif = sk->sk_bound_dev_if;
    + INET_ADDR_COOKIE(acookie, saddr, daddr)

    Signed-off-by: Joe Perches
    Cc: David Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Improve the vendor name match in vendor-prefix.txt by only matching the
    exact vendor name at the beginning of lines.

    Signed-off-by: Florian Vaussard
    Cc: Joe Perches
    Acked-by: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Florian Vaussard
     
  • Look for ".compatible = "foo" strings not only in .dts files, but
    in .c and .h too.

    Signed-off-by: Florian Vaussard
    Cc: Joe Perches
    Acked-by: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Florian Vaussard
     
  • With a compatible string like

    compatible = "foo";

    checkpatch will currently try to find "foo" in vendor-prefixes.txt,
    which is wrong since the vendor prefix is empty in this specific case.

    Skip the vendor test if the compatible is not like

    compatible = "vendor,something";

    Signed-off-by: Florian Vaussard
    Cc: Joe Perches
    Acked-by: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Florian Vaussard
     
  • The current vendor compatible check will not match vendors with dashes,
    like:

    compatible="asahi-kasei"

    Signed-off-by: Florian Vaussard
    Reported-by: Joe Perches
    Acked-by: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Florian Vaussard
     
  • The current octal permissions test is very slow.

    When patch ("checkpatch: add checks for constant non-octal permissions")
    was added, processing time approximately tripled.

    Regain almost all of the performance by not looping through all the
    possible functions unless the line contains one of the functions.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Modify warning message when printk is used in a patch. It mentions to
    use subsystem_dbg instead of netdev_dbg as the first preferred format of
    logging debug messages.

    Signed-off-by: Yogesh Chaudhari
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yogesh Chaudhari
     
  • This test is a bit noisy and opinions seem to agree that it should not
    warn in a lot more situations.

    It seems people agree that:

    return (foo || bar);
    and
    return foo || bar;

    are both acceptable style and checkpatch should be silent about them.

    For now, it warns on parentheses around a simple constant or a single
    function or a ternary.

    return (foo);
    return (foo(bar));
    return (foo ? bar : baz);

    The last ternary test may be quieted in the future.

    Modify the deparenthesize function to only strip balanced leading and
    trailing parentheses.

    Signed-off-by: Joe Perches
    Cc: Julia Lawall
    Reviewed-by: Josh Triplett
    Cc: Monam Agarwal
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • It's very common to have normal block comments for the initial comments
    of a file description preface.

    So for files in drivers/net and net/ don't emit a warning when the first
    comment block in the file uses the normal block comment style and not
    the networking block comment style.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Instead of array indexing $_, use temporary variables like all the other
    subroutines in the script use.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • static const char* arrays create smaller text as each function call does
    not have to populate the array.

    Emit a warning when char *arrays aren't static const and the array is
    not apparently global by being declared in the first column.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • checkpatch could not distinguish between a variable in a struct named
    jiffies and the normal jiffies.

    foo->jiffies

    would emit a "Comparing jiffies" arning.

    Update the $Compare variable to do a negative look-behind for "-" when
    finding a ">" so that a pointer dereference like -> isn't a comparison.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Change a test of $dstat to $line to avoid possibly emitting the sscanf
    warning multiple times.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • When checking permissions, make sure 4 octal digits are used, but allow
    a single 0 too.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Emit a warning when using any of these __constant_ forms:

    __constant_cpu_to_be[x]
    __constant_cpu_to_le[x]
    __constant_be[x]_to_cpu
    __constant_le[x]_to_cpu
    __constant_htons
    __constant_ntohs

    Using any of these outside of include/uapi/ isn't preferred as using the
    function without __constant_ is identical when the argument is a
    constant.

    Signed-off-by: Joe Perches
    Cc: Andy Whitcroft
    Cc: Simon Wunderlich
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • umode_t permissions are sometimes mistakenly written with decimal
    constants. Verify that numeric permissions are using octal.

    Add a list of the most commonly used functions and macros that have
    umode_t permissions and the argument position.

    Add a $Octal type to $Constant.
    Allow $LvalOrFunc to be a pointer indirection too.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Checks for some function pointer return styles are too strict. Fix
    them.

    Multiple spaces after function pointer return types are allowed.
    int (*foo)(int bar)

    Spaces after function pointer returns of pointer types are not required.
    int *(*foo)(int bar)

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Holger reported:

    : The macro udelay cannot handle large values because of loss-of-precision.
    :
    : IMHO udelay on ARM is broken, because it also cannot work with fast
    : ARM processors (where bogomips >= 3355, which is in sight now). It's
    : just not broken enough that someone did something against it ... so
    : the current kludge is good enough.

    Until then, warn on long udelay uses.

    Also fix uses of $line that should have been $herecurr.

    Signed-off-by: Joe Perches
    Reported-by: Holger Schurig
    Cc: Sujith Manoharan
    Cc: John Linville
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

11 Feb, 2014

1 commit

  • Since git v1.7.7, the .git directory can be a file when, for example,
    the kernel is a submodule of another git super project. So, the check
    "-d .git" is not working anymore in this case. Using a more generic
    check like "-e .git" corrects this behaviour.

    Signed-off-by: Richard Genoud
    Cc: Andy Whitcroft
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Richard Genoud
     

28 Jan, 2014

1 commit


24 Jan, 2014

12 commits

  • ether_addr_copy was added for kernel version 3.14. It's slightly
    smaller/faster for some arches. Encourage its use.

    Signed-off-by: Joe Perches
    Cc: Andy Whitcroft
    Cc: David Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • This adds a simple check that any compatible strings in DeviceTree dts
    files are present in Documentation/devicetree/bindings. Vendor prefixes
    are also checked for existing in vendor-prefixes.txt These should be
    temporary checks until we have more sophisticated binding schema
    checking.

    Signed-off-by: Rob Herring
    Signed-off-by: Joe Perches
    Cc: Grant Likely
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rob Herring
     
  • This change restricts the check for the for the FSF address in the GPL
    copyright statement so that it only flags the address, not the
    references to the gnu.org/licenses URL which appears to be used in
    numerous drivers. The idea is to still allow some reference to an
    external copy of the GPL in the event that files are copied out of the
    kernel tree without the COPYING file.

    So for example this statement will still return an error:
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

    However, this statement will not return an error after this patch:
    You should have received a copy of the GNU General Public License
    along with this program. If not, see .

    Signed-off-by: Alexander Duyck
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Duyck
     
  • Kernel style uses function pointers in this form:
    "type (*funcptr)(args...)"

    Emit warnings when this function pointer form isn't used.

    Signed-off-by: Joe Perches
    Cc: Andy Whitcroft
    Cc: Derek Perrin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • The FSF address check is a bit too verbose looking for the GPL text.
    Quiet it a bit by requiring --strict for the GPL bit.

    Also make the address tests match a few uses of abbreviations for street
    names and make it case insensitive.

    Signed-off-by: Joe Perches
    Reviewed-by: Josh Triplett
    Cc: Manfred Spraul
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • If statements don't need multiple parentheses around tested comparisons
    like "if ((foo == bar))".

    An == comparison maybe a sign of an intended assignment, so emit a
    slightly different message if so.

    Signed-off-by: Joe Perches
    Reviewed-by: Josh Triplett
    Cc: Manfred Spraul
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • This test should remove all the spaces before a tab not just one space.

    Substitute a tab for each 8 space block before a tab and remove less than
    8 spaces before a tab.

    This SPACE_BEFORE_TAB test is done after CODE_INDENT.

    If there are spaces used at the beginning of a line that should be
    converted to tabs, please make sure that the CODE_INDENT test and
    conversion is done before this SPACE_BEFORE_TAB test and conversion.

    Reported-by: Manfred Spraul
    Signed-off-by: Joe Perches
    Cc: Josh Triplett
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Add the ability to fix and overwrite existing files/patches instead of
    creating a new file ".EXPERIMENTAL-checkpatch-fixes".

    Suggested-by: Manfred Spraul
    Signed-off-by: Joe Perches
    Reviewed-by: Josh Triplett
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • switch case statements missing a break statement are an unfortunately
    common error.

    e.g.:
    commit 4a2c94c9b6c0 ("HID: kye: Add report fixup for Genius Manticore Keyboard")

    case blocks should end in a break/return/goto/continue.

    If a fall-through is used, it should have a comment showing that it is
    intentional. Ideally that comment should be something like:
    "/* fall-through */"

    Add a test to look for missing break statements.

    This looks only at the context lines before an inserted case so it's
    possible to have false positives when the context contains a close brace
    and the break is before the brace and not part of the patch context.

    Looking at recent patches, this is a pretty rare occurrence. The normal
    kernel style uses a break as the last line of the previous block.

    Signed-off-by: Joe Perches
    Cc: Andy Whitcroft
    Cc: Jiri Kosina
    Cc: Benjamin Tissoires
    Cc: Dave Jones
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • gfp.h and page_alloc.c already specify that __GFP_NOFAIL is deprecated and
    no new users should be added.

    Add a warning to checkpatch to catch this.

    Signed-off-by: David Rientjes
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     
  • The "space before a non-naked semicolon" test has unwanted output when
    used in "for ( ;; )" loops.

    Make the test work only on end-of-line statement termination semicolons.

    Signed-off-by: Joe Perches
    Cc: Dan Carpenter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • The current checkpatch test for split strings does not find several
    cases that should be found.

    For instance:

    /* Else poor success; go back to mode in "active" table */
    } else {
    IWL_DEBUG_RATE(mvm,
    - "LQ: GOING BACK TO THE OLD TABLE suc=%d cur-tpt=%d old-tpt=%d\n",
    + "GOING BACK TO THE OLD TABLE: SR %d "
    + "cur-tpt %d old-tpt %d\n",
    window->success_ratio,
    window->average_tpt,
    lq_sta->last_tpt);

    does not currently emit a warning.

    Improve the test to find these cases.

    Add more exceptions to reduce false positives for assembly and octal/hex
    string constants.

    Signed-off-by: Joe Perches
    Reviewed-by: Josh Triplett
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

14 Dec, 2013

1 commit

  • Prefer use of the direct definition of struct pci_device_id instead of
    indirection via macro DEFINE_PCI_DEVICE_TABLE.

    Update the PCI documentation to deprecate DEFINE_PCI_DEVICE_TABLE. Update
    checkpatch adding --fix option.

    Signed-off-by: Joe Perches
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Jingoo Han

    Joe Perches
     

22 Nov, 2013

1 commit

  • checkpatch is currently confused about some complex macros and references
    undefined variables $stat and $cond.

    Make sure these are defined before using them.

    Signed-off-by: Joe Perches
    Reported-by: Gerhard Sittig
    Acked-by: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

13 Nov, 2013

2 commits

  • Naked use sscanf can be troublesome because the pointed to variables may
    not have been set.

    Add a warning when the sscanf return value is not used.

    For now, do not add __must_check to the sscanf prototype because that will
    cause a couple of hundred new warnings when compiling a kernel.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Avoid prescribing kernel styled shortcuts for gcc extensions of
    __attribute__((foo)) in the uapi include paths.

    Fix $realfile filename when using -f/--file to not remove first level
    directory as if the filename was used in a -P1 patch. Only strip the
    first level directory (typically a or b) for P1 patches.

    Signed-off-by: Joe Perches
    Cc: "Dixit, Ashutosh"
    Cc: Andy Whitcroft
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches