Sat Sep 7 18:17:35 2013 UTC ()
fix -Wuninitialized


(pooka)
diff -r1.1 -r1.2 src/sys/rump/librump/rumpkern/cons.c

cvs diff -r1.1 -r1.2 src/sys/rump/librump/rumpkern/cons.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/cons.c 2013/09/07 17:58:00 1.1
+++ src/sys/rump/librump/rumpkern/cons.c 2013/09/07 18:17:35 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cons.c,v 1.1 2013/09/07 17:58:00 pooka Exp $ */ 1/* $NetBSD: cons.c,v 1.2 2013/09/07 18:17:35 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2013 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2013 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28/* 28/*
29 * rumpcons, a (very) simple console-type device which relays output 29 * rumpcons, a (very) simple console-type device which relays output
30 * to the rumpuser_putchar() hypercall. This is most useful in 30 * to the rumpuser_putchar() hypercall. This is most useful in
31 * environments where there is no Unix-like host (e.g. Xen DomU). 31 * environments where there is no Unix-like host (e.g. Xen DomU).
32 * It's currently a truly half duplex console since there is support 32 * It's currently a truly half duplex console since there is support
33 * only for writing to the console (there is no hypercall for reading 33 * only for writing to the console (there is no hypercall for reading
34 * the host console). 34 * the host console).
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.1 2013/09/07 17:58:00 pooka Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.2 2013/09/07 18:17:35 pooka Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/file.h> 41#include <sys/file.h>
42#include <sys/filedesc.h> 42#include <sys/filedesc.h>
43#include <sys/kernel.h> 43#include <sys/kernel.h>
44#include <sys/kmem.h> 44#include <sys/kmem.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46#include <sys/stat.h> 46#include <sys/stat.h>
47 47
48#include <rump/rumpuser.h> 48#include <rump/rumpuser.h>
49 49
50#include "rump_private.h" 50#include "rump_private.h"
51 51
@@ -92,27 +92,27 @@ rump_consdev_init(void) @@ -92,27 +92,27 @@ rump_consdev_init(void)
92 error += fd_dup2(fp, 1, 0); 92 error += fd_dup2(fp, 1, 0);
93 error += fd_dup2(fp, 2, 0); 93 error += fd_dup2(fp, 2, 0);
94 94
95 if (error) 95 if (error)
96 panic("failed to dup fd 0/1/2"); 96 panic("failed to dup fd 0/1/2");
97} 97}
98 98
99static int 99static int
100rumpcons_write(struct file *fp, off_t *off, struct uio *uio, 100rumpcons_write(struct file *fp, off_t *off, struct uio *uio,
101 kauth_cred_t cred, int flags) 101 kauth_cred_t cred, int flags)
102{ 102{
103 char *buf; 103 char *buf;
104 size_t len, n; 104 size_t len, n;
105 int error; 105 int error = 0;
106 106
107 buf = kmem_alloc(PAGE_SIZE, KM_SLEEP); 107 buf = kmem_alloc(PAGE_SIZE, KM_SLEEP);
108 while (uio->uio_resid > 0) { 108 while (uio->uio_resid > 0) {
109 len = min(PAGE_SIZE, uio->uio_resid); 109 len = min(PAGE_SIZE, uio->uio_resid);
110 error = uiomove(buf, len, uio); 110 error = uiomove(buf, len, uio);
111 if (error) 111 if (error)
112 break; 112 break;
113 113
114 for (n = 0; n < len; n++) { 114 for (n = 0; n < len; n++) {
115 rumpuser_putchar(*(buf+n)); 115 rumpuser_putchar(*(buf+n));
116 } 116 }
117 } 117 }
118 kmem_free(buf, PAGE_SIZE); 118 kmem_free(buf, PAGE_SIZE);