diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/style-guide.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/style-guide.txt b/docs/style-guide.txt index 28fb1fbfc..d1257b755 100644 --- a/docs/style-guide.txt +++ b/docs/style-guide.txt | |||
@@ -175,6 +175,23 @@ The following are simple coding guidelines that should be followed: | |||
175 | (Side Note: we might want to use a single file instead of two, food for | 175 | (Side Note: we might want to use a single file instead of two, food for |
176 | thought). | 176 | thought). |
177 | 177 | ||
178 | - There's a right way and a wrong way to test for sting equivalence with | ||
179 | strcmp: | ||
180 | |||
181 | The wrong way: | ||
182 | |||
183 | if (!strcmp(string, "foo")) { | ||
184 | ... | ||
185 | |||
186 | The right way: | ||
187 | |||
188 | if (strcmp(string, "foo") == 0){ | ||
189 | ... | ||
190 | |||
191 | The use of the "equals" (==) operator in the latter example makes it much | ||
192 | more obvious that you are testing for equivalence. The former example with | ||
193 | the "not" (!) operator makes it look like you are testing for an error. | ||
194 | |||
178 | - Do not use old-style function declarations that declare variable types | 195 | - Do not use old-style function declarations that declare variable types |
179 | between the parameter list and opening bracket. Example: | 196 | between the parameter list and opening bracket. Example: |
180 | 197 | ||