Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs Use the address of vp->v_specnode as vcache key. ...



details:   https://anonhg.NetBSD.org/src/rev/ea8532e1182e
branches:  trunk
changeset: 339147:ea8532e1182e
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Jun 29 16:48:20 2015 +0000

description:
Use the address of vp->v_specnode as vcache key.  It is invariant
over the lifetime of the vnode.

The previous worked by luck, it took the first sizeof(void *) bytes
of struct vnode as key.

Resolves CID 1308957: wrong sizeof()

diffstat:

 sys/miscfs/deadfs/dead_vfsops.c |   8 ++++----
 sys/miscfs/specfs/spec_vnops.c  |  11 +++--------
 2 files changed, 7 insertions(+), 12 deletions(-)

diffs (61 lines):

diff -r d47c46b668aa -r ea8532e1182e sys/miscfs/deadfs/dead_vfsops.c
--- a/sys/miscfs/deadfs/dead_vfsops.c   Mon Jun 29 16:36:17 2015 +0000
+++ b/sys/miscfs/deadfs/dead_vfsops.c   Mon Jun 29 16:48:20 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dead_vfsops.c,v 1.4 2015/06/23 10:42:34 hannken Exp $  */
+/*     $NetBSD: dead_vfsops.c,v 1.5 2015/06/29 16:48:20 hannken Exp $  */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.4 2015/06/23 10:42:34 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.5 2015/06/29 16:48:20 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -108,8 +108,8 @@
        uvm_vnp_setsize(vp, 0);
        spec_node_init(vp, vap->va_rdev);
 
-       *key_len = sizeof(struct vnode *);
-       *new_key = vp;
+       *key_len = sizeof(vp->v_specnode);
+       *new_key = &vp->v_specnode;
 
        return 0;
 }
diff -r d47c46b668aa -r ea8532e1182e sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Mon Jun 29 16:36:17 2015 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Mon Jun 29 16:48:20 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.150 2015/06/29 16:25:49 christos Exp $        */
+/*     $NetBSD: spec_vnops.c,v 1.151 2015/06/29 16:48:20 hannken Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.150 2015/06/29 16:25:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.151 2015/06/29 16:48:20 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -1097,12 +1097,7 @@
        struct vnode *vp = ap->a_vp;
 
        KASSERT(vp->v_mount == dead_rootmount);
-       /*
-        * The key is the pointer itself, see:
-        * miscfs/deadfs/dead_vfsops::dead_newvnode()
-        * coverity[sizeof_mismatch]
-        */
-       vcache_remove(vp->v_mount, vp, sizeof(struct vnode *));
+       vcache_remove(vp->v_mount, &vp->v_specnode, sizeof(vp->v_specnode));
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index