Check return value of ftruncate(). Some versions of gcc give

warnings if I don't.
This commit is contained in:
pooka 2012-11-14 09:22:58 +00:00
parent 856537a70d
commit 2b783d7193

View File

@ -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 @@ rumpuser_filemmap(int fd, off_t offset, size_t len, int flags, int *error)
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)