1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-26 00:28:25 +00:00

fix segfault for diskiograph

The crux is to split args between those for scan_graph() on one hand and
prepare_diskio_stat() on the other hand. To make the code working with
minimal changes, move the yet optional devicename to the end.

General note on graphs:
- for all graphs there exist the optional arguments for scan_graph()
  which come first and are optional (intended duplicate)
- all other args are object specific, and may be optional as well
This commit is contained in:
Phil Sutter 2008-12-18 15:03:02 +01:00
parent 757983ab56
commit 1a35a68bca
5 changed files with 47 additions and 41 deletions

View File

@ -1,3 +1,7 @@
2008-12-18
* Fix segfault for diskiograph*, note the changed order of arguments
* Fix documentation for all graph objects
2008-12-17
* Make gateway objects also detect routes with missing RTF_GATEWAY flag

35
README
View File

@ -640,8 +640,8 @@ conky(1) conky(1)
$cpu for more info on SMP.
1mcpugraph normal|log (cpu number) (height),(width) (gradient colour 1)0m
1m(gradient colour 2)0m
1mcpugraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi0m
1ment colour 2) (scale) (cpu number)0m
CPU usage graph, with optional colours in hex, minus the #. See
$cpu for more info on SMP. Uses a logarithmic scale (to see
small numbers) when you use "log" instead of "normal".
@ -652,8 +652,8 @@ conky(1) conky(1)
of sda for /dev/sda. Individual partitions are allowed.
1mdiskiograph normal|log (device) (height),(width) (gradient colour 1)0m
1m(gradient colour 2) (scale)0m
1mdiskiograph ("normal"|"log") (height),(width) (gradient colour 1) (gra0m
1mdient colour 2) (scale) (device)0m
Disk IO graph, colours defined in hex, minus the #. If scale is
non-zero, it becomes the scale for the graph. Uses a logarithmic
scale (to see small numbers) when you use "log" instead of "nor
@ -664,8 +664,8 @@ conky(1) conky(1)
Displays current disk IO for reads. Device as in diskio.
1mdiskiograph_read normal|log (device) (height),(width) (gradient colour0m
1m1) (gradient colour 2) (scale)0m
1mdiskiograph_read ("normal"|"log") (height),(width) (gradient colour 1)0m
1m(gradient colour 2) (scale) (device)0m
Disk IO graph for reads, colours defined in hex, minus the #. If
scale is non-zero, it becomes the scale for the graph. Device as
in diskio. Uses a logarithmic scale (to see small numbers) when
@ -676,8 +676,8 @@ conky(1) conky(1)
Displays current disk IO for writes. Device as in diskio.
1mdiskiograph_write normal|log (device) (height),(width) (gradient colour0m
1m1) (gradient colour 2) (scale)0m
1mdiskiograph_write ("normal"|"log") (height),(width) (gradient colour 1)0m
1m(gradient colour 2) (scale) (device)0m
Disk IO graph for writes, colours defined in hex, minus the #.
If scale is non-zero, it becomes the scale for the graph. Device
as in diskio. Uses a logarithmic scale (to see small numbers)
@ -697,8 +697,8 @@ conky(1) conky(1)
Download speed in KiB with one decimal
1mdownspeedgraph normal|log net (height),(width) (gradient colour 1)0m
1m(gradient colour 2) (scale)0m
1mdownspeedgraph ("normal"|"log") (height),(width) (gradient colour 1)0m
1m(gradient colour 2) (scale) (net)0m
Download speed graph, colours defined in hex, minus the #. If
scale is non-zero, it becomes the scale for the graph. Uses a
logarithmic scale (to see small numbers) when you use "log" in
@ -732,7 +732,8 @@ conky(1) conky(1)
bar is currently fixed, but that may change in the future.
1mexecgraph (normal|log) command0m
1mexecgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi0m
1ment colour 2) (scale) command0m
Same as execbar, but graphs values. Uses a logaritmic scale when
the log option is given (to see small numbers). Values still
have to be between 0 and 100.
@ -1033,8 +1034,8 @@ conky(1) conky(1)
5 minutes and 3 for past 15 minutes.
1mloadgraph normal|log (height),(width) (gradient colour 1) (gradient0m
1mcolour 2)0m
1mloadgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi0m
1ment colour 2) (scale)0m
Load1 average graph, similar to xload, with optional colours in
hex, minus the #. Uses a logarithmic scale (to see small num
bers) when you use "log" instead of "normal".
@ -1069,8 +1070,8 @@ conky(1) conky(1)
Bar that shows amount of memory in use
1mmemgraph normal|log (height),(width) (gradient colour 1) (gradient0m
1mcolour 2)0m
1mmemgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi0m
1ment colour 2) (scale)0m
Memory usage graph. Uses a logarithmic scale (to see small num
bers) when you use "log" instead of "normal".
@ -1562,8 +1563,8 @@ conky(1) conky(1)
Upload speed in KiB with one decimal
1mupspeedgraph normal|log net (height),(width) (gradient colour 1) (gra0m
1mdient colour 2) (scale)0m
1mupspeedgraph ("normal"|"log") (height),(width) (gradient colour 1)0m
1m(gradient colour 2) (scale) (net)0m
Upload speed graph, colours defined in hex, minus the #. If
scale is non-zero, it becomes the scale for the graph. Uses a
logarithmic scale (to see small numbers) when you use "log" in

