[linux-next:master 9509/10347] fs/libfs.c:1231:47: warning: Local variable 'anon_aops' shadows outer variable [shadowVariable]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   4662b7adea50bb62e993a67f611f3be625d3df0d
commit: cf5e9d6390413e06d48540933b8ce1243315f3f4 [9509/10347] procfs: add 'path' to /proc/<pid>/fdinfo/
compiler: powerpc-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout cf5e9d6390413e06d48540933b8ce1243315f3f4
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>


cppcheck warnings: (new ones prefixed by >>)
>> mm/slab.c:3313:16: warning: Local variable 'slab' shadows outer variable [shadowVariable]
     struct slab *slab;
                  ^
   mm/slab.c:3307:15: note: Shadowed declaration
    struct slab *slab;
                 ^
   mm/slab.c:3313:16: note: Shadow variable
     struct slab *slab;
                  ^
>> fs/libfs.c:1231:47: warning: Local variable 'anon_aops' shadows outer variable [shadowVariable]
    static const struct address_space_operations anon_aops = {
                                                 ^
   fs/libfs.c:1220:46: note: Shadowed declaration
   static const struct address_space_operations anon_aops = {
                                                ^
   fs/libfs.c:1231:47: note: Shadow variable
    static const struct address_space_operations anon_aops = {
                                                 ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> mm/highmem.c:737:13: warning: Uninitialized variable: pam->page [uninitvar]
      if (pam->page == page) {
               ^
   mm/highmem.c:774:13: warning: Uninitialized variable: pam->page [uninitvar]
      if (pam->page == page) {
               ^
--
>> mm/vmstat.c:1409:53: warning: Parameter 'pos' can be declared with const [constParameter]
   static void *frag_start(struct seq_file *m, loff_t *pos)
                                                       ^
>> mm/vmstat.c:1650:68: warning: Parameter 'zone' can be declared with const [constParameter]
   static bool is_zone_first_populated(pg_data_t *pgdat, struct zone *zone)
                                                                      ^
   mm/vmstat.c:1780:55: warning: Parameter 'pos' can be declared with const [constParameter]
   static void *vmstat_start(struct seq_file *m, loff_t *pos)
                                                         ^
>> ipc/shm.c:158:0: warning: failed to expand 'ipc_init_proc_interface', it is invalid to use a preprocessor directive as macro parameter [preprocessorErrorDirective]
   #if BITS_PER_LONG <= 32
   ^
>> mm/zsmalloc.c:2060:16: warning: Local variable 'obj_allocated' shadows outer function [shadowFunction]
    unsigned long obj_allocated = zs_stat_get(class, OBJ_ALLOCATED);
                  ^
   mm/zsmalloc.c:872:13: note: Shadowed declaration
   static bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
               ^
   mm/zsmalloc.c:2060:16: note: Shadow variable
    unsigned long obj_allocated = zs_stat_get(class, OBJ_ALLOCATED);
                  ^
>> mm/zsmalloc.c:2019:15: warning: Uninitialized variables: zspage.huge, zspage.fullness, zspage.class, zspage.isolated, zspage.magic, zspage.inuse, zspage.freeobj, zspage.first_page, zspage.lock [uninitvar]
     lock_zspage(zspage);
                 ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2009:20: note: Assuming condition is false
     if (class->index != i)
                      ^
   mm/zsmalloc.c:2019:15: note: Uninitialized variables: zspage.huge, zspage.fullness, zspage.class, zspage.isolated, zspage.magic, zspage.inuse, zspage.freeobj, zspage.first_page, zspage.lock
     lock_zspage(zspage);
                 ^
   mm/zsmalloc.c:594:16: warning: Local variable 'obj_allocated' shadows outer function [shadowFunction]
    unsigned long obj_allocated, obj_used, pages_used, freeable;
                  ^
   mm/zsmalloc.c:872:13: note: Shadowed declaration
   static bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
               ^
   mm/zsmalloc.c:594:16: note: Shadow variable
    unsigned long obj_allocated, obj_used, pages_used, freeable;
                  ^
--
>> mm/mlock.c:230:20: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
    if (pagevec_count(pvec))
                      ^
   mm/mlock.c:229:9: note: Address of variable taken here.
    pvec = &per_cpu(mlock_pvec.vec, cpu);
           ^
   mm/mlock.c:229:17: note: Temporary created here.
    pvec = &per_cpu(mlock_pvec.vec, cpu);
                   ^
   mm/mlock.c:230:20: note: Using pointer that is a temporary.
    if (pagevec_count(pvec))
                      ^
>> mm/migrate.c:875:7: warning: Redundant initialization for 'rc'. The initialized value is overwritten before it is read. [redundantInitialization]
      rc = migrate_page(mapping, &dst->page, &src->page, mode);
         ^
   mm/migrate.c:865:9: note: rc is initialized
    int rc = -EAGAIN;
           ^
   mm/migrate.c:875:7: note: rc is overwritten
      rc = migrate_page(mapping, &dst->page, &src->page, mode);
         ^
>> mm/migrate.c:355:53: warning: Parameter 'mapping' can be declared with const [constParameter]
   static int expected_page_refs(struct address_space *mapping, struct page *page)
                                                       ^
>> kernel/bpf/task_iter.c:152:11: warning: Redundant initialization for 'curr_fd'. The initialized value is overwritten before it is read. [redundantInitialization]
     curr_fd = info->fd;
             ^
   kernel/bpf/task_iter.c:143:23: note: curr_fd is initialized
    unsigned int curr_fd = info->fd;
                         ^
   kernel/bpf/task_iter.c:152:11: note: curr_fd is overwritten
     curr_fd = info->fd;
             ^
>> kernel/bpf/task_iter.c:498:59: warning: Parameter 'v' can be declared with const [constParameter]
   static void task_vma_seq_stop(struct seq_file *seq, void *v)
                                                             ^
--
   kernel/sched/fair.c:11342:62: warning: Same value in both branches of ternary operator. [duplicateValueTernary]
    update_load_avg(cfs_rq, se, sched_feat(ATTACH_AGE_LOAD) ? 0 : SKIP_AGE_LOAD);
                                                                ^
   kernel/sched/fair.c:7339:1: warning: Label 'done' is not used. There is #if in function body so the label might be used in code that is removed by the preprocessor. [unusedLabelConfiguration]
   done: __maybe_unused;
   ^
   kernel/sched/sched.h:2016:67: warning: Parameter 'p' can be declared with const [constParameter]
   static inline int task_current(struct rq *rq, struct task_struct *p)
                                                                     ^
   kernel/sched/fair.c:6423:16: warning: Local variable 'task_util' shadows outer function [shadowFunction]
    unsigned long task_util, best_cap = 0;
                  ^
   kernel/sched/fair.c:4011:29: note: Shadowed declaration
   static inline unsigned long task_util(struct task_struct *p)
                               ^
   kernel/sched/fair.c:6423:16: note: Shadow variable
    unsigned long task_util, best_cap = 0;
                  ^
   kernel/sched/fair.c:6464:16: warning: Local variable 'task_util' shadows outer function [shadowFunction]
    unsigned long task_util;
                  ^
   kernel/sched/fair.c:4011:29: note: Shadowed declaration
   static inline unsigned long task_util(struct task_struct *p)
                               ^
   kernel/sched/fair.c:6464:16: note: Shadow variable
    unsigned long task_util;
                  ^
>> kernel/sched/fair.c:6967:7: warning: Local variable 'min_vruntime' shadows outer function [shadowFunction]
     u64 min_vruntime;
         ^
   kernel/sched/fair.c:573:19: note: Shadowed declaration
   static inline u64 min_vruntime(u64 min_vruntime, u64 vruntime)
                     ^
   kernel/sched/fair.c:6967:7: note: Shadow variable
     u64 min_vruntime;
         ^
   kernel/sched/fair.c:10298:6: warning: Local variable 'update_next_balance' shadows outer function [shadowFunction]
    int update_next_balance = 0;
        ^
   kernel/sched/fair.c:10152:1: note: Shadowed declaration
   update_next_balance(struct sched_domain *sd, unsigned long *next_balance)
   ^
   kernel/sched/fair.c:10298:6: note: Shadow variable
    int update_next_balance = 0;
        ^
   kernel/sched/fair.c:8933:58: warning: Parameter 'p' can be declared with const [constParameter]
   static int idle_cpu_without(int cpu, struct task_struct *p)
                                                            ^
   kernel/sched/fair.c:6482:25: warning: Uninitialized variable: task_util [uninitvar]
        asym_fits_capacity(task_util, target))
                           ^
   kernel/sched/fair.c:6471:28: note: Assuming condition is false
    if (static_branch_unlikely(&sched_asym_cpucapacity)) {
                              ^
   kernel/sched/fair.c:6482:25: note: Uninitialized variable: task_util
        asym_fits_capacity(task_util, target))
                           ^
   kernel/sched/fair.c:8171:48: warning: Uninitialized variables: cfs_rq.load, cfs_rq.nr_running, cfs_rq.h_nr_running, cfs_rq.idle_nr_running, cfs_rq.idle_h_nr_running, cfs_rq.exec_clock, cfs_rq.min_vruntime, cfs_rq.tasks_timeline, cfs_rq.curr, cfs_rq.next, cfs_rq.last, cfs_rq.skip, cfs_rq.avg, cfs_rq.removed, cfs_rq.tg_load_avg_contrib, cfs_rq.propagate, cfs_rq.prop_runnable_sum, cfs_rq.h_load, cfs_rq.last_h_load_update, cfs_rq.h_load_next, cfs_rq.rq, cfs_rq.on_list, cfs_rq.leaf_cfs_rq_list, cfs_rq.tg, cfs_rq.idle [uninitvar]
     if (update_cfs_rq_load_avg(cfs_rq_clock_pelt(cfs_rq), cfs_rq)) {
                                                  ^
>> kernel/sched/fair.c:5081:25: warning: Uninitialized variables: cfs_rq.load, cfs_rq.nr_running, cfs_rq.h_nr_running, cfs_rq.idle_nr_running, cfs_rq.idle_h_nr_running, cfs_rq.exec_clock, cfs_rq.min_vruntime, cfs_rq.min_vruntime_copy, cfs_rq.tasks_timeline, cfs_rq.curr, cfs_rq.next, cfs_rq.last, cfs_rq.skip [uninitvar]
     struct rq *rq = rq_of(cfs_rq);
                           ^
   kernel/sched/fair.c:5081:25: warning: Uninitialized variables: cfs_rq.load, cfs_rq.nr_running, cfs_rq.h_nr_running, cfs_rq.idle_nr_running, cfs_rq.idle_h_nr_running, cfs_rq.exec_clock, cfs_rq.min_vruntime, cfs_rq.min_vruntime_copy, cfs_rq.tasks_timeline, cfs_rq.curr, cfs_rq.next, cfs_rq.last, cfs_rq.skip, cfs_rq.rq, cfs_rq.on_list, cfs_rq.leaf_cfs_rq_list, cfs_rq.tg, cfs_rq.idle, cfs_rq.runtime_enabled, cfs_rq.runtime_remaining, cfs_rq.throttled_clock, cfs_rq.throttled_clock_pelt, cfs_rq.throttled_clock_pelt_time, cfs_rq.throttled, cfs_rq.throttle_count, cfs_rq.throttled_list [uninitvar]
     struct rq *rq = rq_of(cfs_rq);
                           ^
   kernel/sched/fair.c:5081:25: warning: Uninitialized variables: cfs_rq.load, cfs_rq.nr_running, cfs_rq.h_nr_running, cfs_rq.idle_nr_running, cfs_rq.idle_h_nr_running, cfs_rq.exec_clock, cfs_rq.min_vruntime, cfs_rq.min_vruntime_copy, cfs_rq.tasks_timeline, cfs_rq.curr, cfs_rq.next, cfs_rq.last, cfs_rq.skip, cfs_rq.avg, cfs_rq.load_last_update_time_copy, cfs_rq.removed [uninitvar]
     struct rq *rq = rq_of(cfs_rq);
                           ^
>> mm/slab.c:3289:7: warning: Redundant assignment of 'objp' to itself. [selfAssignment]
    objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
         ^
   mm/slab.c:3435:7: warning: Redundant assignment of 'objp' to itself. [selfAssignment]
    objp = cache_free_debugcheck(cachep, objp, caller);
         ^
>> mm/slab.c:3509:8: warning: Redundant assignment of 'p[i]' to itself. [selfAssignment]
     p[i] = cache_alloc_debugcheck_after(s, flags, p[i], caller);
          ^
>> mm/slab.c:405:9: warning: Local variable 'slab_size' shadows outer function [shadowFunction]
    size_t slab_size = PAGE_SIZE << gfporder;
           ^
   mm/slab.h:188:22: note: Shadowed declaration
   static inline size_t slab_size(const struct slab *slab)
                        ^
   mm/slab.c:405:9: note: Shadow variable
    size_t slab_size = PAGE_SIZE << gfporder;
           ^
>> mm/slab.c:1635:24: warning: Uninitialized variables: slab.__page_flags, slab.__unused_1, slab.freelist, slab.units, slab.__unused_2, slab.__page_refcount [uninitvar]
     slab_destroy(cachep, slab);
                          ^
>> fs/ntfs/ntfs.h:144:3: warning: Assignment of function parameter has no effect outside the function. [uselessAssignmentArg]
     x >>= 1;
     ^
>> fs/ntfs/layout.h:126:43: warning: Parameter 'p' can be declared with const [constParameter]
   static inline bool __ntfs_is_magicp(le32 *p, NTFS_RECORD_TYPE r)
                                             ^
>> fs/ntfs/attrib.c:705:18: warning: Either the condition '!al' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck]
    u8 *al_end = al + initialized_size;
                    ^
   fs/ntfs/attrib.c:715:26: note: Assuming that condition '!al' is not redundant
    if (!vol || !runlist || !al || size <= 0 || initialized_size < 0 ||
                            ^
   fs/ntfs/attrib.c:705:18: note: Null pointer addition
    u8 *al_end = al + initialized_size;
                    ^
>> fs/super.c:750:52: warning: Parameter 'bdev' can be declared with const [constParameter]
   struct super_block *get_super(struct block_device *bdev)
                                                      ^
   fs/super.c:788:59: warning: Parameter 'bdev' can be declared with const [constParameter]
   struct super_block *get_active_super(struct block_device *bdev)
                                                             ^
>> fs/super.c:1310:57: warning: Parameter 'data' can be declared with const [constParameter]
   static int test_bdev_super(struct super_block *s, void *data)
                                                           ^
>> lib/test_printf.c:415:11: warning: Local variable 'addr' shadows outer function [shadowFunction]
    const u8 addr[6] = {0x2d, 0x48, 0xd6, 0xfc, 0x7a, 0x05};
             ^
   lib/test_printf.c:392:1: note: Shadowed declaration
   addr(void)
   ^
   lib/test_printf.c:415:11: note: Shadow variable
    const u8 addr[6] = {0x2d, 0x48, 0xd6, 0xfc, 0x7a, 0x05};
             ^
--
>> kernel/fork.c:942:33: warning: Parameter 'src' can be declared with const [constParameter]
               struct task_struct *src)
                                   ^
>> kernel/fork.c:3256:42: warning: Parameter 'table' can be declared with const [constParameter]
   int sysctl_max_threads(struct ctl_table *table, int write,
                                            ^
>> lib/maple_tree.c:326:2: warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]
    node = (void *)((unsigned long)node & ~MAPLE_ENODE_NULL);
    ^
   lib/maple_tree.c:331:2: warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]
    node = (void *)((unsigned long)node | MAPLE_ENODE_NULL);
    ^
>> lib/maple_tree.c:1871:21: warning: Array index 'split' is used before limits check. [arrayIndexThenCheck]
     while (((bn->pivot[split] - min) < slot_count - 1) &&
                       ^
>> lib/maple_tree.c:4302:23: warning: Boolean result is used in bitwise operation. Clarify expression with parentheses. [clarifyCondition]
     if (!!wr_mas->entry ^ !!wr_mas->content)
                         ^
>> lib/maple_tree.c:4266:15: warning: The if condition is the same as the previous if condition [duplicateCondition]
     if (new_end < node_pivots)
                 ^
   lib/maple_tree.c:4263:15: note: First condition
     if (new_end < node_pivots)
                 ^
   lib/maple_tree.c:4266:15: note: Second condition
     if (new_end < node_pivots)
                 ^
>> lib/maple_tree.c:2426:8: warning: Redundant initialization for 'r_tmp'. The initialized value is overwritten before it is read. [redundantInitialization]
    r_tmp = *mast->orig_r;
          ^
   lib/maple_tree.c:2420:24: note: r_tmp is initialized
    struct ma_state r_tmp = *mast->orig_r;
                          ^
   lib/maple_tree.c:2426:8: note: r_tmp is overwritten
    r_tmp = *mast->orig_r;
          ^
>> lib/maple_tree.c:2427:8: warning: Redundant initialization for 'l_tmp'. The initialized value is overwritten before it is read. [redundantInitialization]
    l_tmp = *mast->orig_l;
          ^
   lib/maple_tree.c:2421:24: note: l_tmp is initialized
    struct ma_state l_tmp = *mast->orig_l;
                          ^
   lib/maple_tree.c:2427:8: note: l_tmp is overwritten
    l_tmp = *mast->orig_l;
          ^
>> lib/maple_tree.c:3160:22: warning: Found suspicious operator ',' [constStatement]
    void __rcu **l_slots, **slots;
                        ^
>> lib/maple_tree.c:694:59: warning: Parameter 'pivots' can be declared with const [constParameter]
   mas_safe_pivot(const struct ma_state *mas, unsigned long *pivots,
                                                             ^
   lib/maple_tree.c:712:51: warning: Parameter 'pivots' can be declared with const [constParameter]
   mas_safe_min(struct ma_state *mas, unsigned long *pivots, unsigned char offset)
                                                     ^
   lib/maple_tree.c:1384:21: warning: Parameter 'pivots' can be declared with const [constParameter]
        unsigned long *pivots,
                       ^
>> lib/maple_tree.c:1522:52: warning: Parameter 'gaps' can be declared with const [constParameter]
   ma_max_gap(struct maple_node *node, unsigned long *gaps, enum maple_type mt,
                                                      ^
   lib/maple_tree.c:1954:43: warning: Parameter 'pivots' can be declared with const [constParameter]
     struct maple_node *node, unsigned long *pivots,
                                             ^
>> lib/maple_tree.c:2033:55: warning: Parameter 'mas' can be declared with const [constParameter]
   static inline void mas_descend_adopt(struct ma_state *mas)
                                                         ^
>> lib/maple_tree.c:3208:11: warning: Size of pointer 'pivs' used instead of size of its data. [pointerSize]
      memset(pivs + tmp, 0,
             ^

vim +/anon_aops +1231 fs/libfs.c

cf5e9d6390413e Kalesh Singh            2022-06-23  1228  
6987843ff7e836 Al Viro                 2013-10-02  1229  struct inode *alloc_anon_inode(struct super_block *s)
6987843ff7e836 Al Viro                 2013-10-02  1230  {
6987843ff7e836 Al Viro                 2013-10-02 @1231  	static const struct address_space_operations anon_aops = {
46de8b979492e1 Matthew Wilcox (Oracle  2022-02-09  1232) 		.dirty_folio	= noop_dirty_folio,
6987843ff7e836 Al Viro                 2013-10-02  1233  	};
6987843ff7e836 Al Viro                 2013-10-02  1234  	struct inode *inode = new_inode_pseudo(s);
6987843ff7e836 Al Viro                 2013-10-02  1235  
6987843ff7e836 Al Viro                 2013-10-02  1236  	if (!inode)
6987843ff7e836 Al Viro                 2013-10-02  1237  		return ERR_PTR(-ENOMEM);
6987843ff7e836 Al Viro                 2013-10-02  1238  
6987843ff7e836 Al Viro                 2013-10-02  1239  	inode->i_ino = get_next_ino();
6987843ff7e836 Al Viro                 2013-10-02  1240  	inode->i_mapping->a_ops = &anon_aops;
6987843ff7e836 Al Viro                 2013-10-02  1241  
6987843ff7e836 Al Viro                 2013-10-02  1242  	/*
6987843ff7e836 Al Viro                 2013-10-02  1243  	 * Mark the inode dirty from the very beginning,
6987843ff7e836 Al Viro                 2013-10-02  1244  	 * that way it will never be moved to the dirty
6987843ff7e836 Al Viro                 2013-10-02  1245  	 * list because mark_inode_dirty() will think
6987843ff7e836 Al Viro                 2013-10-02  1246  	 * that it already _is_ on the dirty list.
6987843ff7e836 Al Viro                 2013-10-02  1247  	 */
6987843ff7e836 Al Viro                 2013-10-02  1248  	inode->i_state = I_DIRTY;
6987843ff7e836 Al Viro                 2013-10-02  1249  	inode->i_mode = S_IRUSR | S_IWUSR;
6987843ff7e836 Al Viro                 2013-10-02  1250  	inode->i_uid = current_fsuid();
6987843ff7e836 Al Viro                 2013-10-02  1251  	inode->i_gid = current_fsgid();
6987843ff7e836 Al Viro                 2013-10-02  1252  	inode->i_flags |= S_PRIVATE;
078cd8279e6599 Deepa Dinamani          2016-09-14  1253  	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
6987843ff7e836 Al Viro                 2013-10-02  1254  	return inode;
6987843ff7e836 Al Viro                 2013-10-02  1255  }
6987843ff7e836 Al Viro                 2013-10-02  1256  EXPORT_SYMBOL(alloc_anon_inode);
1c994a0909a556 Jeff Layton             2014-08-27  1257  

:::::: The code at line 1231 was first introduced by commit
:::::: 6987843ff7e836ea65b554905aec34d2fad05c94 take anon inode allocation to libfs.c

:::::: TO: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
:::::: CC: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux