]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Cleanup ssize_t, off_t and strtoll() for MSVC
authorWolfgang Stöggl <c72578@yahoo.de>
Sat, 20 Jul 2019 11:20:12 +0000 (13:20 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Wed, 24 Jul 2019 17:13:25 +0000 (19:13 +0200)
MSVC defines the standard type off_t. Remove unneeded off_t typedef.

So far there has been a "typedef size_t ssize_t" in case of _MSC_VER,
which is incorrect because size_t is unsigned and ssize_t signed.
MSVC supports SSIZE_T (in capital letters). It is sufficient to have
the typedef SSIZE_T ssize_t in rrd.h - remove redundant, obsolete code
from rrd_restore.c

The function strtoll() is supported since Visual Studio 2013.

In rrd_resize.c, b_read is ssize_t. Use %zd in fprintf() as format
specifier, because ssize_t is signed.

src/rrd.h
src/rrd_resize.c
src/rrd_restore.c

index f6fe84e3569b1ecbbd85fecac81c5dc93778f310..155cd65eeebb97b1445b17e19685dbd760b470f4 100644 (file)
--- a/src/rrd.h
+++ b/src/rrd.h
@@ -56,17 +56,17 @@ extern    "C" {
 
 #ifndef _WIN32
 #include <unistd.h>     /* for off_t */
-#else
+#endif
+
 #ifdef _MSC_VER
+#include <BaseTsd.h>
+    typedef SSIZE_T ssize_t;
 #ifndef PERLPATCHLEVEL
     typedef int mode_t;
 #endif
+#if _MSC_VER < 1800
 #define strtoll _strtoi64
 #endif
-#ifndef __MINGW32__     /* MinGW-w64 has ssize_t and off_t */
-    typedef size_t ssize_t;
-    typedef long off_t;
-#endif
 #endif
 
 #include <time.h>
index 8d282e8776c83c9d5c9b6e775d393609493a4daa..44c1ee570772ede82a390bf540b7f1a61f98a944 100644 (file)
@@ -255,7 +255,7 @@ int rrd_resize(
         if ((b_read=rrd_read(rrd_file, &buffer, sizeof(rrd_value_t) * 1)) <= 0)
             break;
         if(rrd_out_file->pos+b_read > rrd_out_file->file_len) {
-            fprintf(stderr,"WARNING: ignoring last %zu bytes\nWARNING: if you see this message multiple times for a single file you're in trouble\n", b_read);
+            fprintf(stderr,"WARNING: ignoring last %zd bytes\nWARNING: if you see this message multiple times for a single file you're in trouble\n", b_read);
             continue;
         }
         rrd_write(rrd_out_file, &buffer, b_read);
index a931dccd61c07c4f4017fee17a13a3dd5f71139c..14b9446b9d6ba2026c7fdbf173d08232906a8a5b 100644 (file)
 
 #ifndef _WIN32
 #      include <unistd.h>     /* for off_t */
-#else
-#ifndef __MINGW32__     /* MinGW-w64 has ssize_t and off_t */
-       typedef size_t ssize_t;
-       typedef long off_t;
-#endif
 #endif
 
 #include <fcntl.h>