[riot-devel] Coding-conventions: astyle

Christian Mehlis mehlis at inf.fu-berlin.de
Tue Jun 18 20:50:17 CEST 2013


Am 18.06.2013 18:54, schrieb Oleg Hahm:
> For example core/bitarithm.c
>
> The current code is:
>      r =     (v > 0xFFFF) << 4; v >>= r;
>      shift = (v > 0xFF  ) << 3; v >>= shift; r |= shift;
>      shift = (v > 0xF   ) << 2; v >>= shift; r |= shift;
>      shift = (v > 0x3   ) << 1; v >>= shift; r |= shift;
>                                              r |= (v >> 1);
>
> astyle would convert it into:
>      r = (v > 0xFFFF) << 4;
>      v >>= r;
>      shift = (v > 0xFF) << 3;
>      v >>= shift;
>      r |= shift;
>      shift = (v > 0xF) << 2;
>      v >>= shift;
>      r |= shift;
>      shift = (v > 0x3) << 1;
>      v >>= shift;
>      r |= shift;
>      r |= (v >> 1);
>
> In this case I would definitely prefer the non-cc (aka the current) version.

your example above isn't the default case, this is hand tuned bit 
operations... 99% of the code's styling is "just wrong" in terms of the 
style guide.

>> I can also create a pre commit hook to ensure this style!
> In fact, a nice idea. I'm not an expert on git commit hooks. Is it possible to
> configure these hooks in an optional manner? Or is there any way to declare
> exceptions from the coding conventions for particular pieces within the code?

ah, I don't think so, not with astyle.

>
> Anyway, I will browse through the entire suggestions of astyle and probably
> apply most of the changes to the repository.

nice, most of the changes are very useful.

>
> Cheers,
> Oleg
>



More information about the devel mailing list