From 9e98dd15e8cdf8dc410d2c706d1a0d410580c24f Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela@redhat.com>
Date: Thu, 4 Mar 2010 23:11:27 -0300
Subject: [PATCH 05/42] block/bochs.c: fix warning with _FORTIFY_SOURCE

RH-Author: Juan Quintela <quintela@redhat.com>
Message-id: <b6c248d7dcc02ab44ff1004744260df6037d15f5.1267743950.git.quintela@redhat.com>
Patchwork-id: 7535
O-Subject: [PATCH 05/32] block/bochs.c: fix warning with _FORTIFY_SOURCE
Bugzilla: 567099
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>

From: Kirill A. Shutemov <kirill@shutemov.name>

CC    block/bochs.o
cc1: warnings being treated as errors
block/bochs.c: In function 'seek_to_sector':
block/bochs.c:202: error: ignoring return value of 'read', declared with attribute warn_unused_result
make: *** [block/bochs.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
(cherry picked from commit 00ccf932a0e0f0f1cbc6cdb9db5495dd5ebedd5a)

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 block/bochs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 block/bochs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/bochs.c b/block/bochs.c
index bac81c4..f6a18f2 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -199,7 +199,8 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
     // read in bitmap for current extent
     lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
 
-    read(s->fd, &bitmap_entry, 1);
+    if (read(s->fd, &bitmap_entry, 1) != 1)
+        return -1;
 
     if (!((bitmap_entry >> (extent_offset % 8)) & 1))
     {
-- 
1.6.3.rc4.29.g8146

