[PATCH 4/5] Weston: handle file errors

Martin Minarik minarik11 at student.fiit.stuba.sk
Sat Mar 31 03:55:17 PDT 2012


diff --git a/shared/image-loader.c b/shared/image-loader.c
index 98cc431..a0881b5 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -157,7 +157,7 @@ read_func(png_structp png, png_bytep data, png_size_t
size)
 {
 	FILE *fp = png_get_io_ptr(png);

-	if (fread(data, 1, size, fp) < 0)
+	if (fread(data, 1, size, fp) < 1)
 		png_error(png, NULL);
 }

@@ -356,7 +356,9 @@ load_image(const char *filename)
 	if (fp == NULL)
 		return NULL;

-	fread(header, sizeof header, 1, fp);
+	if (fread(header, sizeof header, 1, fp) < 1)
+		return NULL;
+
 	rewind(fp);
 	for (i = 0; i < ARRAY_LENGTH(loaders); i++) {
 		if (memcmp(header, loaders[i].header,
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 4305cd5..f43f652 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -951,7 +951,7 @@ drm_set_backlight(struct weston_output *output_base,
uint32_t value)
 	if (!output->backlight)
 		return;

-	if (value < 0 || value > 255)
+	if (value > 255)
 		return;

 	max_brightness = backlight_get_max_brightness(output->backlight);



More information about the wayland-devel mailing list