libsensors: Introduce error string - Unknown
PATCH 1/1 libsensors: Introduce error string - Unknown
Hello,
sensors_error() returns NULL if errnum is not valid. Returning "Unknown error" in this case, makes output clearer than:
foo: (null)
and prevents error output/logging from segmentation faults.
What do you think?
Andre
---
lib/error.c +1 -1
@@ -33,7 +33,7 @@ void (*sensors_fatal_error) (const charsensors_default_fatal_error ;static const char *errorlist[] = { -/* Invalid error code */ NULL , +/* Invalid error code */ "Unknown error" ,/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name" ,/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known" ,/* SENSORS_ERR_ACCESS_R */ "Can't read" ,
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [Patch] libsensors: Introduce error string -
Hi Andre,
Quoted 17 lines · Andre Prendel
sensors_error()returns NULL if errnum is not valid. Returning "Unknown error" in this case, makes output clearer than:foo: (null)
and prevents error output/logging from segmentation faults.
What do you think?
Andre
Signed-off-by Andre Prendel <[email protected]>---
lib/error.c void (*sensors_fatal_error) (const char · line 39
Quoted 8 lines
lib/error.c +1
-1@@ -33,7 +33,7 @@ void (*sensors_fatal_error) (const charsensors_default_fatal_error ;static const char *errorlist[] = { -/* Invalid error code */ NULL , +/* Invalid error code */ "Unknown error" ,/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name" ,/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known" ,/* SENSORS_ERR_ACCESS_R */ "Can't read" ,
Out of curiosity: did you actually hit this problem in real life?
I was about to say that the caller was supposed to check for NULL, but apparently neither sensors nor sensord nor even libsensors does, so... I guess you're right, having an error string instead of NULL would be better. Actually that's what libsensors 2.x did, I can't remember why I changed that in 3.x:
http://www.lm-sensors.org/changeset/4854
Probably I thought it was not supposed to happen, but I guess it may actually happen if mixing a recent application with an older version of libsensors.
So I am pretty much inclined to apply your patch.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [Patch] libsensors: Introduce error string
In reply to Andre PrendelQuoted 22 lines · Jean Delvare
Hi Andre,
Quoted 19 lines · Andre Prendel
sensors_error()returns NULL if errnum is not valid. Returning "Unknown error" in this case, makes output clearer than:foo: (null)
and prevents error output/logging from segmentation faults.
What do you think?
Andre
Signed-off-by Andre Prendel <[email protected]>---
lib/error.c +0
-0@@ -33,7 +33,7 @@ void (*sensors_fatal_error) (const char sensors_default_fatal_error;
Quoted 8 lines
lib/error.c void (*sensors_fatal_error) (const char · line 39
Quoted 6 lines
lib/error.c +1
-1static const char *errorlist[] = { -/* Invalid error code */ NULL , +/* Invalid error code */ "Unknown error" ,/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name" ,/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known" ,/* SENSORS_ERR_ACCESS_R */ "Can't read" ,Out of curiosity: did you actually hit this problem in real life?
No, I didn't. It's just theoretical.
Quoted 2 lines
I was about to say that the caller was supposed to check for NULL, but apparently neither sensors nor sensord nor even libsensors does, so...
IMO error reporting should be very stable. If the caller checks return value carefully it's fine too. Fprintf() isn't a problem. But I don't know what about vsnprintf(), syslog().
Quoted 10 lines
I guess you're right, having an error string instead of NULL would be better. Actually that's what libsensors 2.x did, I can't remember why I changed that in 3.x:
http://www.lm-sensors.org/changeset/4854Probably I thought it was not supposed to happen, but I guess it may actually happen if mixing a recent application with an older version of libsensors.
So I am pretty much inclined to apply your patch.
Vous avez le choix. :)
Andre
Quoted 2 lines
Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [Patch] libsensors: Introduce error string -
In reply to Andre PrendelQuoted 46 lines · Andre Prendel
Quoted 22 lines · Jean Delvare
Hi Andre,
Quoted 19 lines · Andre Prendel
sensors_error()returns NULL if errnum is not valid. Returning "Unknown error" in this case, makes output clearer than:foo: (null)
and prevents error output/logging from segmentation faults.
What do you think?
Andre
Signed-off-by Andre Prendel <[email protected]>---
lib/error.c +0
-0@@ -33,7 +33,7 @@ void (*sensors_fatal_error) (const char sensors_default_fatal_error;Quoted 8 lines
lib/error.c void (*sensors_fatal_error) (const char · line 39
Quoted 6 lines
lib/error.c +1
-1static const char *errorlist[] = { -/* Invalid error code */ NULL , +/* Invalid error code */ "Unknown error" ,/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name" ,/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known" ,/* SENSORS_ERR_ACCESS_R */ "Can't read" ,Out of curiosity: did you actually hit this problem in real life?
No, I didn't. It's just theoretical.
Quoted 2 lines
I was about to say that the caller was supposed to check for NULL, but apparently neither sensors nor sensord nor even libsensors does, so...
IMO error reporting should be very stable. If the caller checks return value carefully it's fine too.
Fprintf()isn't a problem. But I don't know what aboutvsnprintf(),syslog().Quoted 5 lines
I guess you're right, having an error string instead of NULL would be better. Actually that's what libsensors 2.x did, I can't remember why I changed that in 3.x:
http://www.lm-sensors.org/changeset/4854
Quoted 7 lines
Quoted 5 lines
Probably I thought it was not supposed to happen, but I guess it may actually happen if mixing a recent application with an older version of libsensors.
So I am pretty much inclined to apply your patch.
Vous avez le choix. :)
Sicherlich :)
Patch applied, thanks. If you intend to contribute to the lm-sensors project again on a regular basis, please let me know, we can create an account for you.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [Patch] libsensors: Introduce error string
In reply to Andre PrendelQuoted 53 lines · Jean Delvare
Quoted 52 lines · Andre Prendel
Quoted 22 lines · Jean Delvare
Hi Andre,
Quoted 19 lines · Andre Prendel
sensors_error()returns NULL if errnum is not valid. Returning "Unknown error" in this case, makes output clearer than:foo: (null)
and prevents error output/logging from segmentation faults.
What do you think?
Andre
Signed-off-by Andre Prendel <[email protected]>---
lib/error.c +0
-0@@ -33,7 +33,7 @@ void (*sensors_fatal_error) (const char sensors_default_fatal_error;Quoted 8 lines
lib/error.c void (*sensors_fatal_error) (const char · line 39
Quoted 6 lines
lib/error.c +1
-1static const char *errorlist[] = { -/* Invalid error code */ NULL , +/* Invalid error code */ "Unknown error" ,/* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name" ,/* SENSORS_ERR_NO_ENTRY */ "No such subfeature known" ,/* SENSORS_ERR_ACCESS_R */ "Can't read" ,Out of curiosity: did you actually hit this problem in real life?
No, I didn't. It's just theoretical.
Quoted 2 lines
I was about to say that the caller was supposed to check for NULL, but apparently neither sensors nor sensord nor even libsensors does, so...
IMO error reporting should be very stable. If the caller checks return value carefully it's fine too.
Fprintf()isn't a problem. But I don't know what aboutvsnprintf(),syslog().Quoted 10 lines
I guess you're right, having an error string instead of NULL would be better. Actually that's what libsensors 2.x did, I can't remember why I changed that in 3.x:
http://www.lm-sensors.org/changeset/4854Probably I thought it was not supposed to happen, but I guess it may actually happen if mixing a recent application with an older version of libsensors.
So I am pretty much inclined to apply your patch.
Quoted 7 lines
Quoted 1 line
Vous avez le choix. :)
Sicherlich :)
Patch applied, thanks. If you intend to contribute to the lm-sensors project again on a regular basis, please let me know, we can create an account for you.
I'm very interested in contributing more stuff to the project. For the moment I'm happy sending patches to you. If I should be more involved in the future we can talk about an account again.
Thanks
Andre
Quoted 2 lines
Signature · 1 line
Jean Delvare
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors