• Alex Dowad's avatar
    checkpatch: make types found in a source file/patch local · 485ff23e
    Alex Dowad authored
    checkpatch uses various cues in its input patches and files to discover
    the names of user-defined types and modifiers.  It then uses that
    information when processing expressions to discover potential style
    issues.
    
    Unfortunately, in rare cases, this means that checkpatch may give
    different results if you run it on several input files in one execution,
    or one by one!
    
    The reason is that it may identify a type (or something that looks like a
    type) in one file, and then carry this information over when processing a
    different file.
    
    For example, drivers/staging/media/bcm2048/radio-bcm2048.c contains this
    line (in a macro):
    
    	size value;
    
    and drivers/staging/media/davinci_vpfe/vpfe_video.c has this line:
    
    	while (size * *nbuffers > vpfe_dev->video_limit)
    
    If checkpatch processes these 2 files in a single command like:
    	./scripts/checkpatch.pl -f $file1 $file2
    the (spurious) "size" type detected in the first file will cause it to flag
    the second file for improper use of the pointer dereference operator.
    
    To fix this, store types and modifiers found in a file in separate arrays
    from built-in ones, and reset the arrays of types and modifiers found in
    files at the beginning of each new source file.
    Signed-off-by: default avatarAlex Dowad <alexinbeijing@gmail.com>
    Signed-off-by: default avatarJoe Perches <joe@perches.com>
    Acked-by: default avatarAndy Whitcroft <apw@canonical.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    485ff23e
checkpatch.pl 161 KB