* [lm-sensors] [PATCH 5/8] sensord: Refactoring of parseChips()
@ 2009-04-06 7:57 Andre Prendel
2009-04-19 8:10 ` Jean Delvare
2009-04-22 7:34 ` Andre Prendel
0 siblings, 2 replies; 3+ messages in thread
From: Andre Prendel @ 2009-04-06 7:57 UTC (permalink / raw)
To: lm-sensors
Did some refactoring in parseChips(). This fixes some deep indentation
levels.
---
args.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
--- quilt-sensors.orig/prog/sensord/args.c 2009-03-24 22:01:55.000000000 +0100
+++ quilt-sensors/prog/sensord/args.c 2009-03-24 22:02:56.000000000 +0100
@@ -279,6 +279,8 @@
int parseChips(int argc, char **argv)
{
+ int i, n = argc - optind, err;
+
if (optind = argc) {
sensord_args.chipNames[0].prefix SENSORS_CHIP_NAME_PREFIX_ANY;
@@ -286,26 +288,25 @@
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] [PATCH 5/8] sensord: Refactoring of parseChips()
2009-04-06 7:57 [lm-sensors] [PATCH 5/8] sensord: Refactoring of parseChips() Andre Prendel
@ 2009-04-19 8:10 ` Jean Delvare
2009-04-22 7:34 ` Andre Prendel
1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2009-04-19 8:10 UTC (permalink / raw)
To: lm-sensors
On Mon, 6 Apr 2009 09:57:33 +0200, Andre Prendel wrote:
> Did some refactoring in parseChips(). This fixes some deep indentation
> levels.
> ---
>
> args.c | 37 +++++++++++++++++++------------------
> 1 file changed, 19 insertions(+), 18 deletions(-)
>
> --- quilt-sensors.orig/prog/sensord/args.c 2009-03-24 22:01:55.000000000 +0100
> +++ quilt-sensors/prog/sensord/args.c 2009-03-24 22:02:56.000000000 +0100
> @@ -279,6 +279,8 @@
>
> int parseChips(int argc, char **argv)
> {
> + int i, n = argc - optind, err;
> +
> if (optind = argc) {
Could be replaced with "if (n = 0)", easier to read.
> sensord_args.chipNames[0].prefix > SENSORS_CHIP_NAME_PREFIX_ANY;
> @@ -286,26 +288,25 @@
> 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) {
While you're here: no space between ++ and 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;
> }
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] [PATCH 5/8] sensord: Refactoring of parseChips()
2009-04-06 7:57 [lm-sensors] [PATCH 5/8] sensord: Refactoring of parseChips() Andre Prendel
2009-04-19 8:10 ` Jean Delvare
@ 2009-04-22 7:34 ` Andre Prendel
1 sibling, 0 replies; 3+ messages in thread
From: Andre Prendel @ 2009-04-22 7:34 UTC (permalink / raw)
To: lm-sensors
On Sun, Apr 19, 2009 at 10:10:26AM +0200, Jean Delvare wrote:
> On Mon, 6 Apr 2009 09:57:33 +0200, Andre Prendel wrote:
> > Did some refactoring in parseChips(). This fixes some deep indentation
> > levels.
> > ---
> >
> > args.c | 37 +++++++++++++++++++------------------
> > 1 file changed, 19 insertions(+), 18 deletions(-)
> >
> > --- quilt-sensors.orig/prog/sensord/args.c 2009-03-24 22:01:55.000000000 +0100
> > +++ quilt-sensors/prog/sensord/args.c 2009-03-24 22:02:56.000000000 +0100
> > @@ -279,6 +279,8 @@
> >
> > int parseChips(int argc, char **argv)
> > {
> > + int i, n = argc - optind, err;
> > +
> > if (optind = argc) {
>
> Could be replaced with "if (n = 0)", easier to read.
I agree. Will be updated in v2.
>
> > sensord_args.chipNames[0].prefix > > SENSORS_CHIP_NAME_PREFIX_ANY;
> > @@ -286,26 +288,25 @@
> > 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) {
>
> While you're here: no space between ++ and i.
Oops, overlooked during the last cleanup :)
>
> > + 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;
> > }
>
>
> --
> Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-04-22 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-06 7:57 [lm-sensors] [PATCH 5/8] sensord: Refactoring of parseChips() Andre Prendel
2009-04-19 8:10 ` Jean Delvare
2009-04-22 7:34 ` Andre Prendel
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.