Bug Summary

File:afs/FBSD/osi_vcache.c
Location:line 61, column 20
Description:Value stored to 'p' during its initialization is never read

Annotated Source Code

1/*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10#include <afsconfig.h>
11#include "afs/param.h"
12
13#include "afs/sysincludes.h" /*Standard vendor system headers */
14#include "afsincludes.h" /*AFS-based standard headers */
15
16#if defined(AFS_FBSD80_ENV1)
17#define ma_vn_lock(vp, flags, p)(_vn_lock(vp, flags, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 17))
(vn_lock(vp, flags)_vn_lock(vp, flags, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 17)
)
18#define MA_VOP_LOCK(vp, flags, p)(VOP_LOCK1(vp, flags, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 18))
(VOP_LOCK(vp, flags)VOP_LOCK1(vp, flags, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 18)
)
19#define MA_VOP_UNLOCK(vp, flags, p)(VOP_UNLOCK(vp, flags)) (VOP_UNLOCK(vp, flags))
20#else
21#define ma_vn_lock(vp, flags, p)(_vn_lock(vp, flags, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 21))
(vn_lock(vp, flags, p))
22#define MA_VOP_LOCK(vp, flags, p)(VOP_LOCK1(vp, flags, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 22))
(VOP_LOCK(vp, flags, p))
23#define MA_VOP_UNLOCK(vp, flags, p)(VOP_UNLOCK(vp, flags)) (VOP_UNLOCK(vp, flags, p))
24#endif
25
26int
27osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
28
29 /*
30 * essentially all we want to do here is check that the
31 * vcache is not in use, then call vgone() (which will call
32 * inactive and reclaim as needed). This requires some
33 * kind of complicated locking, which we already need to implement
34 * for FlushVCache, so just call that routine here and check
35 * its return value for whether the vcache was evict-able.
36 */
37 if (osi_VM_FlushVCache(avc, slept) != 0)
38 return 0;
39 else
40 return 1;
41}
42
43struct vcache *
44osi_NewVnode(void) {
45 struct vcache *tvc;
46
47 tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
48 tvc->v = NULL((void *)0); /* important to clean this, or use memset 0 */
49
50 return tvc;
51}
52
53void
54osi_PrePopulateVCache(struct vcache *avc) {
55 memset(avc, 0, sizeof(struct vcache));
56}
57
58void
59osi_AttachVnode(struct vcache *avc, int seq) {
60 struct vnode *vp;
61 struct thread *p = curthread(__curthread());
Value stored to 'p' during its initialization is never read
62
63 ReleaseWriteLock(&afs_xvcache)do { ; (&afs_xvcache)->excl_locked &= ~2; if ((&
afs_xvcache)->wait_states) Afs_Lock_ReleaseR(&afs_xvcache
); (&afs_xvcache)->pid_writer=0; } while (0)
;
64 AFS_GUNLOCK()do { (void)0; _mtx_unlock_flags(((&afs_global_mtx)), (0),
"/home/wollman/openafs/src/afs/FBSD/osi_vcache.c", 64); } while
(0)
;
65#if defined(AFS_FBSD60_ENV1)
66 if (getnewvnode(MOUNT_AFS"afs", afs_globalVFS, &afs_vnodeops, &vp))
67#else
68 if (getnewvnode(MOUNT_AFS"afs", afs_globalVFS, afs_vnodeop_p, &vp))
69#endif
70 panic("afs getnewvnode"); /* can't happen */
71#ifdef AFS_FBSD70_ENV1
72 /* XXX verified on 80--TODO check on 7x */
73 if (!vp->v_mount) {
74 ma_vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p)(_vn_lock(vp, 0x080000 | 0x000400, "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 74))
; /* !glocked */
75 insmntque(vp, afs_globalVFS);
76 MA_VOP_UNLOCK(vp, 0, p)(VOP_UNLOCK(vp, 0));
77 }
78#endif
79 AFS_GLOCK()do { (void)0; _mtx_lock_flags(((&afs_global_mtx)), (0), "/home/wollman/openafs/src/afs/FBSD/osi_vcache.c"
, 79); (void)0; } while (0)
;
80 ObtainWriteLock(&afs_xvcache,339)do { ; if (!(&afs_xvcache)->excl_locked && !(&
afs_xvcache)->readers_reading) (&afs_xvcache) -> excl_locked
= 2; else Afs_Lock_Obtain(&afs_xvcache, 2); (&afs_xvcache
)->pid_writer = (((__curthread())->td_proc)->p_pid )
; (&afs_xvcache)->src_indicator = 339; } while (0)
;
81 if (avc->v != NULL((void *)0)) {
82 /* I'd like to know if this ever happens...
83 * We don't drop global for the rest of this function,
84 * so if we do lose the race, the other thread should
85 * have found the same vnode and finished initializing
86 * the vcache entry. Is it conceivable that this vcache
87 * entry could be recycled during this interval? If so,
88 * then there probably needs to be some sort of additional
89 * mutual exclusion (an Embryonic flag would suffice).
90 * -GAW */
91 afs_warn("afs_NewVCache: lost the race\n");
92 return;
93 }
94 avc->v = vp;
95 avc->v->v_data = avc;
96 lockinit(&avc->rwlock, PINOD((80) + 8), "vcache", 0, 0);
97}
98
99void
100osi_PostPopulateVCache(struct vcache *avc) {
101 avc->v->v_mount = afs_globalVFS;
102 vSetType(avc, VREG)((avc)->v)->v_type = (VREG);
103}
104