[epiphany/mcatanzaro/style: 2/2] Add code style rule regarding comparisons
- From: Jan-Michael Brummer <jbrummer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/style: 2/2] Add code style rule regarding comparisons
- Date: Wed, 2 Jan 2019 09:55:43 +0000 (UTC)
commit 040e1e4722f6d07eb1c6f0b0b508db5e00f9a02d
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Tue Jan 1 16:39:34 2019 -0600
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.
HACKING.md | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/HACKING.md b/HACKING.md
index 2ca51879c..2e287bcae 100644
--- a/HACKING.md
+++ b/HACKING.md
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]