summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2023-05-03 18:54:39 +0200
committerMartin Burnicki <martin.burnicki@meinberg.de>2023-05-03 18:54:39 +0200
commit41fe0058cd3529e5b7449c6fc2235812d87a621c (patch)
tree95f344416536e70d62a640512b08ed2417ff59a5
parentc289a41e628e29a64733dab49a6332e88cf99610 (diff)
downloadmbgtools-lx-41fe0058cd3529e5b7449c6fc2235812d87a621c.tar.gz
mbgtools-lx-41fe0058cd3529e5b7449c6fc2235812d87a621c.zip
Update some mbglib files.
This also fixes some compiler warnings.
-rw-r--r--mbglib/common/lan_util.c24
-rw-r--r--mbglib/common/mbg_syn1588_io.c8
-rw-r--r--mbglib/common/mbg_tgt.h20
-rw-r--r--mbglib/common/mbgpccyc.h13
-rw-r--r--mbglib/common/mbgserio.c13
-rw-r--r--mbglib/common/timeutil.h8
6 files changed, 60 insertions, 26 deletions
diff --git a/mbglib/common/lan_util.c b/mbglib/common/lan_util.c
index b6b3ebe..1253e97 100644
--- a/mbglib/common/lan_util.c
+++ b/mbglib/common/lan_util.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: lan_util.c 1.26 2022/12/21 14:54:41 martin.burnicki REL_M $
+ * $Id: lan_util.c 1.28 2023/03/21 16:00:26 kai.heine REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,10 @@
*
* -----------------------------------------------------------------------
* $Log: lan_util.c $
+ * Revision 1.28 2023/03/21 16:00:26 kai.heine
+ * Fixed conversion of double colons in str_to_ip6_addr
+ * Revision 1.27 2023/03/03 14:37:08 kai.heine
+ * Fixed buffer underflow in str_to_ip6_addr in case addr end with colons
* Revision 1.26 2022/12/21 14:54:41 martin.burnicki
* Quieted another potential compiler warning.
* Revision 1.25 2022/12/13 15:25:16 martin.burnicki
@@ -718,8 +722,8 @@ int str_to_ip6_addr( IP6_ADDR *p_addr, const char *s )
if ( p_addr )
memset( p_addr, 0, sizeof( *p_addr ) ); // Set IP address to '::'.
- startp = tmp.b - 1;
- tp = startp + sizeof( tmp );
+ startp = tmp.b;
+ tp = startp + sizeof( tmp ) - 1;
colonp = NULL;
@@ -791,7 +795,7 @@ int str_to_ip6_addr( IP6_ADDR *p_addr, const char *s )
if ( saw_xdigit )
{
- if ( tp - sizeof( uint16_t ) < startp )
+ if ( ( tp - sizeof( uint16_t ) + 1 ) < startp )
return MBG_ERR_PARM_FMT;
*tp-- = (uint8_t) (val >> 8) & 0xff;
@@ -807,19 +811,19 @@ int str_to_ip6_addr( IP6_ADDR *p_addr, const char *s )
const size_t n = colonp - tp;
size_t i;
- if ( tp == startp )
+ if ( ( tp + 1 ) == startp )
return MBG_ERR_PARM_FMT;
- for ( i = 0; i <= n; i++ )
+ for ( i = 0; i < n; i++ )
{
- startp[i] = colonp[i - n];
- colonp[i - n] = 0;
+ startp[i] = colonp[i + 1 - n];
+ colonp[i + 1 - n] = 0;
}
- tp = startp;
+ tp = startp - 1;
}
- if ( tp != startp )
+ if ( ( tp + 1 ) != startp )
return MBG_ERR_PARM_FMT;
if ( p_addr )
diff --git a/mbglib/common/mbg_syn1588_io.c b/mbglib/common/mbg_syn1588_io.c
index 4fbca91..7390e4e 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.12 2023/02/21 10:15:34 martin.burnicki REL_M $
+ * $Id: mbg_syn1588_io.c 1.13 2023/05/03 16:49:27 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,6 +10,8 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_syn1588_io.c $
+ * Revision 1.13 2023/05/03 16:49:27 martin.burnicki
+ * Fixed some format string compiler warnings.
* Revision 1.12 2023/02/21 10:15:34 martin.burnicki
* Fixed a potential compiler warning.
* Revision 1.11 2022/09/07 15:39:06 martin.burnicki
@@ -584,7 +586,7 @@ int snprintf_sernum( char *s, size_t max_len, MBG_DEV_HANDLE dh )
if ( dev_idx == SYN1588_INVALID_DEV_IDX )
{
// Device index could not be determined.
- n = snprintf_safe( s, max_len, str_not_avail );
+ n = snprintf_safe( s, max_len, "%s", str_not_avail );
goto out;
}
@@ -618,7 +620,7 @@ int snprintf_sernum( char *s, size_t max_len, MBG_DEV_HANDLE dh )
}
// Print the serial number.
- n = snprintf_safe( s, max_len, ser_num );
+ n = snprintf_safe( s, max_len, "%s", ser_num );
out:
return n;
diff --git a/mbglib/common/mbg_tgt.h b/mbglib/common/mbg_tgt.h
index 07bdcf8..cdd6706 100644
--- a/mbglib/common/mbg_tgt.h
+++ b/mbglib/common/mbg_tgt.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbg_tgt.h 1.54 2022/09/01 15:46:33 martin.burnicki REL_M $
+ * $Id: mbg_tgt.h 1.56 2023/04/05 15:12:24 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -11,7 +11,11 @@
*
* -----------------------------------------------------------------------
* $Log: mbg_tgt.h $
- * Revision 1.54 2022/09/01 15:46:33 martin.burnicki
+ * Revision 1.56 2023/04/05 15:12:24 martin.burnicki
+ * Changed the VS version for which some warnings are disabled.
+ * Revision 1.55 2023/03/09 15:43:15Z martin.burnicki
+ * Disable some compiler warnings from old VS versions.
+ * Revision 1.54 2022/09/01 15:46:33Z martin.burnicki
* Suppress deprecated function warnings if
* NO_WARN_DEPRECATED is defined.
* Revision 1.53 2022/03/17 16:38:57Z martin.burnicki
@@ -743,6 +747,18 @@ extern "C" {
#define strtoll _strtoi64
#endif
+ #if ( _MSC_VER <= 1600 )
+ // Disable the annoying "conditional expression is constant"
+ // warnings thrown by older VS versions.
+ #pragma warning( disable : 4127 )
+ #endif
+
+ #if ( _MSC_VER <= 1600 )
+ // Disable the annoying "nameless struct/union"
+ // warnings thrown by older VS versions.
+ #pragma warning( disable : 4201 )
+ #endif
+
#elif defined( _CVI_ )
// 1000 for CVI v10.0 (CVI 2010)
diff --git a/mbglib/common/mbgpccyc.h b/mbglib/common/mbgpccyc.h
index 7f0e65e..e8607e3 100644
--- a/mbglib/common/mbgpccyc.h
+++ b/mbglib/common/mbgpccyc.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: mbgpccyc.h 1.9 2021/03/16 12:21:02 martin REL_M $
+ * $Id: mbgpccyc.h 1.10 2023/03/14 10:12:50 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgpccyc.h $
- * Revision 1.9 2021/03/16 12:21:02 martin
+ * Revision 1.10 2023/03/14 10:12:50 martin.burnicki
+ * More detailed description for QPC usage.
+ * Revision 1.9 2021/03/16 12:21:02Z martin
* Updated some comments.
* Revision 1.8 2019/03/18 08:58:39 martin
* Cleanup and comments.
@@ -186,8 +188,11 @@ void mbg_get_pc_cycles( MBG_PC_CYCLES *p )
#if defined( MBG_TGT_KERNEL ) // kernel space
*p = (MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
#else // user space
- // Please note QPC() *may* fail if p points to a variable
- // that is *not* at least 4-byte-aligned.
+ // Unlike documented by Microsoft, this functions *may* fail
+ // e.g. with WIN32 error 998 "Invalid access to memory location"
+ // if p points to a variable that isn't properly aligned.
+ // Alignment should be at least 4-byte for 32 bit applications,
+ // and probably better 8-byte for 64 bit applications.
QueryPerformanceCounter( (LARGE_INTEGER *) p );
#endif
diff --git a/mbglib/common/mbgserio.c b/mbglib/common/mbgserio.c
index c69a775..7285543 100644
--- a/mbglib/common/mbgserio.c
+++ b/mbglib/common/mbgserio.c
@@ -1,7 +1,6 @@
-
/**************************************************************************
*
- * $Id: mbgserio.c 1.11 2021/12/01 10:19:07 martin.burnicki REL_M $
+ * $Id: mbgserio.c 1.12 2023/02/16 07:34:33 gregoire.diehl TRASH $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +9,9 @@
*
* -----------------------------------------------------------------------
* $Log: mbgserio.c $
- * Revision 1.11 2021/12/01 10:19:07 martin.burnicki
+ * Revision 1.12 2023/02/16 07:34:33 gregoire.diehl
+ * Added strdup define for target CVI
+ * Revision 1.11 2021/12/01 10:19:07Z martin.burnicki
* Make a parameter of mbgserio_get_duration_rcv() const.
* Revision 1.10 2021/05/04 20:31:36 martin
* New functions mbgserio_get_rx_fifo_threshold,
@@ -76,6 +77,7 @@
#include <mbgerror.h>
#include <str_util.h>
+#include <mbg_tgt.h>
#include <stdio.h>
#include <ctype.h>
@@ -87,7 +89,10 @@
#include <errno.h>
#endif
-#if defined( MBG_TGT_WIN32 )
+#if defined( MBG_TGT_CVI )
+ #include "toolbox.h"
+ #define strdup StrDup
+#elif defined( MBG_TGT_WIN32 )
#define strdup _strdup
#endif
diff --git a/mbglib/common/timeutil.h b/mbglib/common/timeutil.h
index 96183fb..1fd128a 100644
--- a/mbglib/common/timeutil.h
+++ b/mbglib/common/timeutil.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: timeutil.h 1.16 2021/04/22 08:37:50 martin REL_M $
+ * $Id: timeutil.h 1.17 2023/02/21 12:26:36 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -10,7 +10,9 @@
*
* -----------------------------------------------------------------------
* $Log: timeutil.h $
- * Revision 1.16 2021/04/22 08:37:50 martin
+ * Revision 1.17 2023/02/21 12:26:36 martin.burnicki
+ * Removed trailing spaces.
+ * Revision 1.16 2021/04/22 08:37:50Z martin
* Avoid some compiler warnings.
* Revision 1.15 2021/03/22 11:52:33 martin
* Updated some comments.
@@ -216,7 +218,7 @@ int mbg_cvt_time32_t_to_time64_t( MBG_TIME64_T *p_t64, const MBG_TIME32_T *p_t32
// Avoid warnings "never used".
(void) p_t64;
(void) p_t32;
-
+
#if 0
// time_t should be at least 4 bytes
assert( sizeof( time_t ) >= 4 );