Skip to content

Instantly share code, notes, and snippets.

@jia200x
Last active June 1, 2018 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jia200x/15c76f15789585592955e09fe469400e to your computer and use it in GitHub Desktop.
Save jia200x/15c76f15789585592955e09fe469400e to your computer and use it in GitHub Desktop.
Case 1) Unaligned |=, +=, etc.
- PINMODE1 |= BIT1; // No Pullup for CS
- FIO0DIR |= BIT16; // CS as output
- FIO0SET = BIT16; // drive cs inactive
- FIO0DIR |= BIT18 + BIT15; // SPi Output
+ PINMODE1 |= BIT1; // No Pullup for CS
+ FIO0DIR |= BIT16; // CS as output
+ FIO0SET = BIT16; // drive cs inactive
+ FIO0DIR |= BIT18 + BIT15; // SPi Output
Case 2) Wrapper spaces
-#define ADC_CONFIG {3, 4, 5, 6}
+#define ADC_CONFIG { 3, 4, 5, 6 }
Case 3) (HARDCODED :( => https://github.com/uncrustify/uncrustify/blob/2e91534fb2c125a2506f59932bd02c8fb6936d34/src/braces.cpp#L691)
- for (i = 0xFF; i > 0; i--); // Time for flag to set
+ for (i = 0xFF; i > 0; i--) { // Time for flag to set
+ }
Case 4) (This indentation...)
- uint32_t now = xtimer_now_usec();
- int sec = now / US_PER_SEC;
- int min = sec / 60;
- int hr = sec / 3600;
+ uint32_t now = xtimer_now_usec();
+ int sec = now / US_PER_SEC;
+ int min = sec / 60;
+ int hr = sec / 3600;
Case 5) And this
#define LED4_ON LED1_OFF; \
- LED2_ON; \
- LED0_ON
+ LED2_ON; \
+ LED0_ON
Case 6) C++ comments to C doesn't detect multiline comments
Plan:
1) INDENT-OFF/INDENT-ON
2) Require GH label if changes touch lines between INDENT tags
3) Check case 3) with another script? Coccinelle? (Or push fix to Uncrustify repo).
3 alt) Deal with inline /* */ comments
4) Whitelist, change component by component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment