From 847105f3c54e332f1f5f45f079bd3a2329d7aea9 Mon Sep 17 00:00:00 2001 From: Jay Jay Billings Date: Fri, 22 May 2020 18:05:36 -0400 Subject: [PATCH 1/2] Fixed GCC 10 printing null variable bugs for Fedora 32 build. Signed-off-by: Jay Jay Billings --- interface/vcos/pthreads/vcos_pthreads.c | 2 +- interface/vcos/vcos_logging.h | 4 ++-- interface/vmcs_host/linux/vcfilesys.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interface/vcos/pthreads/vcos_pthreads.c b/interface/vcos/pthreads/vcos_pthreads.c index 77ce58c2c..37e3da9de 100644 --- a/interface/vcos/pthreads/vcos_pthreads.c +++ b/interface/vcos/pthreads/vcos_pthreads.c @@ -306,7 +306,7 @@ void vcos_vlog_default_impl(const VCOS_LOG_CAT_T *cat, VCOS_LOG_LEVEL_T _level, #endif if(NULL != log_fhandle) { - if (cat->flags.want_prefix) + if (NULL != cat && cat->flags.want_prefix) fprintf( log_fhandle, "%s: ", cat->name ); vfprintf(log_fhandle, fmt, args); fputs("\n", log_fhandle); diff --git a/interface/vcos/vcos_logging.h b/interface/vcos/vcos_logging.h index a2f9fe08d..1bbf111d9 100644 --- a/interface/vcos/vcos_logging.h +++ b/interface/vcos/vcos_logging.h @@ -231,8 +231,8 @@ void vcos_log_dump_mem_impl( const VCOS_LOG_CAT_T *cat, # if !defined(AMPUTATE_ALL_VCOS_LOGGING) && (!defined(NDEBUG) || defined(VCOS_ALWAYS_WANT_LOGGING)) # define VCOS_LOGGING_ENABLED -# define _VCOS_LOG_X(cat, _level, fmt...) do { if (vcos_is_log_enabled(cat,_level)) vcos_log_impl(cat,_level,fmt); } while (0) -# define _VCOS_VLOG_X(cat, _level, fmt, ap) do { if (vcos_is_log_enabled(cat,_level)) vcos_vlog_impl(cat,_level,fmt,ap); } while (0) +# define _VCOS_LOG_X(cat, _level, fmt...) do { if (vcos_is_log_enabled(cat,_level) && NULL != cat) vcos_log_impl(cat,_level,fmt); } while (0) +# define _VCOS_VLOG_X(cat, _level, fmt, ap) do { if (vcos_is_log_enabled(cat,_level) && NULL != cat) vcos_vlog_impl(cat,_level,fmt,ap); } while (0) # else # define _VCOS_LOG_X(cat, _level, fmt...) (void)0 # define _VCOS_VLOG_X(cat, _level, fmt, ap) (void)0 diff --git a/interface/vmcs_host/linux/vcfilesys.c b/interface/vmcs_host/linux/vcfilesys.c index 9f3ebf159..80cb389a1 100644 --- a/interface/vmcs_host/linux/vcfilesys.c +++ b/interface/vmcs_host/linux/vcfilesys.c @@ -1016,7 +1016,8 @@ int64_t vc_hostfs_totalspace64(const char *inPath) } } - DEBUG_MINOR( "vc_hostfs_totalspace for '%s' returning %" PRId64 "", path, ret ); + if (NULL != path) + DEBUG_MINOR( "vc_hostfs_totalspace for '%s' returning %" PRId64 "", path, ret ); if (path) free( path ); From 94cbfad18eb9a7c8b803871d7372ca31f3546b59 Mon Sep 17 00:00:00 2001 From: Jay Jay Billings Date: Mon, 15 Jun 2020 13:17:22 -0400 Subject: [PATCH 2/2] Condensed null checks to avoid 'const != var' style Signed-off-by: Jay Jay Billings --- interface/vcos/pthreads/vcos_pthreads.c | 2 +- interface/vmcs_host/linux/vcfilesys.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/vcos/pthreads/vcos_pthreads.c b/interface/vcos/pthreads/vcos_pthreads.c index 37e3da9de..2e0ad3c5f 100644 --- a/interface/vcos/pthreads/vcos_pthreads.c +++ b/interface/vcos/pthreads/vcos_pthreads.c @@ -306,7 +306,7 @@ void vcos_vlog_default_impl(const VCOS_LOG_CAT_T *cat, VCOS_LOG_LEVEL_T _level, #endif if(NULL != log_fhandle) { - if (NULL != cat && cat->flags.want_prefix) + if (cat->flags.want_prefix && cat->name) fprintf( log_fhandle, "%s: ", cat->name ); vfprintf(log_fhandle, fmt, args); fputs("\n", log_fhandle); diff --git a/interface/vmcs_host/linux/vcfilesys.c b/interface/vmcs_host/linux/vcfilesys.c index 80cb389a1..446326e20 100644 --- a/interface/vmcs_host/linux/vcfilesys.c +++ b/interface/vmcs_host/linux/vcfilesys.c @@ -1016,7 +1016,7 @@ int64_t vc_hostfs_totalspace64(const char *inPath) } } - if (NULL != path) + if (path) DEBUG_MINOR( "vc_hostfs_totalspace for '%s' returning %" PRId64 "", path, ret ); if (path)