mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 18:16:01 +03:00
Address MISRA Rule 20.7 violation: Macro parameter expands into an expression without being wrapped by parentheses. Some of the exception the coverity is not able to catch are: 1. Macro parameters passed as parameter to another macro. i.e NVGPU_ACCESS_ONCE. Fixing these by additional parantheses. 2. Macro parameter used as type. i.e. type parameter in container_of. While at it, update copyright date rage for list.h and types.h. JIRA NVGPU-841 Change-Id: I4b793981d671069289720e8c041bad8125961c0c Signed-off-by: Sagar Kamble <skamble@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1929823 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
105 lines
3.4 KiB
C
105 lines
3.4 KiB
C
/*
|
|
* Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#ifndef NVGPU_LIST_H
|
|
#define NVGPU_LIST_H
|
|
#include <nvgpu/types.h>
|
|
|
|
struct nvgpu_list_node {
|
|
struct nvgpu_list_node *prev;
|
|
struct nvgpu_list_node *next;
|
|
};
|
|
|
|
static inline void nvgpu_init_list_node(struct nvgpu_list_node *node)
|
|
{
|
|
node->prev = node;
|
|
node->next = node;
|
|
}
|
|
|
|
static inline void nvgpu_list_add(struct nvgpu_list_node *new_node, struct nvgpu_list_node *head)
|
|
{
|
|
new_node->next = head->next;
|
|
new_node->next->prev = new_node;
|
|
new_node->prev = head;
|
|
head->next = new_node;
|
|
}
|
|
|
|
static inline void nvgpu_list_add_tail(struct nvgpu_list_node *new_node, struct nvgpu_list_node *head)
|
|
{
|
|
new_node->prev = head->prev;
|
|
new_node->prev->next = new_node;
|
|
new_node->next = head;
|
|
head->prev = new_node;
|
|
}
|
|
|
|
static inline void nvgpu_list_del(struct nvgpu_list_node *node)
|
|
{
|
|
node->prev->next = node->next;
|
|
node->next->prev = node->prev;
|
|
nvgpu_init_list_node(node);
|
|
}
|
|
|
|
static inline bool nvgpu_list_empty(struct nvgpu_list_node *head)
|
|
{
|
|
return head->next == head;
|
|
}
|
|
|
|
static inline void nvgpu_list_move(struct nvgpu_list_node *node, struct nvgpu_list_node *head)
|
|
{
|
|
nvgpu_list_del(node);
|
|
nvgpu_list_add(node, head);
|
|
}
|
|
|
|
static inline void nvgpu_list_replace_init(struct nvgpu_list_node *old_node, struct nvgpu_list_node *new_node)
|
|
{
|
|
new_node->next = old_node->next;
|
|
new_node->next->prev = new_node;
|
|
new_node->prev = old_node->prev;
|
|
new_node->prev->next = new_node;
|
|
nvgpu_init_list_node(old_node);
|
|
}
|
|
|
|
#define nvgpu_list_entry(ptr, type, member) \
|
|
type ## _from_ ## member(ptr)
|
|
|
|
#define nvgpu_list_next_entry(pos, type, member) \
|
|
nvgpu_list_entry((pos)->member.next, type, member)
|
|
|
|
#define nvgpu_list_first_entry(ptr, type, member) \
|
|
nvgpu_list_entry((ptr)->next, type, member)
|
|
|
|
#define nvgpu_list_last_entry(ptr, type, member) \
|
|
nvgpu_list_entry((ptr)->prev, type, member)
|
|
|
|
#define nvgpu_list_for_each_entry(pos, head, type, member) \
|
|
for ((pos) = nvgpu_list_first_entry(head, type, member); \
|
|
&(pos)->member != (head); \
|
|
(pos) = nvgpu_list_next_entry(pos, type, member))
|
|
|
|
#define nvgpu_list_for_each_entry_safe(pos, n, head, type, member) \
|
|
for ((pos) = nvgpu_list_first_entry(head, type, member), \
|
|
(n) = nvgpu_list_next_entry(pos, type, member); \
|
|
&(pos)->member != (head); \
|
|
(pos) = (n), (n) = nvgpu_list_next_entry(n, type, member))
|
|
|
|
#endif /* NVGPU_LIST_H */
|