From: Andre Prendel <andre.prendel@gmx.de>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] 3.1.2 sensord duplicate RRD name problem
Date: Thu, 06 May 2010 19:42:30 +0000 [thread overview]
Message-ID: <20100506194230.GA2062@andre-laptop> (raw)
In-Reply-To: <25a99abe1003040437t333b4007k76850b406911925d@mail.gmail.com>
On Thu, May 06, 2010 at 06:12:52PM +0200, Jean Delvare wrote:
> On Thu, 6 May 2010 14:20:56 +0200, Jean Delvare wrote:
> > I have a patch ready, I'll give it some testing to make sure I got it
> > right, and then I'll post it here.
>
> Andre, can you please comment on the patch below? Sergey, any chance
> you could test it? It works for me on two different machines, but I may
> not have covered all possible cases.
Jean, the patch works for me with two sensor chips :)
So I think it's enough for the moment. I've just realised that the code is
still difficult to read. I hope we will find some time for more
simplification/cleanups.
> ---
> prog/sensord/rrd.c | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
> --- lm-sensors.orig/prog/sensord/rrd.c 2009-11-05 10:18:11.000000000 +0100
> +++ lm-sensors/prog/sensord/rrd.c 2010-05-06 17:54:06.000000000 +0200
> @@ -137,9 +137,11 @@ static void rrdCheckLabel(const char *ra
> }
> }
>
> +/* Returns the number of features processed, or -1 on error */
> static int _applyToFeatures(FeatureFN fn, void *data,
> const sensors_chip_name *chip,
> - const ChipDescriptor *desc)
> + const ChipDescriptor *desc,
> + int labelOffset)
> {
> int i;
> const FeatureDescriptor *features = desc->features;
> @@ -147,7 +149,7 @@ static int _applyToFeatures(FeatureFN fn
> const char *rawLabel;
> char *label;
>
> - for (i = 0; i < MAX_RRD_SENSORS && features[i].format; ++i) {
> + for (i = 0; labelOffset + i < MAX_RRD_SENSORS && features[i].format; ++i) {
> feature = features + i;
> rawLabel = feature->feature->name;
>
> @@ -158,11 +160,11 @@ static int _applyToFeatures(FeatureFN fn
> return -1;
> }
>
> - rrdCheckLabel(rawLabel, i);
> - fn(data, rrdLabels[i], label, feature);
> + rrdCheckLabel(rawLabel, labelOffset + i);
> + fn(data, rrdLabels[labelOffset + i], label, feature);
> free(label);
> }
> - return 0;
> + return i;
> }
>
> static ChipDescriptor *lookup_known_chips(const sensors_chip_name *chip)
> @@ -184,7 +186,7 @@ static ChipDescriptor *lookup_known_chip
>
> static int applyToFeatures(FeatureFN fn, void *data)
> {
> - int i, i_detected, ret;
> + int i, i_detected, ret, labelOffset = 0;
> const sensors_chip_name *chip, *chip_arg;
> ChipDescriptor *desc;
>
> @@ -197,9 +199,10 @@ static int applyToFeatures(FeatureFN fn,
> if (!desc)
> continue;
>
> - ret = _applyToFeatures(fn, data, chip, desc);
> - if (ret)
> + ret = _applyToFeatures(fn, data, chip, desc, labelOffset);
> + if (ret < 0)
> return ret;
> + labelOffset += ret;
> }
> }
> return 0;
>
>
>
> --
> Jean Delvare
Regards,
Andre
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2010-05-06 19:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 12:37 [lm-sensors] 3.1.2 sensord duplicate RRD name problem Sergey Kvachonok
2010-05-06 8:34 ` Jean Delvare
2010-05-06 11:54 ` Andre Prendel
2010-05-06 12:20 ` Jean Delvare
2010-05-06 16:12 ` Jean Delvare
2010-05-06 19:42 ` Andre Prendel [this message]
2010-05-07 12:42 ` Jean Delvare
2010-05-08 18:19 ` Sergey Kvachonok
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100506194230.GA2062@andre-laptop \
--to=andre.prendel@gmx.de \
--cc=lm-sensors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.