Wolfgang Stöggl [Tue, 13 Jul 2021 18:23:54 +0000 (20:23 +0200)]
Add escapeJSON() to legend entries
Double quotes in legends are currently not escaped, if JSON imgformat
is used for rrdtool graph. This produces invalid JSON files.
See comment in #409 for further details.
Wolfgang Stöggl [Tue, 29 Jun 2021 19:16:53 +0000 (21:16 +0200)]
Update Windows GitHub Actions
- Update ci-workflow.yml and add GitHub Actions for Windows builds
using MSVC and vcpkg. Both, x64 and x86 builds are part of the CI.
The required vcpkg ports are installed and cached using
lukka/run-vcpkg@v7
- Add release-windows.yml, which enables building Windows binaries of
RRDtool. This GitHub action is run automatically upon new tags and
can be triggered manually. The required .exe and .dll files are
copied using collect_rrdtool_vcpkg_files.bat and deployed by
actions/upload-artifact@v2
- Makefile_vcpkg.msc:
Add include\harfbuzz, which is required for building pango. Fixes: pango-coverage.h(28): fatal error C1083:
Cannot open include file: 'hb.h': No such file or directory
Sven Panne [Mon, 22 Mar 2021 11:55:26 +0000 (12:55 +0100)]
Avoid segfault: Don't read and write into the same buffer.
Using CTX->rrd_error as a source *and* destination buffer at the same time
provokes undefined behavior. In real life you get funny error messages
and/or segfaults within vs(n)printf().
Simple solution: Use a temporary copy of the error message while writing
into it.
Wolfgang Stöggl [Sat, 13 Mar 2021 09:06:06 +0000 (10:06 +0100)]
Switch to pkgconf (MSYS2, MinGW-w64)
The MSYS2 project has switched from pkg-config to pkgconf as default.
For details, see: https://github.com/msys2/MSYS2-packages/pull/2197
Both packages work when building RRDtool for Windows using MSYS2.
- Switch to pkgconf instead of pkg-config
- Update the following files:
.github/workflows/ci-workflow.yml
win32/README-MinGW-w64
- This avoids the following warning in the Windows CI-build:
warning: removing 'mingw-w64-x86_64-pkg-config' from target list
because it conflicts with 'mingw-w64-x86_64-pkgconf'
Simon Arlott [Fri, 11 Dec 2020 18:38:42 +0000 (18:38 +0000)]
Use a separate pango fontmap per thread
Reusing the same fontmap from multiple threads is not safe, despite
the attempts to use a mutex to protect it there are other instances
where it behaves unexpectedly if graphs are created from multiple
threads at the same time, e.g.:
(process:76234): Pango-WARNING **: 11:47:25.823: failed to create cairo scaled font, expect ugly output. the offending font is 'DejaVu Sans Mono 8'
(process:76234): Pango-WARNING **: 11:47:25.823: font_face status is: no error has occurred
(process:76234): Pango-WARNING **: 11:47:25.823: scaled_font status is: invalid matrix (not invertible)
(process:76234): Pango-WARNING **: 11:47:25.823: shaping failure, expect ugly output. shape-engine='PangoFcShapeEngine', font='DejaVu Sans Mono 8', text='Apparent temp (?C)'
This error results in boxes instead of characters on the graph. In the
worst case scenario there are memory management errors that cause GLib
to complain or the process to abort.
Calling pango_cairo_font_map_get_default() multiple times from the same
thread will return the same object, so this satisfies the performance
expectations of reusing it within a single thread. Trying to lock a
mutex for even more pango/cairo function calls is likely to decrease
performance when multiple threads are used concurrently.
Wolfgang Stöggl [Sun, 9 Aug 2020 19:20:02 +0000 (21:20 +0200)]
Add -no-undefined automatically for MinGW-w64
The linker flag -no-undefined is required, when building the dll for
Windows using MinGW-w64. Add -no-undefined to librrd_la_LDFLAGS in
Makefile.am in case of MinGW-w64 builds. This way it is not necessary
anymore to add LDFLAGS=-no-undefined to the make command.
Allow to generate a graph as if the current timezone was UTC (e.g set TZ=UTC).
This allows to easily calculate daily average ranging from midgnight to midnight rather than say the last 24 hours.
Niclas Zeising [Sun, 14 Jun 2020 09:31:33 +0000 (11:31 +0200)]
rrd_open: Ignore EINVAL from posix_fallocate()
ZFS on FreeBSD (at least) does not support posix_fallocate(),
returning EINVAL instead. Ignore this error and continue normally.
Without this change, it is not possible to resize rrd files on ZFS.
Wolfgang Stöggl [Mon, 18 Nov 2019 19:11:47 +0000 (20:11 +0100)]
Use LC_NUMERIC=C for tests
The following tests require dot as decimal separator:
graph1, rpn1, create-with-source-4, dcounter1, vformatter1, pdp-calc1
Set LC_NUMERIC=C, which allows these tests to pass also under locales,
where the decimal separator is not a dot by default:
de_DE, es_ES, fr_FR, nl_NL etc.
From Debian lintian checker:
Each manual page should start with a "NAME" section, which lists the
name and a brief description of the page separated by "\-". The "NAME"
section is parsed by lexgrog and used to generate a database that's
queried by commands like apropos and whatis. This tag indicates that
lexgrog was unable to parse the NAME section of this manual page.
For manual pages that document multiple programs, functions, files, or
other things, the part before "\-" should list each separated by a comma
and a space. Each thing listed must not contain spaces; a man page for a
two-part command like "fs listacl" must use something like "fs_listacl"
in the "NAME" section so that it can be parsed by lexgrog.
Refer to the lexgrog(1) manual page, the groff_man(7) manual page, and
the groff_mdoc(7) manual page for details.
Wolfgang Stöggl [Thu, 26 Sep 2019 07:27:47 +0000 (09:27 +0200)]
Sort and remove duplicate entries in ALL_LIBS
- So far, configure showed e.g. the following at the end:
Libraries: -lgobject-2.0 -lpng -lm -ldbi -lglib-2.0 -lpangocairo-1.0
-lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lcairo -lxml2
The variable ALL_LIBS included duplicates resulting from the configure
process and some double spaces.
- Now, ALL_LIBS is sorted and duplicate entries are removed, e.g.:
Libraries: -lcairo -ldbi -lglib-2.0 -lgobject-2.0 -lharfbuzz -lm
-lpango-1.0 -lpangocairo-1.0 -lpng -lxml2
Wolfgang Stöggl [Sun, 8 Sep 2019 13:19:09 +0000 (15:19 +0200)]
Remove duplicate code of find_first_weekday()
So far, the same code of find_first_weekday() was used in rrd_graph.c
and rrd_rpncalc.c
Remove duplicate code from rrd_graph.c and add find_first_weekday()
to rrd_rpncalc.h, which is included from rrd_graph.h
Wolfgang Stöggl [Tue, 10 Sep 2019 10:07:14 +0000 (12:07 +0200)]
Use DefaultPlatformToolset for .vcxproj files
- Use $(DefaultPlatformToolset) for the PlatformToolset
instead of v140. This allows to use the associated PlatformToolset
automatically for each version of Visual Studio:
v140 for VS2015, v141 for VS2017, v142 for VS2019.
However, a developer can easily target projects to a desired,
different PlatformToolset.
- Set ToolsVersion="Current" instead of ToolsVersion="14.0"
- Strings were replaced in .vcxproj files the following way:
git grep -l 'v140' -- '*.vcxproj' | \
xargs sed -i 's/v140/$(DefaultPlatformToolset)/g'
git grep -l '14.0' -- '*.vcxproj' | xargs sed -i 's/14.0/Current/g'
Wolfgang Stöggl [Sat, 7 Sep 2019 20:27:22 +0000 (22:27 +0200)]
Use temp pointer for realloc()
- Fixes the following Cppcheck 1.89 errors:
[src/rrd_cgi.c:295] (error) Common realloc mistake:'varheap'
nulled but not freed upon failure [memleakOnRealloc]
[src/rrd_cgi.c:1138] (error) Common realloc mistake: 'argv'
nulled but not freed upon failure [memleakOnRealloc]
[src/rrd_graph.c:1211] (error) Common realloc mistake: 'steparray'
nulled but not freed upon failure [memleakOnRealloc]
In rrd_client_last and rrd_client_first, the response value is in the
message prior to any additional lines. Unfortunately, the buffer that
contains this data is on the stack for response_read and is no longer valid
by the time the caller sees it.
This change strdups the message line in response_read and subsequently frees
it in response_free.
Wolfgang Stöggl [Mon, 2 Sep 2019 10:20:54 +0000 (12:20 +0200)]
Clean tests/rpn1.out
- There was another leftover in the tests folder after
make clean: rpn1.out
It is a png file created during the test rpn1
- This is a followup commit to PR #1049
Clar Fon [Sun, 25 Aug 2019 23:18:47 +0000 (19:18 -0400)]
Zero wbuf on start.
It turns out that calloc isn't enough, because listen_fds is copied to the socket array on start. This zeroes these fields out when the socket is opened.
Wolfgang Stöggl [Thu, 22 Aug 2019 12:18:35 +0000 (14:18 +0200)]
Fix compiler warning (-Wstringop-truncation)
- Use strncat() the following way in rrd_cgi.c:
strncat(dest, src, dest_size - strlen(dest) - 1);
- Fixes the following gcc compiler warning:
rrd_cgi.c:1407:21: warning: ‘strncat’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Wstringop-truncation]
strncat(line, tmp, tmplen);
Wolfgang Stöggl [Wed, 21 Aug 2019 15:50:09 +0000 (17:50 +0200)]
Fix compiler warnings (-Wcast-function-type)
- Add tree_compare_func() and use this function instead of
`(GCompareDataFunc) strcmp`
Fixes the following gcc compiler warning:
rrd_daemon.c:4245:34: warning: cast between incompatible function
types from ‘int (*)(const char *, const char *)’
to ‘gint (*)(const void *, const void *, void *)’
{aka ‘int (*)(const void *, const void *, void *)’}
[-Wcast-function-type]
cache_tree = g_tree_new_full((GCompareDataFunc) strcmp, NULL, NULL,
- Use g_strcmp0() instead of strcmp() in tree_compare_func().
g_strcmp0() compares str1 and str2 like strcmp(). Handles NULL
gracefully by sorting it before non-NULL strings.
Comparing two NULL pointers returns 0.
- Cast free_cache_item using (void (*)(void)
Fixes the following gcc compiler warning:
rrd_daemon.c:4246:34: warning: cast between incompatible function
types from ‘void * (*)(cache_item_t *)’
{aka ‘void * (*)(struct cache_item_s *)’}
to ‘void (*)(void *)’ [-Wcast-function-type]
(GDestroyNotify) free_cache_item);
Wolfgang Stöggl [Fri, 2 Aug 2019 17:00:10 +0000 (19:00 +0200)]
Update .travis.yml for Ubuntu xenial (16.04LTS)
- Install libtool-bin to fix failing "valgrind-logfile" tests
- Enable the following "valgrind-logfile" tests, which are passing now
under xenial: create-with-source-4, vformatter1
Add also graph1 and pdp-calc1, which have been added in the meantime.
There are only three failing tests left: rpn1, rpn2, xport1
- Add Perl 5.22, which is the version in xenial
Wolfgang Stöggl [Sat, 20 Jul 2019 11:20:12 +0000 (13:20 +0200)]
Cleanup ssize_t, off_t and strtoll() for MSVC
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.
Wolfgang Stöggl [Wed, 17 Jul 2019 10:36:30 +0000 (12:36 +0200)]
Fix rrd_cgi.c Cppcheck_warnings
Remove the identical inner 'if' condition.
Use the %zu format specifier for size_t returned from strlen(),
according to: https://en.cppreference.com/w/c/string/byte/strlen
- Fixes the following Cppcheck warnings:
[src/rrd_cgi.c:349] (warning) Identical inner 'if' condition is
always true (outer condition is 'calcpr[i]' and inner condition is
'calcpr[i]'). [identicalInnerCondition]
[src/rrd_cgi.c:527] (portability) %zd in format string (no. 1)
requires 'ssize_t' but the argument type is 'size_t
{aka unsigned long}'. [invalidPrintfArgType_sint]
or
[src/rrd_cgi.c:527] (portability) %zd in format string (no. 1)
requires 'ssize_t' but the argument type is 'size_t
{aka unsigned long long}'. [invalidPrintfArgType_sint]
Wolfgang Stöggl [Mon, 15 Jul 2019 13:09:06 +0000 (15:09 +0200)]
Fix format specifiers
- Fixes the following Cppcheck warnings:
[bindings/tcl/tclrrd.c:513] (warning) %lu in format string (no. 1)
requires 'unsigned long' but the argument type is 'signed long'.
[invalidPrintfArgType_uint]
[src/rrd_fetch_libdbi.c:56] (warning) %i in format string (no. 3)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:63] (warning) %i in format string (no. 3)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:85] (warning) %i in format string (no. 3)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:85] (warning) %i in format string (no. 4)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:119] (warning) %i in format string (no. 3)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:126] (warning) %i in format string (no. 3)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:148] (warning) %i in format string (no. 3)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_fetch_libdbi.c:148] (warning) %i in format string (no. 4)
requires 'int' but the argument type is 'unsigned int'.
[invalidPrintfArgType_sint]
[src/rrd_graph_helper.c:1504] (warning) %u in format string (no. 2)
requires 'unsigned int' but the argument type is 'signed int'.
[invalidPrintfArgType_uint]
[src/rrd_graph_helper.c:1511] (warning) %u in format string (no. 2)
requires 'unsigned int' but the argument type is 'signed int'.
[invalidPrintfArgType_uint]
[src/rrd_graph_helper.c:1695] (warning) %u in format string (no. 1)
requires 'unsigned int' but the argument type is 'signed int'.
[invalidPrintfArgType_uint]
[src/rrd_graph_helper.c:1812] (warning) %u in format string (no. 2)
requires 'unsigned int' but the argument type is 'signed int'.
[invalidPrintfArgType_uint]
[src/rrd_tune.c:392] (warning) %ld in format string (no. 3)
requires 'long' but the argument type is 'unsigned long'.
[invalidPrintfArgType_sint]
Wolfgang Stöggl [Thu, 11 Jul 2019 13:00:09 +0000 (15:00 +0200)]
Use temp pointer for realloc()
If realloc() fails, it returns NULL and the original block is
left untouched; it is not freed. Use a temporary pointer first to
check, if realloc() has failed.
- Fixes the following Cppcheck errors:
[src/rrd_create.c:958] (error) Common realloc mistake: 'mappings'
nulled but not freed upon failure [memleakOnRealloc]
[src/rrd_create.c:2451] (error) Common realloc mistake: 'candidates'
nulled but not freed upon failure [memleakOnRealloc]
[src/rrd_daemon.c:2402] (error) Common realloc mistake: 'sources'
nulled but not freed upon failure [memleakOnRealloc]
Wolfgang Stöggl [Thu, 11 Jul 2019 09:46:15 +0000 (11:46 +0200)]
Add Bear compilation database file to .gitignore
- Add compile_commands.json to .gitignore. This compilation database
file can be created by Build EAR
(BEAR, https://github.com/rizsotto/Bear) and used by Cppcheck
Wolfgang Stöggl [Tue, 9 Jul 2019 09:24:42 +0000 (11:24 +0200)]
Update MSVC .vcxproj files (SAFESH, IntDir)
Win32 Debug configurations have EditAndContinue set, whereas /SAFESEH
is incompatible with EditAndContinue. Add
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
to these configurations.
- Fixes the following warning in Visual Studio build log files, e.g.:
warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/SAFESEH' specification
The projects librrd-8, rrdcgi, rrdtool and rrdupdate are built in
the same directory, which is OK, as there is no overlap. No need for a
separate IntDir for each project. To silence the warning, add:
<IntDirSharingDetected>None</IntDirSharingDetected>
- Fixes the following warning in Visual Studio build log files, e.g.:
warning MSB8028: The intermediate directory (Debug\) contains files
shared from another project (librrd-8.vcxproj).
This can lead to incorrect clean and rebuild behavior.
Wolfgang Stöggl [Mon, 8 Jul 2019 12:06:28 +0000 (14:06 +0200)]
Fix identical inner if condition rrd_graph_helper
- Fixes the following Cppcheck warning:
[src/rrd_graph_helper.c:972] (warning) Identical inner 'if' condition
is always true
(outer condition is '!vname' and inner condition is '!vname').
[identicalInnerCondition]
Wolfgang Stöggl [Sat, 6 Jul 2019 03:45:20 +0000 (05:45 +0200)]
Include asprintf.h in rrd_info.c for MSVC builds
- Fixes the following MSVC level 3 compiler warning:
rrd_info.c(21): warning C4013: 'vasprintf' undefined;
assuming extern returning int
- This is a follow-up to PR #828 and commit b1bcbca
Wolfgang Stöggl [Thu, 27 Jun 2019 19:35:40 +0000 (21:35 +0200)]
Add rrdcgi.vcxproj and update Makefile.am (MSVC)
So far, rrdcgi.exe has been built using nmake. Add rrdcgi.vcxproj
as an additional Visual Studio project and add it to rrd.sln
- Update Makefile.am:
Add win32/rrdcgi.vcxproj and win32/Makefile_vcpkg.msc to EXTRA_DIST
Remove win32/rrdtool.sln and win32/rrdupdate.sln, because all
projects are part of rrd.sln
- git rm win32/rrdtool.sln win32/rrdupdate.sln