Skip to content

Commit

Permalink
Merge pull request #7363 from singh264/openj9_issues_19261
Browse files Browse the repository at this point in the history
Update the coding standard
  • Loading branch information
babsingh authored Jun 7, 2024
2 parents a3ad1c5 + c4f7cbf commit 361c9df
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 361c9df

Please sign in to comment.