Lindent and __user, etc. - Kernel

This is a discussion on Lindent and __user, etc. - Kernel ; Indent doesn't understand macros and typedefs, so when running Lindent it makes some wrong suggestions about pointers. For example, something like "void fun(void __iomem *ptr)" comes back as "void fun(void __iomem * ptr)" from Lindent. I emailed the maintainer, and ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Lindent and __user, etc.

  1. Lindent and __user, etc.

    Indent doesn't understand macros and typedefs, so when running Lindent
    it makes some wrong suggestions about pointers. For example, something
    like "void fun(void __iomem *ptr)" comes back as "void fun(void
    __iomem * ptr)" from Lindent. I emailed the maintainer, and as indent
    doesn't do any parsing, the only solution is by telling it your
    typedefs with -T. Obviously, telling Lindent about every typedef and
    special macro in the kernel might be prohibitive, but should it at
    least know about __kernel, __user, etc. and all the u8, u16, etc.
    typedefs?

    Letting indent know about some common typenames will also help it find
    other style bugs it currently misses. I can submit more examples if
    desired, and I'll submit a patch to Lindent if people think it would
    be a good idea. Please CC me directly with replies.

    Thanks,
    J.R.
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: Lindent and __user, etc.

    Here's a patch that outlines the basic idea. Obviously more types should
    be added to catch more things that Lindent currently misses if this change seems
    beneficial.


    Make Lindent aware of sparse annotations and integer declarations

    Signed-off by: J.R. Mauro
    --

    --- Lindent 2008-10-17 18:16:56.000000000 -0400
    +++ Lindent-mod 2008-10-18 00:37:49.000000000 -0400
    @@ -1,5 +1,7 @@
    #!/bin/sh
    PARAM="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1"
    +CHECK="-T __user -T __kernel -T __safe -T __force -T __nocast -T __iomem"
    +TYPES="-T s8 -T u8 -T s16 -T u16 -T s32 -T u32 -T s64 -T u64"
    RES=`indent --version`
    V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1`
    V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2`
    @@ -15,4 +17,4 @@ elif [ $V1 -eq 2 ]; then
    fi
    fi
    fi
    -indent $PARAM "$@"
    +indent $PARAM $CHECK $TYPES "$@"
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread