diff options
author | Martin Burnicki <martin.burnicki@meinberg.de> | 2022-12-13 15:58:33 +0100 |
---|---|---|
committer | Martin Burnicki <martin.burnicki@meinberg.de> | 2022-12-13 15:58:33 +0100 |
commit | 8efbee4b28b03891f97910b5ba7fea3322ba8e23 (patch) | |
tree | d7a01d37ff0420cddf2f5b6858b71a9f15bf9115 | |
parent | 72996e0fdff2cfead96ca748844e389f8c87deaa (diff) | |
download | mbgtools-lx-8efbee4b28b03891f97910b5ba7fea3322ba8e23.tar.gz mbgtools-lx-8efbee4b28b03891f97910b5ba7fea3322ba8e23.zip |
Update some mbglib files to fix potential compiler warnings
-rw-r--r-- | mbglib/common/lan_util.c | 6 | ||||
-rw-r--r-- | mbglib/common/mbg_syn1588_io.c | 36 | ||||
-rw-r--r-- | mbglib/common/mbg_tgt.h | 30 | ||||
-rw-r--r-- | mbglib/common/mbgutil.c | 6 | ||||
-rw-r--r-- | mbglib/common/nanotime.c | 22 | ||||
-rw-r--r-- | mbglib/common/use_pack.h | 8 |
6 files changed, 64 insertions, 44 deletions
diff --git a/mbglib/common/lan_util.c b/mbglib/common/lan_util.c index 8615e74..95f95a7 100644 --- a/mbglib/common/lan_util.c +++ b/mbglib/common/lan_util.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: lan_util.c 1.24 2022/08/26 13:55:28 martin.burnicki REL_M $ + * $Id: lan_util.c 1.25 2022/12/13 15:25:16 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,6 +10,8 @@ * * ----------------------------------------------------------------------- * $Log: lan_util.c $ + * Revision 1.25 2022/12/13 15:25:16 martin.burnicki + * Fixed a potential compiler warning. * Revision 1.24 2022/08/26 13:55:28 martin.burnicki * Changed the return type of some snprint_... functions from size_t to int. * Revision 1.23 2021/07/20 10:27:30 daniel @@ -281,7 +283,7 @@ int snprint_ip4_cidr_addr( char *s, size_t max_len, const IP4_ADDR *p_addr, const IP4_ADDR *p_mask, const char *info ) { int cidr_mask_bits; - size_t n = snprint_ip4_addr( s, max_len, p_addr, info ); + int n = snprint_ip4_addr( s, max_len, p_addr, info ); cidr_mask_bits = get_ip4_net_mask_bits( p_mask ); diff --git a/mbglib/common/mbg_syn1588_io.c b/mbglib/common/mbg_syn1588_io.c index e27dbf7..af77d00 100644 --- a/mbglib/common/mbg_syn1588_io.c +++ b/mbglib/common/mbg_syn1588_io.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_syn1588_io.c 1.9 2022/06/01 19:59:31 martin.burnicki REL_M $ + * $Id: mbg_syn1588_io.c 1.11 2022/09/07 15:39:06 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -10,7 +10,11 @@ * * ----------------------------------------------------------------------- * $Log: mbg_syn1588_io.c $ - * Revision 1.9 2022/06/01 19:59:31 martin.burnicki + * Revision 1.11 2022/09/07 15:39:06 martin.burnicki + * Fixed some compiler warnings in debug code. + * Revision 1.10 2022/09/01 14:56:18Z martin.burnicki + * Fix build in case mbgdevio is statically linked. + * Revision 1.9 2022/06/01 19:59:31Z martin.burnicki * Removed inappropriate function attributes from some functions. * Revision 1.8 2022/05/31 13:09:30Z martin.burnicki * Support SYN1588 mutex on Windows. @@ -321,8 +325,8 @@ void mbg_syn1588_close_device( MBG_DEV_HANDLE *p_dh ) if ( p == NULL ) { #if DEBUG_SYN1588_OPEN_CLOSE - fprintf( stderr, "%s: no existing device slot found for file handle 0x%lX\n", - __func__, (ulong) *p_dh ); + fprintf( stderr, "%s: no existing device slot found for file handle 0x%" PRIx64 "\n", + __func__, (uint64_t) *p_dh ); #endif goto out; } @@ -330,8 +334,8 @@ void mbg_syn1588_close_device( MBG_DEV_HANDLE *p_dh ) if ( p->use_count == 0 ) { #if DEBUG_SYN1588_OPEN_CLOSE - fprintf( stderr, "%s: use count already 0 for file handle 0x%lX, dev idx %i\n", - __func__, (ulong) *p_dh, p->dev_idx ); + fprintf( stderr, "%s: use count already 0 for file handle 0x%" PRIx64 ", dev idx %i\n", + __func__, (uint64_t) *p_dh, p->dev_idx ); #endif goto out; @@ -342,8 +346,8 @@ void mbg_syn1588_close_device( MBG_DEV_HANDLE *p_dh ) if ( p->use_count == 0 ) { #if DEBUG_SYN1588_OPEN_CLOSE - fprintf( stderr, "%s: use count decreased to 0, closing device with idx %i, handle 0x%lX\n\n", - __func__, p->dev_idx, (ulong) p->dh ); + fprintf( stderr, "%s: use count decreased to 0, closing device with idx %i, handle 0x%" PRIx64 "\n\n", + __func__, p->dev_idx, (uint64_t) p->dh ); #endif syn1588_close( p->dev_idx ); mbg_syn1588_set_dev_info( p, MBG_INVALID_DEV_HANDLE, @@ -352,8 +356,8 @@ void mbg_syn1588_close_device( MBG_DEV_HANDLE *p_dh ) } #if DEBUG_SYN1588_OPEN_CLOSE - fprintf( stderr, "%s: decreased use count is %i, not closing device with idx %i, handle 0x%lX\n", - __func__, p->use_count, p->dev_idx, (ulong) p->dh ); + fprintf( stderr, "%s: decreased use count is %i, not closing device with idx %i, handle 0x%" PRIx64 "\n", + __func__, p->use_count, p->dev_idx, (uint64_t) p->dh ); #endif } #else @@ -409,8 +413,8 @@ int mbg_syn1588_open_device( SYN1588_DEV_IDX dev_idx, MBG_DEV_HANDLE *p_dh ) p->use_count++; #if DEBUG_SYN1588_OPEN_CLOSE - fprintf( stderr, "%s: opened device idx %i, new handle 0x%lX, new use count: %li\n", - __func__, p->dev_idx, (ulong) p->dh, p->use_count ); + fprintf( stderr, "%s: opened device idx %i, new handle 0x%" PRIx64 ", new use count: %li\n", + __func__, p->dev_idx, (uint64_t) p->dh, p->use_count ); #endif #if SUPP_SYN1588_USR_SPC_TESTS @@ -433,8 +437,8 @@ int mbg_syn1588_open_device( SYN1588_DEV_IDX dev_idx, MBG_DEV_HANDLE *p_dh ) p->use_count++; #if DEBUG_SYN1588_OPEN_CLOSE - fprintf( stderr, "%s: re-using handle 0x%lX for idx %i, new use count: %li\n", - __func__, (ulong) p->dh, p->dev_idx, p->use_count ); + fprintf( stderr, "%s: re-using handle 0x%" PRIx64 " for idx %i, new use count: %li\n", + __func__, (uint64_t) p->dh, p->dev_idx, p->use_count ); #endif rc = MBG_SUCCESS; @@ -758,7 +762,7 @@ int do_syn1588_get_safe_pcps_time_stamp_raw( MBG_DEV_HANDLE dh, // If on Windows, we have to get a lock to protect // against concurrent access. - #if defined( MBG_TGT_WIN32 ) + #if defined( MBG_TGT_WIN32 ) && !defined( MBGDEVIO_STATIC_LIB ) mbgdevio_syn1588_get_lock_win32(); #endif @@ -768,7 +772,7 @@ int do_syn1588_get_safe_pcps_time_stamp_raw( MBG_DEV_HANDLE dh, o_rc = syn1588_getSafeTimeAndStatus( dev_idx, p_tss ); // If on Windows, we have to release the lock we got above. - #if defined( MBG_TGT_WIN32 ) + #if defined( MBG_TGT_WIN32 ) && !defined( MBGDEVIO_STATIC_LIB ) mbgdevio_syn1588_release_lock_win32(); #endif diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h index 05527a7..07bdcf8 100644 --- a/mbglib/common/mbg_tgt.h +++ b/mbglib/common/mbg_tgt.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbg_tgt.h 1.53 2022/03/17 16:38:57 martin.burnicki REL_M $ + * $Id: mbg_tgt.h 1.54 2022/09/01 15:46:33 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,7 +11,10 @@ * * ----------------------------------------------------------------------- * $Log: mbg_tgt.h $ - * Revision 1.53 2022/03/17 16:38:57 martin.burnicki + * Revision 1.54 2022/09/01 15:46:33 martin.burnicki + * Suppress deprecated function warnings if + * NO_WARN_DEPRECATED is defined. + * Revision 1.53 2022/03/17 16:38:57Z martin.burnicki * Added definitions MBG_DEV_HANDLE_FMT. * Revision 1.52 2021/10/05 09:10:44Z martin * Clean up definitions _MBG_API_ATTR_EXPORT and _MBG_API_ATTR_IMPORT. @@ -574,15 +577,16 @@ extern "C" { #define MBG_TGT_HAS_WCHAR_T 1 - - #if defined( __clang__ ) - #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) // works with clang 3.4.1 - #elif ( _GCC_VERSION > 40500 ) // gcc 4.5.0 and newer - #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) - #elif ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer - #define _DEPRECATED_BY( _s ) __attribute__((deprecated)) - #else - // Not supported at all, use empty default definiton below. + #if !defined( NO_WARN_DEPRECATED ) + #if defined( __clang__ ) + #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) // works with clang 3.4.1 + #elif ( _GCC_VERSION > 40500 ) // gcc 4.5.0 and newer + #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) + #elif ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer + #define _DEPRECATED_BY( _s ) __attribute__((deprecated)) + #else + // Not supported at all, use empty default definiton below. + #endif #endif #if ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer @@ -692,7 +696,9 @@ extern "C" { // file of the DDK project. #if ( ( _MSC_VER >= 1500 ) || \ ( ( _MSC_VER >= 1400 ) && !defined( _DDK_BUILD_ ) ) ) - #define _DEPRECATED_BY( _s ) __declspec(deprecated("deprecated, use \"" _s "\"")) + #if !defined( NO_WARN_DEPRECATED ) + #define _DEPRECATED_BY( _s ) __declspec(deprecated("deprecated, use \"" _s "\"")) + #endif #endif // availability of _abs64() diff --git a/mbglib/common/mbgutil.c b/mbglib/common/mbgutil.c index ad85b86..bbf079d 100644 --- a/mbglib/common/mbgutil.c +++ b/mbglib/common/mbgutil.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: mbgutil.c 1.16 2021/11/08 20:01:37 martin.burnicki REL_M $ + * $Id: mbgutil.c 1.17 2022/08/23 17:30:49 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -9,6 +9,8 @@ * * ----------------------------------------------------------------------- * $Log: mbgutil.c $ + * Revision 1.17 2022/08/23 17:30:49 martin.burnicki + * Quieted a compiler warning. * Revision 1.16 2021/11/08 20:01:37 martin.burnicki * In mbg_str_dev_name(), print build num in case * of SYN1588 device. @@ -541,7 +543,9 @@ _MBG_API_ATTR int _MBG_API mbg_str_pcps_date_time( char *s, int max_len, int n = mbg_str_pcps_date( s, max_len, pt ); n += mbg_strchar( &s[n], max_len - n, ' ', mbg_date_time_dist ); n += mbg_str_pcps_time( &s[n], max_len - n, pt ); + // FIXME Use tz_str ? + (void) tz_str; return n; diff --git a/mbglib/common/nanotime.c b/mbglib/common/nanotime.c index a7ea088..e9592ef 100644 --- a/mbglib/common/nanotime.c +++ b/mbglib/common/nanotime.c @@ -1,7 +1,7 @@ /************************************************************************** * - * $Id: nanotime.c 1.11 2022/06/23 14:48:23 martin.burnicki REL_M $ + * $Id: nanotime.c 1.12 2022/09/02 12:41:38 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * @@ -11,7 +11,9 @@ * * ----------------------------------------------------------------------- * $Log: nanotime.c $ - * Revision 1.11 2022/06/23 14:48:23 martin.burnicki + * Revision 1.12 2022/09/02 12:41:38 martin.burnicki + * Fixed some compiler warnings. + * Revision 1.11 2022/06/23 14:48:23Z martin.burnicki * Changed the return value of some snprintf_ functions from size_t to int. * Revision 1.10 2021/10/20 07:27:18 thomas-b * Fixed conversion between fractions of TM_GPS and ns in NANO_TIME_64 @@ -116,10 +118,10 @@ void double_to_nano_time( NANO_TIME *p, double d ) */ int snprint_nano_time( char *s, size_t max_len, const NANO_TIME *nt ) { - size_t n = snprintf_safe( s, max_len, "%c%li.%09li", - _nano_time_negative( nt ) ? '-' : '+', - labs( (long) nt->secs ), - labs( (long) nt->nano_secs ) ); + int n = snprintf_safe( s, max_len, "%c%li.%09li", + _nano_time_negative( nt ) ? '-' : '+', + labs( (long) nt->secs ), + labs( (long) nt->nano_secs ) ); return n; } // snprint_nano_time @@ -218,10 +220,10 @@ void double_to_nano_time_64( NANO_TIME_64 *p, double d ) */ int snprint_nano_time_64( char *s, size_t max_len, const NANO_TIME_64 *nt ) { - size_t n = snprintf_safe( s, max_len, "%c%" PRId64 ".%09" PRId64, - _nano_time_negative( nt ) ? '-' : '+', - _abs64( nt->secs ), - _abs64( nt->nano_secs ) ); + int n = snprintf_safe( s, max_len, "%c%" PRId64 ".%09" PRId64, + _nano_time_negative( nt ) ? '-' : '+', + _abs64( nt->secs ), + _abs64( nt->nano_secs ) ); return n; } // snprint_nano_time_64 diff --git a/mbglib/common/use_pack.h b/mbglib/common/use_pack.h index 5edcdfe..4da7bec 100644 --- a/mbglib/common/use_pack.h +++ b/mbglib/common/use_pack.h @@ -1,17 +1,19 @@ /************************************************************************** * - * $Id: use_pack.h 1.5 2012/10/12 12:40:01 martin REL_M $ + * $Id: use_pack.h 1.6 2022/10/13 16:02:51 martin.burnicki REL_M $ * * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany * * Description: - * Check the current compiler type to decide if pragma pack() is + * Check the current compiler type to decide if pragma pack() is * required to pack cross-platform data structures. * * ----------------------------------------------------------------------- * $Log: use_pack.h $ - * Revision 1.5 2012/10/12 12:40:01 martin + * Revision 1.6 2022/10/13 16:02:51 martin.burnicki + * Removed tabs and trailing spaces. + * Revision 1.5 2012/10/12 12:40:01Z martin * Removed temporary changes. * Revision 1.4 2012/10/02 18:06:25 martin * Temporary changes to test alignment under Linux/Sparc. |