diff options
author | Amulya <Amurthyreddy@nvidia.com> | 2018-08-29 07:09:46 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-09-05 23:40:03 -0400 |
commit | cf7850ee33a5a9ffc32f584c7c3beefe286ceed2 (patch) | |
tree | eaa6af1806dd3242857d41efe427f0240d7e5310 /drivers/gpu/nvgpu/common/rbtree.c | |
parent | 2eface802a4aea417206bcdda689a65cf47d300b (diff) |
nvgpu: common: MISRA 10.1 boolean fixes
Fix violations where a variable of type non-boolean is used as a
boolean in gpu/nvgpu/common.
JIRA NVGPU-646
Change-Id: I91baa5cf1d38081161336bde5fbc06661b741273
Signed-off-by: Amulya <Amurthyreddy@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1807133
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/rbtree.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/rbtree.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/gpu/nvgpu/common/rbtree.c b/drivers/gpu/nvgpu/common/rbtree.c index a0e97ee9..33735a4f 100644 --- a/drivers/gpu/nvgpu/common/rbtree.c +++ b/drivers/gpu/nvgpu/common/rbtree.c | |||
@@ -96,7 +96,7 @@ static void insert_fixup(struct nvgpu_rbtree_node **root, | |||
96 | if (x->parent == x->parent->parent->left) { | 96 | if (x->parent == x->parent->parent->left) { |
97 | struct nvgpu_rbtree_node *y = x->parent->parent->right; | 97 | struct nvgpu_rbtree_node *y = x->parent->parent->right; |
98 | 98 | ||
99 | if (y && y->is_red) { | 99 | if ((y != NULL) && (y->is_red)) { |
100 | /* uncle is RED */ | 100 | /* uncle is RED */ |
101 | x->parent->is_red = false; | 101 | x->parent->is_red = false; |
102 | y->is_red = false; | 102 | y->is_red = false; |
@@ -119,7 +119,7 @@ static void insert_fixup(struct nvgpu_rbtree_node **root, | |||
119 | /* mirror image of above code */ | 119 | /* mirror image of above code */ |
120 | struct nvgpu_rbtree_node *y = x->parent->parent->left; | 120 | struct nvgpu_rbtree_node *y = x->parent->parent->left; |
121 | 121 | ||
122 | if (y && y->is_red) { | 122 | if ((y != NULL) && (y->is_red)) { |
123 | /* uncle is RED */ | 123 | /* uncle is RED */ |
124 | x->parent->is_red = false; | 124 | x->parent->is_red = false; |
125 | y->is_red = false; | 125 | y->is_red = false; |
@@ -189,7 +189,7 @@ static void _delete_fixup(struct nvgpu_rbtree_node **root, | |||
189 | struct nvgpu_rbtree_node *parent_of_x, | 189 | struct nvgpu_rbtree_node *parent_of_x, |
190 | struct nvgpu_rbtree_node *x) | 190 | struct nvgpu_rbtree_node *x) |
191 | { | 191 | { |
192 | while ((x != *root) && (!x || !x->is_red)) { | 192 | while ((x != *root) && ((x == NULL) || (!x->is_red))) { |
193 | /* | 193 | /* |
194 | * NULL nodes are sentinel nodes. If we delete a sentinel | 194 | * NULL nodes are sentinel nodes. If we delete a sentinel |
195 | * node (x==NULL) it must have a parent node (or be the root). | 195 | * node (x==NULL) it must have a parent node (or be the root). |
@@ -200,21 +200,21 @@ static void _delete_fixup(struct nvgpu_rbtree_node **root, | |||
200 | if ((parent_of_x != NULL) && (x == parent_of_x->left)) { | 200 | if ((parent_of_x != NULL) && (x == parent_of_x->left)) { |
201 | struct nvgpu_rbtree_node *w = parent_of_x->right; | 201 | struct nvgpu_rbtree_node *w = parent_of_x->right; |
202 | 202 | ||
203 | if (w && w->is_red) { | 203 | if ((w != NULL) && (w->is_red)) { |
204 | w->is_red = false; | 204 | w->is_red = false; |
205 | parent_of_x->is_red = true; | 205 | parent_of_x->is_red = true; |
206 | rotate_left(root, parent_of_x); | 206 | rotate_left(root, parent_of_x); |
207 | w = parent_of_x->right; | 207 | w = parent_of_x->right; |
208 | } | 208 | } |
209 | 209 | ||
210 | if (!w || ((!w->left || !w->left->is_red) | 210 | if ((w == NULL) || (((w->left == NULL) || (!w->left->is_red)) && |
211 | && (!w->right || !w->right->is_red))) { | 211 | ((w->right == NULL) || (!w->right->is_red)))) { |
212 | if (w) { | 212 | if (w != NULL) { |
213 | w->is_red = true; | 213 | w->is_red = true; |
214 | } | 214 | } |
215 | x = parent_of_x; | 215 | x = parent_of_x; |
216 | } else { | 216 | } else { |
217 | if (!w->right || !w->right->is_red) { | 217 | if ((w->right == NULL) || (!w->right->is_red)) { |
218 | w->left->is_red = false; | 218 | w->left->is_red = false; |
219 | w->is_red = true; | 219 | w->is_red = true; |
220 | rotate_right(root, w); | 220 | rotate_right(root, w); |
@@ -229,21 +229,21 @@ static void _delete_fixup(struct nvgpu_rbtree_node **root, | |||
229 | } else if (parent_of_x != NULL) { | 229 | } else if (parent_of_x != NULL) { |
230 | struct nvgpu_rbtree_node *w = parent_of_x->left; | 230 | struct nvgpu_rbtree_node *w = parent_of_x->left; |
231 | 231 | ||
232 | if (w && w->is_red) { | 232 | if ((w != NULL) && (w->is_red)) { |
233 | w->is_red = false; | 233 | w->is_red = false; |
234 | parent_of_x->is_red = true; | 234 | parent_of_x->is_red = true; |
235 | rotate_right(root, parent_of_x); | 235 | rotate_right(root, parent_of_x); |
236 | w = parent_of_x->left; | 236 | w = parent_of_x->left; |
237 | } | 237 | } |
238 | 238 | ||
239 | if (!w || ((!w->right || !w->right->is_red) | 239 | if ((w == NULL) || (((w->right == NULL) || (!w->right->is_red)) && |
240 | && (!w->left || !w->left->is_red))) { | 240 | ((w->left == NULL) || (!w->left->is_red)))) { |
241 | if (w) { | 241 | if (w != NULL) { |
242 | w->is_red = true; | 242 | w->is_red = true; |
243 | } | 243 | } |
244 | x = parent_of_x; | 244 | x = parent_of_x; |
245 | } else { | 245 | } else { |
246 | if (!w->left || !w->left->is_red) { | 246 | if ((w->left == NULL) || (!w->left->is_red)) { |
247 | w->right->is_red = false; | 247 | w->right->is_red = false; |
248 | w->is_red = true; | 248 | w->is_red = true; |
249 | rotate_left(root, w); | 249 | rotate_left(root, w); |
@@ -259,7 +259,7 @@ static void _delete_fixup(struct nvgpu_rbtree_node **root, | |||
259 | parent_of_x = x->parent; | 259 | parent_of_x = x->parent; |
260 | } | 260 | } |
261 | 261 | ||
262 | if (x) { | 262 | if (x != NULL) { |
263 | x->is_red = false; | 263 | x->is_red = false; |
264 | } | 264 | } |
265 | } | 265 | } |
@@ -276,7 +276,7 @@ void nvgpu_rbtree_unlink(struct nvgpu_rbtree_node *node, | |||
276 | z = node; | 276 | z = node; |
277 | 277 | ||
278 | /* unlink */ | 278 | /* unlink */ |
279 | if (!z->left || !z->right) { | 279 | if ((z->left == NULL) || (z->right == NULL)) { |
280 | /* y has a SENTINEL node as a child */ | 280 | /* y has a SENTINEL node as a child */ |
281 | y = z; | 281 | y = z; |
282 | } else { | 282 | } else { |
@@ -296,7 +296,7 @@ void nvgpu_rbtree_unlink(struct nvgpu_rbtree_node *node, | |||
296 | 296 | ||
297 | /* remove y from the parent chain */ | 297 | /* remove y from the parent chain */ |
298 | parent_of_x = y->parent; | 298 | parent_of_x = y->parent; |
299 | if (x) { | 299 | if (x != NULL) { |
300 | x->parent = parent_of_x; | 300 | x->parent = parent_of_x; |
301 | } | 301 | } |
302 | 302 | ||
@@ -431,7 +431,7 @@ void nvgpu_rbtree_enum_next(struct nvgpu_rbtree_node **node, | |||
431 | { | 431 | { |
432 | struct nvgpu_rbtree_node *curr = NULL; | 432 | struct nvgpu_rbtree_node *curr = NULL; |
433 | 433 | ||
434 | if (root && *node) { | 434 | if ((root != NULL) && (*node != NULL)) { |
435 | /* if we don't have a right subtree return the parent */ | 435 | /* if we don't have a right subtree return the parent */ |
436 | curr = *node; | 436 | curr = *node; |
437 | 437 | ||