Trac is being migrated to new services! Issues can be found in our new
YouTrack instance and WIKI pages can be found on our
website.
- Timestamp:
-
Feb 28, 2014, 7:31:35 AM (10 years ago)
- Author:
-
MarkDoliner
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v10
|
v11
|
|
86 | 86 | |
87 | 87 | |
88 | | == Variable Declarations == |
| 88 | == Variables == |
89 | 89 | * Prefer declaring each variable on its own line. This makes diffs easier to read and reduces churn. It also makes the code more clear when one variable is given an initial value but another is not. |
90 | 90 | * Use const for variables that don't need to change or be deallocated. |
| 91 | * Avoid assigning variables in conditions unless it leads to simpler logic, e.g.: |
| 92 | {{{ |
| 93 | #!c |
| 94 | /* Don't do this: */ |
| 95 | if ((written = write(fd, buf, len)) < len) { |
| 96 | ... |
| 97 | } |
| 98 | |
| 99 | /* Do this -- it's easier to read and leads to |
| 100 | * cleaner diffs when things change: */ |
| 101 | written = write(fd, buf, len); |
| 102 | if (written < len) { |
| 103 | ... |
| 104 | } |
| 105 | |
| 106 | /* But this if often ok, because the alternative might be unwieldy: */ |
| 107 | while (has_next = get_next()) { |
| 108 | ... |
| 109 | } |
| 110 | }}} |
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!