mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 18:43:45 +00:00
Update CONTRIBUTING.md
This commit is contained in:
parent
80ea7427bb
commit
df6640c188
@ -30,7 +30,7 @@ try to keep the codebase consistent and clean.
|
||||
* Tabs are used for indentation. In a switch statement, the
|
||||
cases are indentend at the switch level.
|
||||
|
||||
```
|
||||
```c
|
||||
switch(n) {
|
||||
case 1:
|
||||
case 2:
|
||||
@ -45,7 +45,7 @@ default:
|
||||
or in a while of a do-while statement. Always use braces for if and while,
|
||||
except when the expressions are very simple and they can fit in a one-line.
|
||||
|
||||
```
|
||||
```c
|
||||
if (a == b) {
|
||||
...
|
||||
}
|
||||
@ -92,7 +92,7 @@ if (a == b) {
|
||||
* Use early returns instead of if-else when you need to filter out some bad
|
||||
value at the start of a function.
|
||||
|
||||
```
|
||||
```c
|
||||
int check(RCore *c, int a, int b) {
|
||||
if (!c) return R_FALSE;
|
||||
if (a < 0 || b < 1) return R_FALSE;
|
||||
@ -103,11 +103,47 @@ int check(RCore *c, int a, int b) {
|
||||
|
||||
* Use a space after most of the keyword and around operators.
|
||||
|
||||
```
|
||||
```c
|
||||
a = b + 3;
|
||||
a = (b << 3) * 5;
|
||||
```
|
||||
|
||||
* Multiline ternary operator conditionals must be indented a-la JS way:
|
||||
|
||||
```c
|
||||
- ret = over ?
|
||||
- r_debug_step_over (dbg, 1) :
|
||||
- r_debug_step (dbg, 1);
|
||||
+ ret = over
|
||||
+ ? r_debug_step_over (dbg, 1)
|
||||
+ : r_debug_step (dbg, 1);
|
||||
```
|
||||
|
||||
* Split long conditional expressions into small `static inline` functions to make them more readable:
|
||||
|
||||
```c
|
||||
+static inline bool inRange(RBreakpointItem *b, ut64 addr) {
|
||||
+ return (addr >= b->addr && addr < (b->addr + b->size));
|
||||
+}
|
||||
+
|
||||
+static inline bool matchProt(RBreakpointItem *b, int rwx) {
|
||||
+ return (!rwx || (rwx && b->rwx));
|
||||
+}
|
||||
+
|
||||
R_API RBreakpointItem *r_bp_get_in(RBreakpoint *bp, ut64 addr, int rwx) {
|
||||
RBreakpointItem *b;
|
||||
RListIter *iter;
|
||||
r_list_foreach (bp->bps, iter, b) {
|
||||
- if (addr >= b->addr && addr < (b->addr+b->size) && \
|
||||
- (!rwx || rwx&b->rwx))
|
||||
+ if (inRange (b, addr) && matchProt (b, rwx)) {
|
||||
return b;
|
||||
+ }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
```
|
||||
|
||||
* Do not leave trailing whitespaces at the end of line
|
||||
|
||||
* Do not use C99 variable declaration
|
||||
|
Loading…
Reference in New Issue
Block a user