From 6ed846397ce78ef1532a129dbd0e6e4a682d7d9a Mon Sep 17 00:00:00 2001 From: guenther Date: Mon, 11 May 2015 01:56:26 +0000 Subject: [PATCH] Convert from uiomovei() to uiomove() to prevent short tranfers diff from natano@bitrig, with some additional format and cast tweaks --- sys/arch/amd64/amd64/nvram.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/arch/amd64/amd64/nvram.c b/sys/arch/amd64/amd64/nvram.c index c3aa137e234..3cdb28beed1 100644 --- a/sys/arch/amd64/amd64/nvram.c +++ b/sys/arch/amd64/amd64/nvram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvram.c,v 1.3 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: nvram.c,v 1.4 2015/05/11 01:56:26 guenther Exp $ */ /* * Copyright (c) 2004 Joshua Stein @@ -94,7 +94,7 @@ nvramread(dev_t dev, struct uio *uio, int flags) u_char buf[NVRAM_SIZE]; u_int pos = uio->uio_offset; u_char *tmp; - int count = min(sizeof(buf), uio->uio_resid); + size_t count = ulmin(sizeof(buf), uio->uio_resid); int ret; if (!nvram_initialized) @@ -104,17 +104,17 @@ nvramread(dev_t dev, struct uio *uio, int flags) return (0); #ifdef NVRAM_DEBUG - printf("attempting to read %d bytes at offset %d\n", count, pos); + printf("attempting to read %zu bytes at offset %d\n", count, pos); #endif for (tmp = buf; count-- > 0 && pos < NVRAM_SIZE; ++pos, ++tmp) *tmp = nvram_get_byte(pos); #ifdef NVRAM_DEBUG - printf("nvramread read %d bytes (%s)\n", (tmp - buf), tmp); + printf("nvramread read %td bytes (%s)\n", (tmp - buf), tmp); #endif - ret = uiomovei((caddr_t)buf, (tmp - buf), uio); + ret = uiomove(buf, (tmp - buf), uio); uio->uio_offset += uio->uio_resid; -- 2.20.1