All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [Patch] libsensors: Fix wrong behaviour in multiple
@ 2009-02-18  8:20 Andre Prendel
  2009-02-18 10:04 ` [lm-sensors] [Patch] libsensors: Fix wrong behaviour in Jean Delvare
  2009-02-18 11:11 ` Andre Prendel
  0 siblings, 2 replies; 3+ messages in thread
From: Andre Prendel @ 2009-02-18  8:20 UTC (permalink / raw)
  To: lm-sensors

The support for multiple configuration files causes a fatal error if
/etc/sensors.d does not exist.

That shouldn't be treated as an error. This patch fixes that.

--- lm-sensors-dev/lib/init.c	2009-02-16 14:12:50.000000000 +0100
+++ my-sensors/lib/init.c	2009-02-17 23:15:46.000000000 +0100
@@ -124,10 +124,15 @@ static int add_config_from_dir(const cha
 	struct dirent **namelist;
 
 	count = scandir(dir, &namelist, config_file_filter, alphasort);
+	/* Do not return an error if directory does not exist or is empty. */
 	if (count < 0) {
+		if (errno = ENOENT)
+			return 0;
+		
 		sensors_parse_error_wfn(strerror(errno), NULL, 0);
 		return -SENSORS_ERR_PARSE;
-	}
+	} else if (!count)
+		return 0;
 
 	for (res = 0, i = 0; !res && i < count; i++) {
 		int len;

_______________________________________________
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] libsensors: Fix wrong behaviour in
  2009-02-18  8:20 [lm-sensors] [Patch] libsensors: Fix wrong behaviour in multiple Andre Prendel
@ 2009-02-18 10:04 ` Jean Delvare
  2009-02-18 11:11 ` Andre Prendel
  1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2009-02-18 10:04 UTC (permalink / raw)
  To: lm-sensors

Hi Andre,

On Wed, 18 Feb 2009 09:20:08 +0100, Andre Prendel wrote:
> The support for multiple configuration files causes a fatal error if
> /etc/sensors.d does not exist.
> 
> That shouldn't be treated as an error. This patch fixes that.

You are perfectly right, what you propose is how I intended to
implement the thing but apparently there was a loss of signal between
the idea and its implementation.

> --- lm-sensors-dev/lib/init.c	2009-02-16 14:12:50.000000000 +0100
> +++ my-sensors/lib/init.c	2009-02-17 23:15:46.000000000 +0100
> @@ -124,10 +124,15 @@ static int add_config_from_dir(const cha
>  	struct dirent **namelist;
>  
>  	count = scandir(dir, &namelist, config_file_filter, alphasort);
> +	/* Do not return an error if directory does not exist or is empty. */
>  	if (count < 0) {
> +		if (errno = ENOENT)
> +			return 0;
> +		

I'm applying this right now.

>  		sensors_parse_error_wfn(strerror(errno), NULL, 0);
>  		return -SENSORS_ERR_PARSE;
> -	}
> +	} else if (!count)
> +		return 0;

This second test doesn't seem needed, the following code is a no-op if
count = 0, isn't it?

>  
>  	for (res = 0, i = 0; !res && i < count; i++) {
>  		int len;

Thanks for your contribution!

-- 
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] libsensors: Fix wrong behaviour in
  2009-02-18  8:20 [lm-sensors] [Patch] libsensors: Fix wrong behaviour in multiple Andre Prendel
  2009-02-18 10:04 ` [lm-sensors] [Patch] libsensors: Fix wrong behaviour in Jean Delvare
@ 2009-02-18 11:11 ` Andre Prendel
  1 sibling, 0 replies; 3+ messages in thread
From: Andre Prendel @ 2009-02-18 11:11 UTC (permalink / raw)
  To: lm-sensors

On Wed, Feb 18, 2009 at 11:04:12AM +0100, Jean Delvare wrote:
> Hi Andre,

Hi Jean!
> 
> On Wed, 18 Feb 2009 09:20:08 +0100, Andre Prendel wrote:
> > The support for multiple configuration files causes a fatal error if
> > /etc/sensors.d does not exist.
> > 
> > That shouldn't be treated as an error. This patch fixes that.
> 
> You are perfectly right, what you propose is how I intended to
> implement the thing but apparently there was a loss of signal between
> the idea and its implementation.

I know this problem. :)
> 
> > --- lm-sensors-dev/lib/init.c	2009-02-16 14:12:50.000000000 +0100
> > +++ my-sensors/lib/init.c	2009-02-17 23:15:46.000000000 +0100
> > @@ -124,10 +124,15 @@ static int add_config_from_dir(const cha
> >  	struct dirent **namelist;
> >  
> >  	count = scandir(dir, &namelist, config_file_filter, alphasort);
> > +	/* Do not return an error if directory does not exist or is empty. */
> >  	if (count < 0) {
> > +		if (errno = ENOENT)
> > +			return 0;
> > +		
> 
> I'm applying this right now.
> 
> >  		sensors_parse_error_wfn(strerror(errno), NULL, 0);
> >  		return -SENSORS_ERR_PARSE;
> > -	}
> > +	} else if (!count)
> > +		return 0;
> 
> This second test doesn't seem needed, the following code is a no-op if
> count = 0, isn't it?

Yes it is. That's just my programming style. So you see at first view
what will happen if the directory is empty. You have not to examine the loop.

> 
> >  
> >  	for (res = 0, i = 0; !res && i < count; i++) {
> >  		int len;
> 
> Thanks for your contribution!

Thanks
Andre

> 
> -- 
> 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-02-18 11:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-18  8:20 [lm-sensors] [Patch] libsensors: Fix wrong behaviour in multiple Andre Prendel
2009-02-18 10:04 ` [lm-sensors] [Patch] libsensors: Fix wrong behaviour in Jean Delvare
2009-02-18 11:11 ` 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.