??????????Linux??????Щ??????????????????У????????????????Linux????coding style??????????????????????????CodingStyle???????????????????д??????????????????????????????? ???????????????????????????????????????drivers/staging?μ????????????????????????????????coding style???????????????????TODO??????????”checkpatch.pl fixes”???????????????checkpatch.pl??????????????????coding style????????
????????????coding style?????????????????????顣????Microsoft??????????????????????Linus????????????(brain damaged)????????????????????Linus?????coding style??????????????????????????????????????????????????????????????????????д???????????????????????????
?????Щ????????
??????????????????????????????????coding style???????????????????????????Щ?????????á?
????scripts/checkpatch.pl
?????????????????????????????淶?????????????壬checkpatch?????????patch????????????????????????????????????????“-f”????
???????????????????????(??????print_msg.c)??
????void print_msg(int a)
????{
????switch (a) {
????case 1:
????printf("a == 1 ");
????break;
????case 2:
????printf("a == 2 ");
????break;
????}
????}
??????δ????coding style??????????????checkpatch.pl???????£?
????scripts/checkpatch.pl -f print_msg.c
?????????????
????ERROR: switch and case should be at the same indent
????#3: FILE: switch.c:3:
????+ switch (a) {
????+ case 1:
????[...]
????+ case 2:
????total: 1 errors?? 0 warnings?? 12 lines checked
????switch.c has style problems?? please review. If any of these errors
????are false positives report them to the maintainer?? see
????CHECKPATCH in MAINTAINERS.
??????Linux????coding style??switch??case????????????????????????????????????????????????????????????????????????????
????scripts/Lindent
????scripts???μ????Lindent????????????????????????????£????Lindent????????indent????????
???????????????????????Lindent??????
????scripts/Lindent print_msg.c
??????????′??????
????void print_msg(int a)
????{
????switch (a) {
????case 1:
????printf("a == 1 ");
????break;
????case 2:
????printf("a == 2 ");
????break;
????}
????}
????sed
????sed???????????????????????????????????????????????????磬Linux????coding style?????β?????п??????Tab?????????Щ?????????sed??
????????????????????????????β?????Щ?????????д???????????????????????????????е????????????????????????????Kate??????????????????????е?????????????????Tab???????????
????????????Щ??β????????????????飬??????sed?????????????????????????£?
????sed ‘s/[ ]*$//g’ your_code.c