]> git.itanic.dy.fi Git - rrdd/commitdiff
script_parser: Fix fread to return number of bytes read
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 27 Jun 2012 19:00:50 +0000 (22:00 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 27 Jun 2012 19:43:07 +0000 (22:43 +0300)
From fread man page:

The function fread() reads nmemb elements of data, each size bytes
long, from the stream pointed to by stream, storing them at the
location given by ptr.

If size is something else than 1, the return value is not number of
bytes read. The intention here is to have it return number of bytes so
that the debug print can print it correctly.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
parser.c

index 47c0650e97d6f492e1bf40417cf5e1c764803b98..bffe3377b3d2083af3727a691814a9fb548454d0 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -170,7 +170,7 @@ int script_parser(char *rrd_data, const char **parser_data)
        char **cmd = tmp;
 
        pid = run_piped_stream(cmd[0], &cmd[1], NULL, &readf, NULL);
-       ret = fread(rrd_data, RRD_DATA_MAX_LEN, 1, readf);
+       ret = fread(rrd_data, 1, RRD_DATA_MAX_LEN, readf);
 
        pr_info("Read %d bytes :%s\n", ret, rrd_data);
        fclose(readf);