toytoolkit: Don't draw shadows for maximized windows.
[profile/ivi/weston.git] / src / libbacklight.c
index b2e19bf..df811b4 100644 (file)
 
 #define _GNU_SOURCE
 
-#include <libbacklight.h>
+#include "libbacklight.h"
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include <linux/types.h>
 #include <dirent.h>
-#include <drm/drm_mode.h>
+#include <drm.h>
 #include <fcntl.h>
 #include <malloc.h>
 #include <string.h>
 #include <errno.h>
 
-static const char *output_names[] = { "Unknown",
-                                      "VGA",
-                                      "DVI-I",
-                                      "DVI-D",
-                                      "DVI-A",
-                                      "Composite",
-                                      "SVIDEO",
-                                      "LVDS",
-                                      "Component",
-                                      "9-pin DIN",
-                                     "DisplayPort"
-                                      "HDMI Type A",
-                                      "HDMI Type B",
-                                      "TV",
-                                     "Embedded DisplayPort"
-};
-
 static long backlight_get(struct backlight *backlight, char *node)
 {
        char buffer[100];
@@ -126,8 +111,10 @@ long backlight_set_brightness(struct backlight *backlight, long brightness)
                goto out;
        }
 
-       if (asprintf(&buffer, "%ld", brightness) < 0)
-               return -ENOMEM;
+       if (asprintf(&buffer, "%ld", brightness) < 0) {
+               ret = -1;
+               goto out;
+       }
 
        ret = write(fd, buffer, strlen(buffer));
        if (ret < 0) {
@@ -169,7 +156,7 @@ struct backlight *backlight_init(struct udev_device *drm_device,
        enum backlight_type type = 0;
        char buffer[100];
        struct backlight *backlight;
-       int err, ret;
+       int ret;
 
        if (!drm_device)
                return NULL;
@@ -181,7 +168,7 @@ struct backlight *backlight_init(struct udev_device *drm_device,
        if (asprintf(&path, "%s/%s", syspath, "device") < 0)
                return NULL;
 
-       ret = readlink(path, buffer, sizeof(buffer));
+       ret = readlink(path, buffer, sizeof(buffer) - 1);
        free(path);
        if (ret < 0)
                return NULL;
@@ -263,7 +250,7 @@ struct backlight *backlight_init(struct udev_device *drm_device,
                if (asprintf(&path, "%s/%s", backlight_path, "device") < 0)
                        return NULL;
 
-               ret = readlink(path, buffer, sizeof(buffer));
+               ret = readlink(path, buffer, sizeof(buffer) - 1);
 
                if (ret < 0)
                        goto out;