WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 04 of 15] xenpaging: simplify file_op

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 04 of 15] xenpaging: simplify file_op
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Fri, 21 Oct 2011 11:31:38 +0200
Delivery-date: Fri, 21 Oct 2011 02:36:22 -0700
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1319189505; l=1830; s=domk; d=aepfle.de; h=To:From:Date:References:In-Reply-To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:X-RZG-CLASS-ID: X-RZG-AUTH; bh=Y1nLEFUU6/P9Y4nAvN1QMPSMBBs=; b=bylNif2WwtiT2BysBP2T/KxM1WjH9nVdTn/3zX9rMM4LyT3mvgczMbNPAiJDUzMVybO Qa9J671JItrg0KltbIjJhzAvrcwMOR/2TlORi+pGs+lkOSFn2sp9dfJ0iMjB41WJH5ERN 6Ppf9H72eRz6ExNcS0AuSJvd5Gfme/VcZp8=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1319189494@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1319189494@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.7.5
# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1319188795 -7200
# Node ID 71002bff018b95da0db016e18c3a3145cc83fc77
# Parent  e51e5e2a835157df92faf3038abc457714d5e096
xenpaging: simplify file_op

Use -1 as return value and let caller read errno.
Remove const casts from buffer pointers, the page is writeable.
Use wrapper for write() which matches the read() prototype.
Remove unused stdarg.h inclusion.
Remove unused macro.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

diff -r e51e5e2a8351 -r 71002bff018b tools/xenpaging/file_ops.c
--- a/tools/xenpaging/file_ops.c
+++ b/tools/xenpaging/file_ops.c
@@ -21,55 +21,44 @@
 
 
 #include <unistd.h>
-#include <stdarg.h>
 #include <xc_private.h>
 
-
-#define page_offset(_pfn)     (((off_t)(_pfn)) << PAGE_SHIFT)
-
-
 static int file_op(int fd, void *page, int i,
-                   ssize_t (*fn)(int, const void *, size_t))
+                   ssize_t (*fn)(int, void *, size_t))
 {
     off_t seek_ret;
-    int total;
+    int total = 0;
     int bytes;
-    int ret;
 
     seek_ret = lseek(fd, i << PAGE_SHIFT, SEEK_SET);
+    if ( seek_ret == (off_t)-1 )
+        return -1;
 
-    total = 0;
     while ( total < PAGE_SIZE )
     {
         bytes = fn(fd, page + total, PAGE_SIZE - total);
         if ( bytes <= 0 )
-        {
-            ret = -errno;
-            goto err;
-        }
+            return -1;
 
         total += bytes;
     }
 
     return 0;
-
- err:
-    return ret;
 }
 
-static ssize_t my_read(int fd, const void *buf, size_t count)
+static ssize_t my_write(int fd, void *buf, size_t count)
 {
-    return read(fd, (void *)buf, count);
+    return write(fd, buf, count);
 }
 
 int read_page(int fd, void *page, int i)
 {
-    return file_op(fd, page, i, &my_read);
+    return file_op(fd, page, i, &read);
 }
 
 int write_page(int fd, void *page, int i)
 {
-    return file_op(fd, page, i, &write);
+    return file_op(fd, page, i, &my_write);
 }
 
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>