Commit 040e1e47 authored by Michael Catanzaro's avatar Michael Catanzaro Committed by Jan-Michael Brummer

Add code style rule regarding comparisons

Epiphany code is currently inconsistent as to whether we should
explicitly compare pointers against NULL. Very recently, I started
writing explicit comparisons everywhere, after learning that this is now
encouraged by the GLib maintainers. However, I've started having second
thoughts. It's verbose, for one. Also, the C++ community is working on
style guidelines to discourage this:

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es87-dont-add-redundant--or--to-conditions

They make sense to me. We already have a similar rule in WebKit, except
WebKit also enforces this for integer comparisons against zero. I don't
like that. Let's follow the C++ core guidelines advise instead.
parent fca70d21
......@@ -41,6 +41,10 @@ need to stick to in order to get your patch accepted:
* There's no space between a type cast and the variable name: Right:
`(int *)foo`. Wrong: `(int*) foo`.
* Avoid explicit comparisons against TRUE, FALSE, and NULL. Right:
`if (!condition)`, `if (!pointer)`, `if (integer == 0)`. Wrong:
`if (condition == FALSE)`, `if (pointer == NULL)`, `if (!integer)`.
# Code Structure
## Layering
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment