Skip to content

Commit

Permalink
Update the coding standard
Browse files Browse the repository at this point in the history
Issue: eclipse-openj9/openj9#19261
Co-authored-by: Jason Feng <fengj@ca.ibm.com>
Co-authored-by: Keith W. Campbell <keithc@ca.ibm.com>
Co-authored-by: Babneet Singh <sbabneet@ca.ibm.com>
Signed-off-by: Amarpreet Singh <Amarpreet.A.Singh@ibm.com>
  • Loading branch information
4 people committed Jun 7, 2024
1 parent a3ad1c5 commit c4f7cbf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/CodingStandard.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ if (NULL != myPointer) {
}
```

* Utilize the below format for comparisons `(<, <=, >, or >=)` of the form `(min <= value <= max)` to improve clarity.

Correct
```c
if ((0 <= logLevelValue) && (logLevelValue <= 4)) {
```
Wrong
```c
if ((logLevelValue >= 0) && (logLevelValue <= 4)) {
```

#### Rationale
* Keeping rvalues on the left can prevent accidental assignment (= vs ==).
Expand Down

0 comments on commit c4f7cbf

Please sign in to comment.