]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix compiler warnings, llu lli 64bit (MinGW-w64) 851/head
authorWolfgang Stöggl <c72578@yahoo.de>
Thu, 14 Dec 2017 20:10:11 +0000 (21:10 +0100)
committerWolfgang Stöggl <c72578@yahoo.de>
Thu, 14 Dec 2017 20:10:11 +0000 (21:10 +0100)
- time_t is of type 'long long int', when compiled for 64 bit Windows
  (x86_64-w64-mingw32). Use %10llu instead of %10lu in printf and
  %lli instead of %li in dprintf. Requires __USE_MINGW_ANSI_STDIO 1

- Fixes: rrd_lastupdate.c: In function 'rrd_lastupdate':
  rrd_lastupdate.c:76:18:
  warning: format '%lu' expects argument of type 'long unsigned int',
  but argument 2 has type 'time_t {aka long long int}' [-Wformat=]

- Fixes: rrd_graph_helper.c: In function 'parse_shift':
  rrd_graph_helper.c:1458:13:
  warning: format '%li' expects argument of type 'long int',
  but argument 3 has type 'time_t {aka long long int}' [-Wformat=]
  dprintf("SHIFTBY : %li\n",gdp->shval);

src/rrd_graph_helper.c
src/rrd_lastupdate.c

index df9c494a5de8d839e513e7c3558b29b1e67bfb4d..a02720eef641b1bfeceacbdfc19030e935500ced 100644 (file)
@@ -5,6 +5,10 @@
  *                     this code initially written by Alex van den Bogaerdt
  ****************************************************************************/
 
+#ifdef __MINGW64__
+#define __USE_MINGW_ANSI_STDIO 1    /* for %lli */
+#endif
+
 #include <locale.h>
 #include "rrd_config.h"
 #ifdef HAVE_STDINT_H
@@ -1455,7 +1459,11 @@ static int parse_shift(enum gf_en gf,parsedargs_t* pa,image_desc_t *const im) {
   if (gdp->shidx>=0) {
     dprintf("SHIFTBY : %s (%i)\n",im->gdes[gdp->shidx].vname,gdp->shidx);
   } else {
+#ifdef __MINGW64__
+    dprintf("SHIFTBY : %lli\n",gdp->shval); /* argument 3 has type 'time_t {aka long long int}' */
+#else
     dprintf("SHIFTBY : %li\n",gdp->shval);
+#endif
   }
   dprintf("=================================\n");
   /* and return */
index 7fe3b9377e6c4a342e0f250b26b651e69b42a7dc..4e30878944ad8b890699183f56a14faa326a8f12 100644 (file)
@@ -5,6 +5,10 @@
  * rrd_lastupdate  Get the last datum entered for each DS
  *****************************************************************************/
 
+#ifdef __MINGW64__
+#define __USE_MINGW_ANSI_STDIO 1    /* for %10llu */
+#endif
+
 #include "rrd_tool.h"
 #include "rrd_rpncalc.h"
 #include "rrd_client.h"
@@ -73,7 +77,11 @@ int rrd_lastupdate (int argc, char **argv)
         printf(" %s", ds_names[i]);
     printf ("\n\n");
 
+#ifdef __MINGW64__
+    printf ("%10llu:", last_update);    /* argument 2 has type 'time_t {aka long long int} */
+#else
     printf ("%10lu:", last_update);
+#endif
     for (i = 0; i < ds_count; i++) {
         printf(" %s", last_ds[i]);
         free(last_ds[i]);