projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
shell: remove ${#+} tests, it is not a valid construct
[oweals/busybox.git]
/
docs
/
style-guide.txt
diff --git
a/docs/style-guide.txt
b/docs/style-guide.txt
index 5bb3441cdf6c012ae79c02dbc9004271177ee693..9eed7f125156d67e14f2fce405129a706d5a1a1a 100644
(file)
--- a/
docs/style-guide.txt
+++ b/
docs/style-guide.txt
@@
-252,7
+252,7
@@
because it looks like whitespace; using lower-case is easy on the eyes.
Exceptions:
- Enums, macros, and constant variables are occasionally written in all
Exceptions:
- Enums, macros, and constant variables are occasionally written in all
- upper-case with words optionally sep
eratedy
by underscores (i.e. FIFO_TYPE,
+ upper-case with words optionally sep
arated
by underscores (i.e. FIFO_TYPE,
ISBLKDEV()).
- Nobody is going to get mad at you for using 'pvar' as the name of a
ISBLKDEV()).
- Nobody is going to get mad at you for using 'pvar' as the name of a
@@
-329,7
+329,7
@@
With "const int" compiler may fail to optimize it out and will reserve
a real storage in rodata for it! (Hopefully, newer gcc will get better
at it...). With "define", you have slight risk of polluting namespace
(#define doesn't allow you to redefine the name in the inner scopes),
a real storage in rodata for it! (Hopefully, newer gcc will get better
at it...). With "define", you have slight risk of polluting namespace
(#define doesn't allow you to redefine the name in the inner scopes),
-and complex "define" are evaluated each time they u
es
d, not once
+and complex "define" are evaluated each time they u
se
d, not once
at declarations like enums. Also, the preprocessor does _no_ type checking
whatsoever, making it much more error prone.
at declarations like enums. Also, the preprocessor does _no_ type checking
whatsoever, making it much more error prone.
@@
-377,13
+377,13
@@
used in the code.
(in .h header file)
(in .h header file)
- #if
def CONFIG
_FEATURE_FUNKY
- static inline void maybe_do_funky_stuff
(int bar, int baz)
+ #if
ENABLE
_FEATURE_FUNKY
+ static inline void maybe_do_funky_stuff(int bar, int baz)
{
/* lotsa code in here */
}
#else
{
/* lotsa code in here */
}
#else
- static inline void maybe_do_funky_stuff
(int bar, int baz) {}
+ static inline void maybe_do_funky_stuff(int bar, int baz) {}
#endif
(in the .c source file)
#endif
(in the .c source file)
@@
-422,7
+422,7
@@
called 'strings.c' - instead of two, food for thought).
Testing String Equivalence
~~~~~~~~~~~~~~~~~~~~~~~~~~
Testing String Equivalence
~~~~~~~~~~~~~~~~~~~~~~~~~~
-There's a right way and a wrong way to test for sting equivalence with
+There's a right way and a wrong way to test for st
r
ing equivalence with
strcmp():
The wrong way:
strcmp():
The wrong way:
@@
-679,11
+679,10
@@
line in the midst of your #includes, if you need to parse long options:
Then have long options defined:
Then have long options defined:
- static const struct option <applet>_long_options[] = {
- { "list", 0, NULL, 't' },
- { "extract", 0, NULL, 'x' },
- { NULL }
- };
+ static const char <applet>_longopts[] ALIGN1 =
+ "list\0" No_argument "t"
+ "extract\0" No_argument "x"
+ ;
And a code block similar to the following near the top of your applet_main()
routine:
And a code block similar to the following near the top of your applet_main()
routine:
@@
-691,7
+690,7
@@
routine:
char *str_b;
opt_complementary = "cryptic_string";
char *str_b;
opt_complementary = "cryptic_string";
- applet_long_options = <applet>_long
_option
s; /* if you have them */
+ applet_long_options = <applet>_long
opt
s; /* if you have them */
opt = getopt32(argc, argv, "ab:c", &str_b);
if (opt & 1) {
handle_option_a();
opt = getopt32(argc, argv, "ab:c", &str_b);
if (opt & 1) {
handle_option_a();