View File

@ -584,7 +584,7 @@ CPU usage in percents. For SMP machines, the CPU number can be provided as an ar
Bar that shows CPU usage, height is bar's height in pixels. See $cpu for more info on SMP.
.TP
\fB\*(T<\fBcpugraph\fR\*(T>\fR \*(T<\fBnormal|log (cpu number) (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
\fB\*(T<\fBcpugraph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (cpu number)\fR\*(T>
CPU usage graph, with optional colours in hex, minus the #. See $cpu for more info on SMP. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -592,7 +592,7 @@ CPU usage graph, with optional colours in hex, minus the #. See $cpu for more in
Displays current disk IO. Device is optional, and takes the form of sda for /dev/sda. Individual partitions are allowed.
.TP
\fB\*(T<\fBdiskiograph\fR\*(T>\fR \*(T<\fBnormal|log (device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
\fB\*(T<\fBdiskiograph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (device)\fR\*(T>
Disk IO graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -600,7 +600,7 @@ Disk IO graph, colours defined in hex, minus the #. If scale is non-zero, it bec
Displays current disk IO for reads. Device as in diskio.
.TP
\fB\*(T<\fBdiskiograph_read\fR\*(T>\fR \*(T<\fBnormal|log (device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
\fB\*(T<\fBdiskiograph_read\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (device)\fR\*(T>
Disk IO graph for reads, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -608,7 +608,7 @@ Disk IO graph for reads, colours defined in hex, minus the #. If scale is non-ze
Displays current disk IO for writes. Device as in diskio.
.TP
\fB\*(T<\fBdiskiograph_write\fR\*(T>\fR \*(T<\fBnormal|log (device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
\fB\*(T<\fBdiskiograph_write\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (device)\fR\*(T>
Disk IO graph for writes, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -624,7 +624,7 @@ Download speed in KiB
Download speed in KiB with one decimal
.TP
\fB\*(T<\fBdownspeedgraph\fR\*(T>\fR \*(T<\fBnormal|log net (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
\fB\*(T<\fBdownspeedgraph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (net)\fR\*(T>
Download speed graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -652,7 +652,7 @@ Executes a shell command and displays the output in conky. warning: this takes a
Same as exec, except if the first value return is a value between 0-100, it will use that number for a bar. The size for the bar is currently fixed, but that may change in the future.
.TP
\fB\*(T<\fBexecgraph\fR\*(T>\fR \*(T<\fB(normal|log) command\fR\*(T>
\fB\*(T<\fBexecgraph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) command\fR\*(T>
Same as execbar, but graphs values. Uses a logaritmic scale when the log option is given (to see small numbers). Values still have to be between 0 and 100.
.TP
@ -874,7 +874,7 @@ The value of /proc/sys/vm/laptop_mode
(1,2,3)> System load average, 1 is for past 1 minute, 2 for past 5 minutes and 3 for past 15 minutes.
.TP
\fB\*(T<\fBloadgraph\fR\*(T>\fR \*(T<\fBnormal|log (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
\fB\*(T<\fBloadgraph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
Load1 average graph, similar to xload, with optional colours in hex, minus the #. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -905,7 +905,7 @@ Amount of memory in use
Bar that shows amount of memory in use
.TP
\fB\*(T<\fBmemgraph\fR\*(T>\fR \*(T<\fBnormal|log (height),(width) (gradient colour 1) (gradient colour 2)\fR\*(T>
\fB\*(T<\fBmemgraph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
Memory usage graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP
@ -1363,7 +1363,7 @@ Upload speed in KiB
Upload speed in KiB with one decimal
.TP
\fB\*(T<\fBupspeedgraph\fR\*(T>\fR \*(T<\fBnormal|log net (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
\fB\*(T<\fBupspeedgraph\fR\*(T>\fR \*(T<\fB("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (net)\fR\*(T>
Upload speed graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
.TP

View File

@ -420,7 +420,7 @@
<varlistentry>
<term>
<command><option>cpugraph</option></command>
<option>normal|log (cpu number) (height),(width) (gradient colour 1) (gradient colour 2)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (cpu number)</option>
</term>
<listitem>
CPU usage graph, with optional colours in hex, minus the #. See $cpu for more info on SMP. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -440,7 +440,7 @@
<varlistentry>
<term>
<command><option>diskiograph</option></command>
<option>normal|log (device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (device)</option>
</term>
<listitem>
Disk IO graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -460,7 +460,7 @@
<varlistentry>
<term>
<command><option>diskiograph_read</option></command>
<option>normal|log (device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (device)</option>
</term>
<listitem>
Disk IO graph for reads, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -480,7 +480,7 @@
<varlistentry>
<term>
<command><option>diskiograph_write</option></command>
<option>normal|log (device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (device)</option>
</term>
<listitem>
Disk IO graph for writes, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -520,7 +520,7 @@
<varlistentry>
<term>
<command><option>downspeedgraph</option></command>
<option>normal|log net (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (net)</option>
</term>
<listitem>
Download speed graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -587,7 +587,7 @@
<varlistentry>
<term>
<command><option>execgraph</option></command>
<option>(normal|log) command</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) command</option>
</term>
<listitem>
Same as execbar, but graphs values. Uses a logaritmic scale when the log option is given (to see small numbers). Values still have to be between 0 and 100.
@ -1123,7 +1123,7 @@
<varlistentry>
<term>
<command><option>loadgraph</option></command>
<option>normal|log (height),(width) (gradient colour 1) (gradient colour 2)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
</term>
<listitem>
Load1 average graph, similar to xload, with optional colours in hex, minus the #. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -1195,7 +1195,7 @@
<varlistentry>
<term>
<command><option>memgraph</option></command>
<option>normal|log (height),(width) (gradient colour 1) (gradient colour 2)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
</term>
<listitem>
Memory usage graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".
@ -2104,7 +2104,7 @@
<varlistentry>
<term>
<command><option>upspeedgraph</option></command>
<option>normal|log net (height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
<option>("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (net)</option>
</term>
<listitem>
Upload speed graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Uses a logarithmic scale (to see small numbers) when you use "log" instead of "normal".

View File

@ -909,6 +909,7 @@ static char *scan_graph(const char *args, int *w, int *h,
*showaslog = FALSE;
nographtype = args;
}
DBGP("printing graph as %s, other args are: %s", (*showaslog ? "log" : "normal"), nographtype);
//check the rest of the args
if (sscanf(nographtype, "%d,%d %x %x %u", h, w, first_colour, last_colour, scale) == 5) {
return NULL;
@ -1892,24 +1893,24 @@ static struct text_object *construct_text_object(const char *s,
END OBJ(diskio_write, INFO_DISKIO)
obj->data.diskio = prepare_diskio_stat(dev_name(arg));
END OBJ(diskiograph, INFO_DISKIO)
char *buf = scan_graph(dev_name(arg), &obj->a, &obj->b, &obj->c, &obj->d,
char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e, &obj->showaslog);
obj->data.diskio = prepare_diskio_stat(buf);
obj->data.diskio = prepare_diskio_stat(dev_name(buf));
if (buf)
free(buf);
END OBJ(diskiograph_read, INFO_DISKIO)
char *buf = scan_graph(dev_name(arg), &obj->a, &obj->b, &obj->c, &obj->d,
char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e, &obj->showaslog);
obj->data.diskio = prepare_diskio_stat(buf);
obj->data.diskio = prepare_diskio_stat(dev_name(buf));
if (buf)
free(buf);
END OBJ(diskiograph_write, INFO_DISKIO)
char *buf = scan_graph(dev_name(arg), &obj->a, &obj->b, &obj->c, &obj->d,
char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e, &obj->showaslog);
obj->data.diskio = prepare_diskio_stat(buf);
obj->data.diskio = prepare_diskio_stat(dev_name(buf));
if (buf)
free(buf);
#endif