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 v2 4/7] sensord: Refactoring of parseChips()
Date: Mon, 11 May 2009 16:04:01 +0000	[thread overview]
Message-ID: <20090511160401.GE17530@ubuntu> (raw)

Did some refactoring in parseChips(). This fixes some deep indentation
levels.

Changes in v2:

Make condition (are there chips arguments?) easier to read.
Removed withspace (coding style).
---

 args.c |   39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

Index: quilt-sensors/prog/sensord/args.c
=================================--- quilt-sensors.orig/prog/sensord/args.c	2009-04-26 21:19:41.000000000 +0200
+++ quilt-sensors/prog/sensord/args.c	2009-04-26 21:21:49.000000000 +0200
@@ -231,33 +231,34 @@
 
 int parseChips(int argc, char **argv)
 {
-	if (optind = argc) {
+	int i, n = argc - optind, err;
+
+	if (n = 0) {
 		sensord_args.chipNames[0].prefix  			SENSORS_CHIP_NAME_PREFIX_ANY;
 		sensord_args.chipNames[0].bus.type = SENSORS_BUS_TYPE_ANY;
 		sensord_args.chipNames[0].bus.nr = SENSORS_BUS_NR_ANY;
 		sensord_args.chipNames[0].addr = SENSORS_CHIP_NAME_ADDR_ANY;
 		sensord_args.numChipNames = 1;
-	} else {
-		int i, n = argc - optind, err;
-		if (n > MAX_CHIP_NAMES) {
-			fprintf(stderr, "Too many chip names.\n");
-			return -1;
-		}
-		for (i = 0; i < n; ++ i) {
-			char *arg = argv[optind + i];
 
-			err = sensors_parse_chip_name(arg,
-						      sensord_args.chipNames +
-						      i);
-			if (err) {
-				fprintf(stderr,
-					"Invalid chip name `%s': %s\n", arg,
-					sensors_strerror(err));
-				return -1;
-			}
+		return 0;
+	}
+
+	if (n > MAX_CHIP_NAMES) {
+		fprintf(stderr, "Too many chip names.\n");
+		return -1;
+	}
+	for (i = 0; i < n; ++i) {
+		char *arg = argv[optind + i];
+
+		err = sensors_parse_chip_name(arg, sensord_args.chipNames + i);
+		if (err) {
+			fprintf(stderr,	"Invalid chip name `%s': %s\n", arg,
+				sensors_strerror(err));
+			return -1;
 		}
-		sensord_args.numChipNames = n;
 	}
+	sensord_args.numChipNames = n;
+
 	return 0;
 }

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

             reply	other threads:[~2009-05-11 16:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 16:04 Andre Prendel [this message]
2009-05-12 16:30 ` [lm-sensors] [PATCH v2 4/7] sensord: Refactoring of parseChips() 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=20090511160401.GE17530@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.