All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Prendel <andre.prendel@gmx.de>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH v3 7/8] sensord: Evaluate return value of
Date: Tue, 03 Nov 2009 20:03:43 +0000	[thread overview]
Message-ID: <20091103200343.GI4724@ubuntu> (raw)

Evaluate return value of idChip().

Some of the functions called from idChip() can fail which means
idChip() can return an error. Callers of idChip() should be aware of
this.
---
 prog/sensord/sense.c |   24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

Index: sensors/prog/sensord/sense.c
=================================--- sensors.orig/prog/sensord/sense.c	2009-11-03 20:20:10.000000000 +0100
+++ sensors/prog/sensord/sense.c	2009-11-03 20:28:44.000000000 +0100
@@ -45,12 +45,23 @@
 
 static int idChip(const sensors_chip_name *chip)
 {
-	const char *adapter;
+	const char *name, *adapter;
+
+	name = chipName(chip);
+	if (!name) {
+		sensorLog(LOG_ERR, "Error getting chip name");
+		return -1;
+	}
+
+	sensorLog(LOG_INFO, "Chip: %s", name);
 
-	sensorLog(LOG_INFO, "Chip: %s", chipName(chip));
 	adapter = sensors_get_adapter_name(&chip->bus);
-	if (adapter)
-		sensorLog(LOG_INFO, "Adapter: %s", adapter);
+	if (!adapter) {
+		sensorLog(LOG_ERR, "Error getting adapter name");
+		return -1;
+	}
+
+	sensorLog(LOG_INFO, "Adapter: %s", adapter);
 
 	return 0;
 }
@@ -151,8 +162,11 @@
 	const FeatureDescriptor *features = descriptor->features;
 	int i, ret = 0;
 
-	if (action = DO_READ)
+	if (action = DO_READ) {
 		ret = idChip(chip);
+		if (ret)
+			return ret;
+	}
 
 	for (i = 0; features[i].format; i++) {
 		ret = do_features(chip, features + i, action);

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

             reply	other threads:[~2009-11-03 20:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-03 20:03 Andre Prendel [this message]
2009-11-04  9:09 ` [lm-sensors] [PATCH v3 7/8] sensord: Evaluate return value of Jean Delvare

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=20091103200343.GI4724@ubuntu \
    --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.