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 5/7] sensord: Coding style conversion (gnu ->
Date: Mon, 09 Mar 2009 08:45:59 +0000	[thread overview]
Message-ID: <20090309084559.GF4636@ubuntu> (raw)

Fix coding style in sense.c

---
 prog/sensord/sense.c |  399 ++++++++++++++++++++++++++-------------------------
 1 file changed, 207 insertions(+), 192 deletions(-)

--- quilt-sensors.orig/prog/sensord/sense.c	2009-03-07 22:49:58.000000000 +0100
+++ quilt-sensors/prog/sensord/sense.c	2009-03-07 23:07:17.000000000 +0100
@@ -34,202 +34,217 @@
 #define DO_SET 2
 #define DO_RRD 3
 
-static const char *
-chipName
-(const sensors_chip_name *chip) {
-  static char buffer[256];
-  if (sensors_snprintf_chip_name(buffer, 256, chip) < 0)
-    return NULL;
-  return buffer;
-}
-
-static int
-idChip
-(const sensors_chip_name *chip) {
-  const char *adapter;
-
-  sensorLog (LOG_INFO, "Chip: %s", chipName (chip));
-  adapter = sensors_get_adapter_name (&chip->bus);
-  if (adapter)
-    sensorLog (LOG_INFO, "Adapter: %s", adapter);
-  
-  return 0;
-}
-
-static int
-doKnownChip
-(const sensors_chip_name *chip, const ChipDescriptor *descriptor, int action) {
-  const FeatureDescriptor *features = descriptor->features;
-  int index0, subindex;
-  int ret = 0;
-  double tmp;
-
-  if (action = DO_READ)
-    ret = idChip (chip);
-  for (index0 = 0; (ret = 0) && features[index0].format; ++ index0) {
-    const FeatureDescriptor *feature = features + index0;
-    int alarm, beep;
-    char *label = NULL;
-
-    if (!(label = sensors_get_label (chip, feature->feature))) {
-      sensorLog (LOG_ERR, "Error getting sensor label: %s/%s", chip->prefix, feature->feature->name);
-      ret = 22;
-    } else {
-      double values[MAX_DATA];
-
-      alarm = 0;
-      if (!ret && feature->alarmNumber != -1) {
-        if ((ret = sensors_get_value (chip, feature->alarmNumber, &tmp))) {
-          sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->alarmNumber, sensors_strerror (ret));
-          ret = 20;
-        } else {
-          alarm = (int) (tmp + 0.5);
-        }
-      }
-      if ((action = DO_SCAN) && !alarm)
-        continue;
-
-      beep = 0;
-      if (!ret && feature->beepNumber != -1) {
-        if ((ret = sensors_get_value (chip, feature->beepNumber, &tmp))) {
-          sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->beepNumber, sensors_strerror (ret));
-          ret = 21;
-        } else {
-          beep = (int) (tmp + 0.5);
-        }
-      }
-
-      for (subindex = 0; !ret && (feature->dataNumbers[subindex] >= 0); ++ subindex) {
-        if ((ret = sensors_get_value (chip, feature->dataNumbers[subindex], values + subindex))) {
-          sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->dataNumbers[subindex], sensors_strerror (ret));
-          ret = 23;
-        }
-      }
-      if (ret = 0) {
-        if (action = DO_RRD) { // arse = "N:"
-          if (feature->rrd) {
-            const char *rrded = feature->rrd (values);
-            strcat (strcat (rrdBuff, ":"), rrded ? rrded : "U");
-          }
-        } else {
-          const char *formatted = feature->format (values, alarm, beep);
-          if (formatted) {
-            if (action = DO_READ) {
-              sensorLog (LOG_INFO, "  %s: %s", label, formatted);
-            } else {
-              sensorLog (LOG_ALERT, "Sensor alarm: Chip %s: %s: %s", chipName (chip), label, formatted);
-            }
-          }
-        }
-      }
-    }
-    if (label)
-      free (label);
-  }
-  return ret;
-}
-
-static int
-setChip
-(const sensors_chip_name *chip) {
-  int ret = 0;
-  if ((ret = idChip (chip))) {
-    sensorLog (LOG_ERR, "Error identifying chip: %s", chip->prefix);
-  } else if ((ret = sensors_do_chip_sets (chip))) {
-    sensorLog (LOG_ERR, "Error performing chip sets: %s: %s", chip->prefix, sensors_strerror (ret));
-    ret = 50;
-  } else {
-    sensorLog (LOG_INFO, "Set.");
-  }
-  return ret;
-}
-
-static int
-doChip
-(const sensors_chip_name *chip, int action) {
-  int ret = 0;
-  if (action = DO_SET) {
-    ret = setChip (chip);
-  } else {
-    int index0, chipindex = -1;
-    for (index0 = 0; knownChips[index0].features; ++ index0)
-      /* Trick: we compare addresses here. We know it works because both
-         pointers were returned by sensors_get_detected_chips(), so they
-         refer to libsensors internal structures, which do not move. */
-      if (knownChips[index0].name = chip) {
-        chipindex = index0;
-        break;
-      }
-    if (chipindex >= 0)
-      ret = doKnownChip (chip, &knownChips[chipindex], action);
-  }
-  return ret;
-}
-
-static int
-doChips
-(int action) {
-  const sensors_chip_name *chip;
-  int i, j, ret = 0;
-
-  for (j = 0; (ret = 0) && (j < numChipNames); ++ j) {
-    i = 0;
-    while ((ret = 0) && ((chip = sensors_get_detected_chips (&chipNames[j], &i)) != NULL)) {
-      ret = doChip (chip, action);
-    }
-  }
-
-  return ret;
-}
-
-int
-readChips
-(void) {
-  int ret = 0;
-
-  sensorLog (LOG_DEBUG, "sensor read started");
-  ret = doChips (DO_READ);
-  sensorLog (LOG_DEBUG, "sensor read finished");
-
-  return ret;
-}
-
-int
-scanChips
-(void) {
-  int ret = 0;
-
-  sensorLog (LOG_DEBUG, "sensor sweep started"); /* only logged in debug mode */
-  ret = doChips (DO_SCAN);
-  sensorLog (LOG_DEBUG, "sensor sweep finished");
-
-  return ret;
-}
-
-int
-setChips
-(void) {
-  int ret = 0;
-
-  sensorLog (LOG_DEBUG, "sensor set started");
-  ret = doChips (DO_SET);
-  sensorLog (LOG_DEBUG, "sensor set finished");
+static const char *chipName(const sensors_chip_name *chip)
+{
+	static char buffer[256];
+	if (sensors_snprintf_chip_name(buffer, 256, chip) < 0)
+		return NULL;
+	return buffer;
+}
+
+static int idChip(const sensors_chip_name *chip)
+{
+	const char *adapter;
+
+	sensorLog(LOG_INFO, "Chip: %s", chipName (chip));
+	adapter = sensors_get_adapter_name(&chip->bus);
+	if (adapter)
+		sensorLog(LOG_INFO, "Adapter: %s", adapter);
+
+	return 0;
+}
+
+static int doKnownChip(const sensors_chip_name *chip,
+		       const ChipDescriptor *descriptor, int action)
+{
+	const FeatureDescriptor *features = descriptor->features;
+	int index0, subindex;
+	int ret = 0;
+	double tmp;
+
+	if (action = DO_READ)
+		ret = idChip(chip);
+	for (index0 = 0; (ret = 0) && features[index0].format; ++ index0) {
+		const FeatureDescriptor *feature = features + index0;
+		int alarm, beep;
+		char *label = NULL;
+
+		if (!(label = sensors_get_label(chip, feature->feature))) {
+			sensorLog(LOG_ERR,
+				  "Error getting sensor label: %s/%s",
+				  chip->prefix, feature->feature->name);
+			ret = 22;
+		} else {
+			double values[MAX_DATA];
+
+			alarm = 0;
+			if (!ret && feature->alarmNumber != -1) {
+				if ((ret = sensors_get_value(chip,
+							     feature->alarmNumber,
+							     &tmp))) {
+					sensorLog(LOG_ERR,
+						  "Error getting sensor data: %s/#%d: %s",
+						  chip->prefix,
+						  feature->alarmNumber,
+						  sensors_strerror(ret));
+					ret = 20;
+				} else {
+					alarm = (int) (tmp + 0.5);
+				}
+			}
+			if ((action = DO_SCAN) && !alarm)
+				continue;
+
+			beep = 0;
+			if (!ret && feature->beepNumber != -1) {
+				if ((ret = sensors_get_value(chip,
+							     feature->beepNumber,
+							     &tmp))) {
+					sensorLog(LOG_ERR,
+						  "Error getting sensor data: %s/#%d: %s",
+						  chip->prefix,
+						  feature->beepNumber,
+						  sensors_strerror(ret));
+					ret = 21;
+				} else {
+					beep = (int) (tmp + 0.5);
+				}
+			}
+
+			for (subindex = 0; !ret &&
+				     (feature->dataNumbers[subindex] >= 0); ++ subindex) {
+				if ((ret = sensors_get_value(chip, feature->dataNumbers[subindex], values + subindex))) {
+					sensorLog(LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->dataNumbers[subindex], sensors_strerror(ret));
+					ret = 23;
+				}
+			}
+			if (ret = 0) {
+				if (action = DO_RRD) { // arse = "N:"
+					if (feature->rrd) {
+						const char *rrded = feature->rrd (values);
+						strcat(strcat (rrdBuff, ":"),
+						       rrded ? rrded : "U");
+					}
+				} else {
+					const char *formatted = feature->format (values, alarm, beep);
+					if (formatted) {
+						if (action = DO_READ) {
+							sensorLog(LOG_INFO, "  %s: %s", label, formatted);
+						} else {
+							sensorLog(LOG_ALERT, "Sensor alarm: Chip %s: %s: %s", chipName(chip), label, formatted);
+						}
+					}
+				}
+			}
+		}
+		if (label)
+			free(label);
+	}
+	return ret;
+}
+
+static int setChip(const sensors_chip_name *chip)
+{
+	int ret = 0;
+	if ((ret = idChip(chip))) {
+		sensorLog(LOG_ERR, "Error identifying chip: %s",
+			  chip->prefix);
+	} else if ((ret = sensors_do_chip_sets(chip))) {
+		sensorLog(LOG_ERR, "Error performing chip sets: %s: %s",
+			  chip->prefix, sensors_strerror(ret));
+		ret = 50;
+	} else {
+		sensorLog(LOG_INFO, "Set.");
+	}
+	return ret;
+}
+
+static int doChip(const sensors_chip_name *chip, int action)
+{
+	int ret = 0;
+	if (action = DO_SET) {
+		ret = setChip(chip);
+	} else {
+		int index0, chipindex = -1;
+		for (index0 = 0; knownChips[index0].features; ++ index0)
+			/*
+			 * Trick: we compare addresses here. We know it works
+			 * because both pointers were returned by
+			 * sensors_get_detected_chips(), so they refer to
+			 * libsensors internal structures, which do not move.
+			 */
+			if (knownChips[index0].name = chip) {
+				chipindex = index0;
+				break;
+			}
+		if (chipindex >= 0)
+			ret = doKnownChip(chip, &knownChips[chipindex],
+					  action);
+	}
+	return ret;
+}
+
+static int doChips(int action)
+{
+	const sensors_chip_name *chip;
+	int i, j, ret = 0;
+
+	for (j = 0; (ret = 0) && (j < numChipNames); ++ j) {
+		i = 0;
+		while ((ret = 0) &&
+		       ((chip = sensors_get_detected_chips(&chipNames[j], &i))
+			!= NULL)) {
+			ret = doChip(chip, action);
+		}
+	}
+
+	return ret;
+}
+
+int readChips(void)
+{
+	int ret = 0;
+
+	sensorLog(LOG_DEBUG, "sensor read started");
+	ret = doChips(DO_READ);
+	sensorLog(LOG_DEBUG, "sensor read finished");
+
+	return ret;
+}
+
+int scanChips(void)
+{
+	int ret = 0;
+
+	sensorLog(LOG_DEBUG, "sensor sweep started");
+	ret = doChips(DO_SCAN);
+	sensorLog(LOG_DEBUG, "sensor sweep finished");
+
+	return ret;
+}
+
+int setChips(void)
+{
+	int ret = 0;
+
+	sensorLog(LOG_DEBUG, "sensor set started");
+	ret = doChips(DO_SET);
+	sensorLog(LOG_DEBUG, "sensor set finished");
 
-  return ret;
+	return ret;
 }
 
 /* TODO: loadavg entry */
 
-int
-rrdChips
-(void) {
-  int ret = 0;
-
-  strcpy (rrdBuff, "N");
-
-  sensorLog (LOG_DEBUG, "sensor rrd started"); 
-  ret = doChips (DO_RRD);
-  sensorLog (LOG_DEBUG, "sensor rrd finished");
+int rrdChips(void)
+{
+	int ret = 0;
 
-  return ret;
+	strcpy(rrdBuff, "N");
+
+	sensorLog(LOG_DEBUG, "sensor rrd started");
+	ret = doChips(DO_RRD);
+	sensorLog(LOG_DEBUG, "sensor rrd finished");
+
+	return ret;
 }

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

                 reply	other threads:[~2009-03-09  8:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090309084559.GF4636@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.