[PATCH] Fix `unused-result' warnings.
Jonas Ådahl
jadahl at gmail.com
Fri Mar 30 14:10:27 PDT 2012
Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
This fixes all warnings using gcc 4.6.1.
clients/dnd.c | 4 +++-
clients/window.c | 4 +++-
shared/image-loader.c | 17 +++++++++--------
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/clients/dnd.c b/clients/dnd.c
index e3d3c34..8e67dc4 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -272,7 +272,9 @@ data_source_send(void *data, struct wl_data_source *source,
dnd_flower_message.x_offset = dnd_drag->x_offset;
dnd_flower_message.y_offset = dnd_drag->y_offset;
- write(fd, &dnd_flower_message, sizeof dnd_flower_message);
+ if (write(fd, &dnd_flower_message, sizeof dnd_flower_message) < 0)
+ abort();
+
close(fd);
}
diff --git a/clients/window.c b/clients/window.c
index 74ddedd..e3959c1 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1934,7 +1934,9 @@ data_offer_receive_data(struct data_offer *offer, const char *mime_type,
{
int p[2];
- pipe2(p, O_CLOEXEC);
+ if (pipe2(p, O_CLOEXEC) == -1)
+ return;
+
wl_data_offer_receive(offer->offer, mime_type, p[1]);
close(p[1]);
diff --git a/shared/image-loader.c b/shared/image-loader.c
index 98cc431..b18eb97 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) != size)
png_error(png, NULL);
}
@@ -356,13 +356,14 @@ load_image(const char *filename)
if (fp == NULL)
return NULL;
- fread(header, sizeof header, 1, fp);
- rewind(fp);
- for (i = 0; i < ARRAY_LENGTH(loaders); i++) {
- if (memcmp(header, loaders[i].header,
- loaders[i].header_size) == 0) {
- image = loaders[i].load(fp);
- break;
+ if (fread(header, sizeof header, 1, fp) > 0) {
+ rewind(fp);
+ for (i = 0; i < ARRAY_LENGTH(loaders); i++) {
+ if (memcmp(header, loaders[i].header,
+ loaders[i].header_size) == 0) {
+ image = loaders[i].load(fp);
+ break;
+ }
}
}
--
1.7.5.4
More information about the wayland-devel
mailing list