Sat Jan 28 21:54:57 2017 UTC ()
avoid the shadow


(christos)
diff -r1.16 -r1.17 src/sys/compat/linux32/common/linux32_dirent.c

cvs diff -r1.16 -r1.17 src/sys/compat/linux32/common/linux32_dirent.c (expand / switch to unified diff)

--- src/sys/compat/linux32/common/linux32_dirent.c 2017/01/28 15:09:55 1.16
+++ src/sys/compat/linux32/common/linux32_dirent.c 2017/01/28 21:54:57 1.17
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux32_dirent.c,v 1.16 2017/01/28 15:09:55 christos Exp $ */ 1/* $NetBSD: linux32_dirent.c,v 1.17 2017/01/28 21:54:57 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. 4 * Copyright (c) 2006 Emmanuel Dreyfus, 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 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS  24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE. 31 * POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35 35
36__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.16 2017/01/28 15:09:55 christos Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.17 2017/01/28 21:54:57 christos Exp $");
37 37
38#include <sys/types.h> 38#include <sys/types.h>
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/fstypes.h> 40#include <sys/fstypes.h>
41#include <sys/signal.h> 41#include <sys/signal.h>
42#include <sys/dirent.h> 42#include <sys/dirent.h>
43#include <sys/kernel.h> 43#include <sys/kernel.h>
44#include <sys/fcntl.h> 44#include <sys/fcntl.h>
45#include <sys/file.h> 45#include <sys/file.h>
46#include <sys/filedesc.h> 46#include <sys/filedesc.h>
47#include <sys/malloc.h> 47#include <sys/malloc.h>
48#include <sys/select.h> 48#include <sys/select.h>
49#include <sys/proc.h> 49#include <sys/proc.h>
@@ -205,29 +205,29 @@ again: @@ -205,29 +205,29 @@ again:
205 */ 205 */
206 if (oldcall) { 206 if (oldcall) {
207 idb.d_off = (linux32_off_t)linux32_reclen; 207 idb.d_off = (linux32_off_t)linux32_reclen;
208 idb.d_reclen = (u_short)bdp->d_namlen; 208 idb.d_reclen = (u_short)bdp->d_namlen;
209 } else { 209 } else {
210 if (sizeof (idb.d_off) <= 4 && (off >> 32) != 0) { 210 if (sizeof (idb.d_off) <= 4 && (off >> 32) != 0) {
211 compat_offseterr(vp, "linux32_getdents"); 211 compat_offseterr(vp, "linux32_getdents");
212 error = EINVAL; 212 error = EINVAL;
213 goto out; 213 goto out;
214 } 214 }
215 idb.d_off = (linux32_off_t)off; 215 idb.d_off = (linux32_off_t)off;
216 idb.d_reclen = (u_short)linux32_reclen; 216 idb.d_reclen = (u_short)linux32_reclen;
217 } 217 }
218 size_t l = MIN(sizeof(idb.d_name) - 1, bdp->d_namlen + 1); 218 size_t dirl = MIN(sizeof(idb.d_name) - 1, bdp->d_namlen + 1);
219 memcpy(idb.d_name, bdp->d_name, l); 219 memcpy(idb.d_name, bdp->d_name, dirl);
220 idb.d_name[l + 1] = bdp->d_type; 220 idb.d_name[dirl + 1] = bdp->d_type;
221 if ((error = copyout((void *)&idb, outp, linux32_reclen))) 221 if ((error = copyout((void *)&idb, outp, linux32_reclen)))
222 goto out; 222 goto out;
223 /* advance past this real entry */ 223 /* advance past this real entry */
224 inp += reclen; 224 inp += reclen;
225 if (cookie) 225 if (cookie)
226 off = *cookie++; /* each entry points to itself */ 226 off = *cookie++; /* each entry points to itself */
227 else 227 else
228 off += reclen; 228 off += reclen;
229 /* advance output past Linux-shaped entry */ 229 /* advance output past Linux-shaped entry */
230 outp += linux32_reclen; 230 outp += linux32_reclen;
231 resid -= linux32_reclen; 231 resid -= linux32_reclen;
232 if (oldcall) 232 if (oldcall)
233 break; 233 break;