aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-08-19 22:41:09 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-08-19 22:41:09 -0500
commit1b5643103532cd11cbd4432e9c534871c3a34fe9 (patch)
tree543910e7cb86bb5b2d8491fe3fca52db853aad2c
parentffaf526a28c84587590cfab283bd8f144258651e (diff)
downloadayatana-indicator-power-1b5643103532cd11cbd4432e9c534871c3a34fe9.tar.gz
ayatana-indicator-power-1b5643103532cd11cbd4432e9c534871c3a34fe9.tar.bz2
ayatana-indicator-power-1b5643103532cd11cbd4432e9c534871c3a34fe9.zip
in ib_brightness_control_set_value(), log the strerror when write() fails.
-rw-r--r--src/ib-brightness-control.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ib-brightness-control.c b/src/ib-brightness-control.c
index cf1e5ad..2b9b79d 100644
--- a/src/ib-brightness-control.c
+++ b/src/ib-brightness-control.c
@@ -18,6 +18,8 @@
*/
#include <gudev/gudev.h>
+
+#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
@@ -75,6 +77,7 @@ ib_brightness_control_set_value (IbBrightnessControl* self, gint value)
gchar *filename;
gchar *svalue;
gint length;
+ gint err;
if (self->path == NULL)
return;
@@ -90,9 +93,12 @@ ib_brightness_control_set_value (IbBrightnessControl* self, gint value)
svalue = g_strdup_printf ("%i", value);
length = strlen (svalue);
+ err = errno;
+ errno = 0;
if (write (fd, svalue, length) != length) {
- g_warning ("Fail to write brightness information.");
+ g_warning ("Fail to write brightness information: %s", g_strerror(errno));
}
+ errno = err;
close (fd);
g_free (svalue);