OpenAFS Master Repository branch, master, updated. openafs-devel-1_9_1-317-g36e4c02

Gerrit Code Review gerrit@openafs.org
Thu, 29 Feb 2024 12:56:18 -0500


The following commit has been merged in the master branch:
commit 36e4c02ff27b9d66755b9544778896b9b1e5c391
Author: Cheyenne Wills <cwills@sinenomine.net>
Date:   Fri Feb 9 09:01:33 2024 -0700

    afs: fix 'ops' variable may be used uninitialized
    
    When the function rxfs_storeInit() has the static attribute, gcc flags
    the variable 'ops' as possibly uninitialized.
    
    In function 'afs_CacheStoreDCaches',
        inlined from 'afs_CacheStoreVCache' at
         .../src/afs/afs_fetchstore.c:630:14:
         .../afs/afs_fetchstore.c:535:17: error: 'ops' may be used
         uninitialized [-Werror=maybe-uninitialized]
          535 |         code = (*ops->destroy)(&rock, code);
              |                ~^~~~~~~~~~~~~~
         ...src/afs/afs_fetchstore.c: In function 'afs_CacheStoreVCache':
         ...src/afs/afs_fetchstore.c:567:22: note: 'ops' was declared here
          567 |     struct storeOps *ops;
              |                      ^~~
         cc1: all warnings being treated as errors
    
    This is a false positive report by the gcc compiler.
    
    The function rxfs_storeInit() returns a 0 only when it has successfully
    assigned a value to the ops variable, and afs_CacheStoreDcaches() is
    only called if the return value from rxfs_storeInit() is 0.
    
    The ops variable is only used within a block that is within a for loop,
    which could leave a stray value if the variable isn't initialized within
    that loop.
    
    Assigning a NULL to ops is sufficient to avoid the compiler error, and
    relocating the declaration of the ops variable into the block where it
    is actually used ensures that it's always initialized before its use
    within the loop.
    
    Clean up whitespace in the statement that follows the new location for
    the ops variable.
    
    Note, this commit is being added before a commit that adds the static
    attribute to the rxfs_storeInit() function which also "fixes" the
    compiler error (see: afs: Add static attribute to internal functions).
    
    Change-Id: Id2c3e68720f92ea05818419567ffe90ce0b5061a
    Reviewed-on: https://gerrit.openafs.org/15630
    Reviewed-by: Andrew Deason <adeason@sinenomine.net>
    Tested-by: BuildBot <buildbot@rampaginggeek.com>
    Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
    Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

 src/afs/afs_fetchstore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
OpenAFS Master Repository