From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: two patches
Date: Thu, 19 May 2005 06:23:35 +0000 [thread overview]
Message-ID: <20020715003408.7c5513a4.khali@linux-fr.org> (raw)
Hello
Here are two patches for lm_sensors2 I wrote in the train two hours ago.
The first one fixes a (maybe dangerous) bug in libsensors where
read-only features could be written and write-only features could be
read.
The second one simply (re)indents the eeprom section of prog/sensors. I
plan to make modifications on this part soon, and it was hardly readable
the way it was before.
--
Jean "Khali" Delvare
http://www.ensicaen.ismra.fr/~delvare/
-------------- next part --------------
diff -ruN lm_sensors2/lib/access.c lm_sensors2-and/lib/access.c
--- lm_sensors2/lib/access.c Fri Dec 24 23:44:40 1999
+++ lm_sensors2-and/lib/access.c Sun Jul 14 22:06:34 2002
@@ -222,7 +222,7 @@
sensors_lookup_feature_nr(name.prefix,
main_feature->compute_mapping)))
return -SENSORS_ERR_NO_ENTRY;
- if (! (main_feature->mode && SENSORS_MODE_R))
+ if (! (main_feature->mode & SENSORS_MODE_R))
return -SENSORS_ERR_ACCESS;
for (chip = NULL; !expr && (chip = sensors_for_all_config_chips(name,chip));)
for (i = 0; !final_expr && (i < chip->computes_count); i++) {
@@ -265,7 +265,7 @@
sensors_lookup_feature_nr(name.prefix,
main_feature->compute_mapping)))
return -SENSORS_ERR_NO_ENTRY;
- if (! (main_feature->mode && SENSORS_MODE_W))
+ if (! (main_feature->mode & SENSORS_MODE_W))
return -SENSORS_ERR_ACCESS;
for (chip = NULL; !expr && (chip = sensors_for_all_config_chips(name,chip));)
for (i = 0; !final_expr && (i < chip->computes_count); i++)
-------------- next part --------------
diff -ruN lm_sensors2/prog/sensors/chips.c lm_sensors2-indent-eeprom/prog/sensors/chips.c
--- lm_sensors2/prog/sensors/chips.c Fri Jul 12 13:08:06 2002
+++ lm_sensors2-indent-eeprom/prog/sensors/chips.c Sun Jul 14 22:14:30 2002
@@ -2423,46 +2423,45 @@
void print_eeprom(const sensors_chip_name *name)
{
- char *label = NULL;
- double a, b, c, d;
- int valid, i;
+ char *label = NULL;
+ double a, b, c, d;
+ int valid, i;
- if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_TYPE, &label,&valid) &&
- !sensors_get_feature(*name, SENSORS_EEPROM_TYPE, &a)) {
- if (valid) {
- if(((int) a) = 4) {
- print_label(label, 24);
- printf("SDRAM DIMM SPD\n");
- } else if(((int) a) = 7) {
- print_label(label, 24);
- printf("DDR SDRAM DIMM SPD\n");
- } else
- return;
- }
- } else
- printf("ERROR: data 1\n");
- free_the_label(&label);
+ if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_TYPE, &label,&valid) &&
+ !sensors_get_feature(*name, SENSORS_EEPROM_TYPE, &a)) {
+ if (valid) {
+ if(((int) a) = 4) {
+ print_label(label, 24);
+ printf("SDRAM DIMM SPD\n");
+ } else if(((int) a) = 7) {
+ print_label(label, 24);
+ printf("DDR SDRAM DIMM SPD\n");
+ } else
+ return;
+ }
+ } else
+ printf("ERROR: data 1\n");
+ free_the_label(&label);
- if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_ROWADDR, &label,&valid) &&
- !sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) &&
- !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) &&
- !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c) &&
- !sensors_get_feature(*name, SENSORS_EEPROM_BANKS, &d)) {
- if (valid) {
- print_label(label, 24);
- i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17;
- if(i > 0 && i <= 12 && c <= 8 && d <= 8)
- printf("%d\n", (1 << i) * ((int) c) * ((int) d));
- else
-{
- printf("invalid\n");
-printf("%d %d %d %d\n", (int) a, (int) b, (int) c, (int) d);
-}
+ if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_ROWADDR, &label,&valid) &&
+ !sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) &&
+ !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) &&
+ !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c) &&
+ !sensors_get_feature(*name, SENSORS_EEPROM_BANKS, &d)) {
+ if (valid) {
+ print_label(label, 24);
+ i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17;
+ if(i > 0 && i <= 12 && c <= 8 && d <= 8)
+ printf("%d\n", (1 << i) * ((int) c) * ((int) d));
+ else
+ {
+ printf("invalid\n");
+ printf("%d %d %d %d\n", (int) a, (int) b, (int) c, (int) d);
}
- } else
- printf("ERROR: data 2\n");
- free_the_label(&label);
-
+ }
+ } else
+ printf("ERROR: data 2\n");
+ free_the_label(&label);
}
next reply other threads:[~2005-05-19 6:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-19 6:23 Jean Delvare [this message]
2005-05-19 6:23 ` two patches Mark D. Studebaker
-- strict thread matches above, loose matches on Subject: below --
2010-04-16 5:50 Yury G. Kudryashov
2010-04-16 15:28 ` Dan Nicholson
2010-04-16 16:31 ` Kay Sievers
2010-04-16 17:34 ` Dan Nicholson
2010-04-16 17:51 ` Yury G. Kudryashov
2010-04-16 18:03 ` Dan Nicholson
2010-04-16 18:52 ` Yury G. Kudryashov
2010-04-16 18:56 ` Yury G. Kudryashov
2010-04-16 19:01 ` Yury G. Kudryashov
2010-04-16 22:01 ` Dan Nicholson
2010-04-16 22:02 ` Dan Nicholson
2002-04-11 13:22 Two patches Grigory Batalov
2002-04-11 13:33 ` Grigory Batalov
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=20020715003408.7c5513a4.khali@linux-fr.org \
--to=khali@linux-fr.org \
--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.