Loading docs/CODE_STYLE.md +16 −2 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,20 @@ between the keyword and the open parenthesis. Like this: /* loop forever */ /* loop forever */ } } ## Use boolean conditions Rather than test a conditional value such as a bool against TRUE or FALSE, a pointer against NULL or != NULL and an int against zero or not zero in if/while conditions we prefer: CURLcode result = CURLE_OK; result = do_something(); if(!result) { /* something went wrong */ return result; } ## No assignments in conditions ## No assignments in conditions To increase readability and reduce complexity of conditionals, we avoid To increase readability and reduce complexity of conditionals, we avoid Loading @@ -112,7 +126,7 @@ assigning variables within if/while conditions. We frown upon this style: and instead we encourage the above version to be spelled out more clearly: and instead we encourage the above version to be spelled out more clearly: ptr = malloc(100); ptr = malloc(100); if(ptr == NULL) if(!ptr) return NULL; return NULL; ## New block on a new line ## New block on a new line Loading Loading
docs/CODE_STYLE.md +16 −2 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,20 @@ between the keyword and the open parenthesis. Like this: /* loop forever */ /* loop forever */ } } ## Use boolean conditions Rather than test a conditional value such as a bool against TRUE or FALSE, a pointer against NULL or != NULL and an int against zero or not zero in if/while conditions we prefer: CURLcode result = CURLE_OK; result = do_something(); if(!result) { /* something went wrong */ return result; } ## No assignments in conditions ## No assignments in conditions To increase readability and reduce complexity of conditionals, we avoid To increase readability and reduce complexity of conditionals, we avoid Loading @@ -112,7 +126,7 @@ assigning variables within if/while conditions. We frown upon this style: and instead we encourage the above version to be spelled out more clearly: and instead we encourage the above version to be spelled out more clearly: ptr = malloc(100); ptr = malloc(100); if(ptr == NULL) if(!ptr) return NULL; return NULL; ## New block on a new line ## New block on a new line Loading