Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cppcheck 1.82 warnings #9732

Closed
wants to merge 8 commits into from
Closed

Commits on Dec 16, 2019

  1. cppcheck: (error) Uninitialized variable

    Resolve the following uninitialized variable warnings.  In practice
    these were unreachable due to the goto.  Replacing the goto with a
    return resolves the warning and yields more readable code.
    
    [module/icp/algs/modes/ccm.c:892]: (error) Uninitialized variable: ccm_param
    [module/icp/algs/modes/ccm.c:893]: (error) Uninitialized variable: ccm_param
    [module/icp/algs/modes/gcm.c:564]: (error) Uninitialized variable: gcm_param
    [module/icp/algs/modes/gcm.c:565]: (error) Uninitialized variable: gcm_param
    [module/icp/algs/modes/gcm.c:599]: (error) Uninitialized variable: gmac_param
    [module/icp/algs/modes/gcm.c:600]: (error) Uninitialized variable: gmac_param
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Ubuntu authored and behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    1bad165 View commit details
    Browse the repository at this point in the history
  2. cppcheck: (error) Uninitialized variable

    As of cppcheck 1.82 warnings are issued when using the list_for_each_*
    functions with an uninitialized variable.  Functionally, this is fine
    but to resolve the warning initialize these variables.
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Ubuntu authored and behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    dbd873a View commit details
    Browse the repository at this point in the history
  3. cppcheck: (error) Shifting signed 64-bit value by 63 bits

    As of cppcheck 1.82 surpress the warning regarding shifting too many
    bits for __divdi3() implemention.  The algoritm used here is correct.
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Ubuntu authored and behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    d4fb6f1 View commit details
    Browse the repository at this point in the history
  4. cppcheck: (error) Memory leak: vtoc

    Resolve the reported memory leak by using a dedicated local vptr
    variable to store the pointer reported by calloc().  Only assign the
    passed **vtoc function argument on success, in all other cases vptr
    is freed.
    
    [lib/libefi/rdwr_efi.c:403]: (error) Memory leak: vtoc
    [lib/libefi/rdwr_efi.c:422]: (error) Memory leak: vtoc
    [lib/libefi/rdwr_efi.c:440]: (error) Memory leak: vtoc
    [lib/libefi/rdwr_efi.c:454]: (error) Memory leak: vtoc
    [lib/libefi/rdwr_efi.c:470]: (error) Memory leak: vtoc
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    0f02a61 View commit details
    Browse the repository at this point in the history
  5. cppcheck: (warning) Possible null pointer dereference: dnp

    The dnp argument can only be set to NULL when the DNODE_DRY_RUN flag
    is set.  In which case, an early return path will be executed and a
    NULL pointer dereference at the given location is impossible.  Add
    an additional ASSERT to silence the cppcheck warning and document
    that dbp must never be NULL at the point in the function.
    
    [module/zfs/dnode.c:1566]: (warning) Possible null pointer deref: dnp
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    dd35210 View commit details
    Browse the repository at this point in the history
  6. cppcheck: (error) Null pointer dereference: who_perm

    As indicated by the VERIFY the local who_perm variable can never
    be NULL in parse_fs_perm().  Due to the existance of the is_set
    conditional, which is always true, cppcheck 1.88 was reporting
    a possible NULL reference.  Resolve the issue by removing the
    extraneous is_set variable.
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    3511eb8 View commit details
    Browse the repository at this point in the history
  7. cppcheck: (error) Address of local auto-variable assigned

    Suppress autoVariables warnings in the lua interpretter.  The usage
    here while unconventional in intentional and the same as upstream.
    
    [module/lua/ldebug.c:327]: (error) Address of local auto-variable
        assigned to a function parameter.
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    behlendorf committed Dec 16, 2019
    Configuration menu
    Copy the full SHA
    161704b View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2019

  1. cppcheck: (warning) Possible null pointer dereference: nvh

    Move the 'nvh = (void *)buf' assignment after the 'buf == NULL'
    check to resolve the warning.  Interestingly, cppcheck 1.88
    correctly determines that the existing code is safe, while
    cppcheck 1.86 reports the warning.
    
    Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    behlendorf committed Dec 17, 2019
    Configuration menu
    Copy the full SHA
    84a615f View commit details
    Browse the repository at this point in the history