mbox series

[00/25] libselinux: misc compiler and static analyzer findings

Message ID 20210503175350.55954-1-cgzones@googlemail.com (mailing list archive)
Headers show
Series libselinux: misc compiler and static analyzer findings | expand

Message

Christian Göttsche May 3, 2021, 5:53 p.m. UTC
Several changes found by compilers and static analyzer regarding const
qualifiers, dead code, code smells and resource cleanup.

Contains no changes with regard to libselinux callers.

Christian Göttsche (25):
  libselinux: sidtab_hash(): do not discard const qualifier
  libselinux: selinux_file_context_cmp(): do not discard const qualifier
  libselinux: label_common(): do not discard const qualifier
  libselinux: Sha1Finalise(): do not discard const qualifier
  libselinux: sefcontext_compile: mark local variable static
  libselinux: avcstat: use standard length modifier for unsigned long
    long
  libselinux: selinux_restorecon: mark local variable static
  libselinux: selabel_get_digests_all_partial_matches: free memory after
    FTS_D block
  libselinux: getconlist: free memory on multiple level arguments
  libselinux: exclude_non_seclabel_mounts(): drop unused variable
  libselinux: context_new(): drop dead assignment
  libselinux: label_x::init(): drop dead assignment
  libselinux: label_media::init(): drop dead assignment
  libselinux: setexecfilecon(): drop dead assignment
  libselinux: getdefaultcon: free memory on multiple same arguments
  libselinux: store_stem(): do not free possible non-heap object
  libselinux: matchmediacon(): close file on error
  libselinux: init_selinux_config(): free resources on error
  libselinux: label_file::init(): do not pass NULL to strdup
  libselinux: matchpathcon: free memory on realloc failure
  libselinux: label_db::db_init(): open file with CLOEXEC mode
  libselinux: drop redundant casts to the same type
  libselinux: sidtab_sid_stats(): unify parameter name
  libselinux: regex: unify parameter names
  libselinux: label_file.c: fix indent

 libselinux/src/audit2why.c                    |  2 +-
 libselinux/src/avc_sidtab.c                   | 15 ++++-----
 libselinux/src/context.c                      |  2 +-
 libselinux/src/is_customizable_type.c         |  2 +-
 libselinux/src/label_db.c                     |  2 +-
 libselinux/src/label_file.c                   | 16 ++++++----
 libselinux/src/label_file.h                   |  8 +++--
 libselinux/src/label_media.c                  |  1 -
 libselinux/src/label_x.c                      |  1 -
 libselinux/src/matchmediacon.c                |  1 +
 libselinux/src/matchpathcon.c                 | 32 +++++++++++--------
 libselinux/src/regex.c                        |  4 +--
 libselinux/src/selinux_config.c               |  7 +++-
 libselinux/src/selinux_restorecon.c           |  7 ++--
 libselinux/src/setexecfilecon.c               |  1 -
 libselinux/src/sha1.c                         | 10 +++---
 libselinux/src/sha1.h                         |  2 +-
 libselinux/utils/avcstat.c                    |  4 +--
 libselinux/utils/getconlist.c                 |  1 +
 libselinux/utils/getdefaultcon.c              |  3 ++
 libselinux/utils/sefcontext_compile.c         |  2 +-
 .../selabel_get_digests_all_partial_matches.c | 10 +++---
 22 files changed, 76 insertions(+), 57 deletions(-)

Comments

Petr Lautrbach May 18, 2021, 6:37 p.m. UTC | #1
Christian Göttsche <cgzones@googlemail.com> writes:

> Several changes found by compilers and static analyzer regarding const
> qualifiers, dead code, code smells and resource cleanup.
>
> Contains no changes with regard to libselinux callers.

Acked-by: Petr Lautrbach <plautrba@redhat.com>

All merged.

Thanks!


>
> Christian Göttsche (25):
>   libselinux: sidtab_hash(): do not discard const qualifier
>   libselinux: selinux_file_context_cmp(): do not discard const qualifier
>   libselinux: label_common(): do not discard const qualifier
>   libselinux: Sha1Finalise(): do not discard const qualifier
>   libselinux: sefcontext_compile: mark local variable static
>   libselinux: avcstat: use standard length modifier for unsigned long
>     long
>   libselinux: selinux_restorecon: mark local variable static
>   libselinux: selabel_get_digests_all_partial_matches: free memory after
>     FTS_D block
>   libselinux: getconlist: free memory on multiple level arguments
>   libselinux: exclude_non_seclabel_mounts(): drop unused variable
>   libselinux: context_new(): drop dead assignment
>   libselinux: label_x::init(): drop dead assignment
>   libselinux: label_media::init(): drop dead assignment
>   libselinux: setexecfilecon(): drop dead assignment
>   libselinux: getdefaultcon: free memory on multiple same arguments
>   libselinux: store_stem(): do not free possible non-heap object
>   libselinux: matchmediacon(): close file on error
>   libselinux: init_selinux_config(): free resources on error
>   libselinux: label_file::init(): do not pass NULL to strdup
>   libselinux: matchpathcon: free memory on realloc failure
>   libselinux: label_db::db_init(): open file with CLOEXEC mode
>   libselinux: drop redundant casts to the same type
>   libselinux: sidtab_sid_stats(): unify parameter name
>   libselinux: regex: unify parameter names
>   libselinux: label_file.c: fix indent
>
>  libselinux/src/audit2why.c                    |  2 +-
>  libselinux/src/avc_sidtab.c                   | 15 ++++-----
>  libselinux/src/context.c                      |  2 +-
>  libselinux/src/is_customizable_type.c         |  2 +-
>  libselinux/src/label_db.c                     |  2 +-
>  libselinux/src/label_file.c                   | 16 ++++++----
>  libselinux/src/label_file.h                   |  8 +++--
>  libselinux/src/label_media.c                  |  1 -
>  libselinux/src/label_x.c                      |  1 -
>  libselinux/src/matchmediacon.c                |  1 +
>  libselinux/src/matchpathcon.c                 | 32 +++++++++++--------
>  libselinux/src/regex.c                        |  4 +--
>  libselinux/src/selinux_config.c               |  7 +++-
>  libselinux/src/selinux_restorecon.c           |  7 ++--
>  libselinux/src/setexecfilecon.c               |  1 -
>  libselinux/src/sha1.c                         | 10 +++---
>  libselinux/src/sha1.h                         |  2 +-
>  libselinux/utils/avcstat.c                    |  4 +--
>  libselinux/utils/getconlist.c                 |  1 +
>  libselinux/utils/getdefaultcon.c              |  3 ++
>  libselinux/utils/sefcontext_compile.c         |  2 +-
>  .../selabel_get_digests_all_partial_matches.c | 10 +++---
>  22 files changed, 76 insertions(+), 57 deletions(-)
>
> -- 
> 2.31.1