
From: Zhang Zekun <zhangzekun11@huawei.com> Offering: HULK hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5XQS4 CVE: NA ----------------------------------------- Fix the following CodeCheck2.0 static warnings. (1) Inline functions (and functional macros) are recommended to be no more than 3 lines ( Length: 5 ). Remove the inline clause before sp_mapping_find(). (2) Do not declare or define reserved identifiers.The reserved identifier: __prot = prot. There need not to define a new variable, just use prot directly. (3) Multi-branch statements of if, else/elseif, if there are multiple statements in any branch, all branches need to be braced. Add brackets in if, elese/elseif statements in sp_alloc_area(). (4) Return value judgment should follow the function call. Remove an empty line after sp_mapping_type() in function sp_mapping_detach(). (5) The pointer(*) can't have no spaces neither before nor after it. Remove tap before *mapping[SP_MAPPING_END], use space instead. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> --- mm/share_pool.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mm/share_pool.c b/mm/share_pool.c index 42a63b9beabc..51422fdb1485 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -216,7 +216,7 @@ struct sp_group { struct rw_semaphore rw_lock; /* list node for dvpp mapping */ struct list_head mnode; - struct sp_mapping *mapping[SP_MAPPING_END]; + struct sp_mapping *mapping[SP_MAPPING_END]; }; /* a per-process(per mm) struct which manages a sp_group_node list */ @@ -364,7 +364,6 @@ static void sp_mapping_detach(struct sp_group *spg, struct sp_mapping *spm) return; type = sp_mapping_type(spm); - if (type == SP_MAPPING_DVPP) list_del(&spg->mnode); if (atomic_dec_and_test(&spm->user)) @@ -456,7 +455,7 @@ static int sp_mapping_group_setup(struct mm_struct *mm, struct sp_group *spg) return 0; } -static inline struct sp_mapping *sp_mapping_find(struct sp_group *spg, +static struct sp_mapping *sp_mapping_find(struct sp_group *spg, unsigned long addr) { if (addr >= MMAP_SHARE_POOL_NORMAL_START && addr < MMAP_SHARE_POOL_NORMAL_END) @@ -1503,10 +1502,9 @@ int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id) unsigned long populate = 0; struct file *file = spa_file(spa); unsigned long addr; - unsigned long __prot = prot; if ((spa->flags & (SP_PROT_RO | SP_PROT_FOCUS)) == (SP_PROT_RO | SP_PROT_FOCUS)) - __prot &= ~PROT_WRITE; + prot &= ~PROT_WRITE; __sp_area_drop_locked(prev); prev = spa; @@ -1519,7 +1517,7 @@ int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id) spin_unlock(&sp_area_lock); if (spa->type == SPA_TYPE_K2SPG && spa->kva) { - addr = sp_remap_kva_to_vma(spa->kva, spa, mm, __prot, NULL); + addr = sp_remap_kva_to_vma(spa->kva, spa, mm, prot, NULL); if (IS_ERR_VALUE(addr)) pr_warn("add group remap k2u failed %ld\n", addr); @@ -1537,7 +1535,7 @@ int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id) break; } - addr = sp_mmap(mm, file, spa, &populate, __prot, NULL); + addr = sp_mmap(mm, file, spa, &populate, prot, NULL); if (IS_ERR_VALUE(addr)) { sp_munmap_task_areas(mm, spg, &spa->link); up_write(&mm->mmap_lock); @@ -1791,10 +1789,11 @@ static struct sp_area *sp_alloc_area(unsigned long size, unsigned long flags, return ERR_PTR(-EINVAL); } mapping = spg->mapping[SP_MAPPING_RO]; - } else if (flags & SP_DVPP) + } else if (flags & SP_DVPP) { mapping = spg->mapping[SP_MAPPING_DVPP]; - else + } else { mapping = spg->mapping[SP_MAPPING_NORMAL]; + } if (!mapping) { pr_err_ratelimited("non DVPP spg, id %d\n", spg->id); -- 2.17.1