Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumpuser Check return value of ftruncate(). Some ver...



details:   https://anonhg.NetBSD.org/src/rev/f99e425cb628
branches:  trunk
changeset: 782690:f99e425cb628
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Nov 14 09:22:58 2012 +0000

description:
Check return value of ftruncate().  Some versions of gcc give
warnings if I don't.

diffstat:

 lib/librumpuser/rumpuser.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r e0cc746a6154 -r f99e425cb628 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c        Wed Nov 14 08:26:29 2012 +0000
+++ b/lib/librumpuser/rumpuser.c        Wed Nov 14 09:22:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser.c,v 1.21 2012/10/10 11:15:57 pooka Exp $      */
+/*     $NetBSD: rumpuser.c,v 1.22 2012/11/14 09:22:58 pooka Exp $      */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.21 2012/10/10 11:15:57 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.22 2012/11/14 09:22:58 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/ioctl.h>
@@ -284,8 +284,12 @@
        void *rv;
        int mmflags, prot;
 
-       if (flags & RUMPUSER_FILEMMAP_TRUNCATE)
-               ftruncate(fd, offset + len);
+       if (flags & RUMPUSER_FILEMMAP_TRUNCATE) {
+               if (ftruncate(fd, offset + len) == -1) {
+                       seterror(errno);
+                       return NULL;
+               }
+       }
 
        mmflags = MAP_FILE;
        if (flags & RUMPUSER_FILEMMAP_SHARED)



Home | Main Index | Thread Index | Old Index