Print this page
6752 E_SUPPRESSION_DIRECTIVE_UNUSED lint warnings on SPARC build
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/usb/clients/usbser/usbser_rseq.c
+++ new/usr/src/uts/common/io/usb/clients/usbser/usbser_rseq.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
27 27 /*
28 28 * rseq implementation
29 29 */
30 30
31 31 #include <sys/usb/clients/usbser/usbser_rseq.h>
32 32
33 33 #ifdef _KERNEL
34 34 #include <sys/debug.h>
35 35 #include <sys/ddi.h>
36 36 #include <sys/sunddi.h>
37 -/*LINTED E_STATIC_UNUSED*/
38 37 static long rseq_random();
39 38 #define random rseq_random
40 39 #else
41 40 #include <assert.h>
42 41 #define ASSERT assert
43 42 #include <stdlib.h>
44 43 #endif
45 44
46 45
47 46 /*ARGSUSED*/
48 47 static int
49 48 rseq_do_common(rseq_t *rseq, int num, uintptr_t arg, int flags, int fail_err,
50 49 uintptr_t fail_num)
51 50 {
52 51 int i;
53 52 rseq_step_t *s;
54 53 int rval = RSEQ_OK;
55 54
56 55 for (i = 0; i < num; i++) {
57 56 s = &rseq[i].r_do;
58 57
59 58 if (s->s_func == NULL) {
60 59 continue;
61 60 }
62 61 s->s_rval = (i != fail_num) ? s->s_func(arg) : fail_err;
63 62 rval = (s->s_cb) ? (s->s_cb(rseq, i, arg)) : RSEQ_OK;
64 63
65 64 if (rval == RSEQ_UNDO) {
66 65 (void) rseq_undo(rseq, i, arg, flags);
67 66 break;
68 67 } else if (rval == RSEQ_ABORT) {
69 68 break;
70 69 }
71 70 ASSERT(rval == RSEQ_OK);
72 71 }
73 72 return (rval);
74 73 }
75 74
76 75
77 76 /*ARGSUSED*/
78 77 static int
79 78 rseq_undo_common(rseq_t *rseq, int num, uintptr_t arg, int flags, int fail_err,
80 79 uintptr_t fail_num)
81 80 {
82 81 int i;
83 82 rseq_step_t *s;
84 83 int rval = RSEQ_OK;
85 84
86 85 for (i = num - 1; i >= 0; i--) {
87 86 s = &rseq[i].r_undo;
88 87
89 88 if (s->s_func == NULL) {
90 89 continue;
91 90 }
92 91 s->s_rval = (i != fail_num) ? s->s_func(arg) : fail_err;
93 92 rval = (s->s_cb) ? (s->s_cb(rseq, i, arg)) : RSEQ_OK;
94 93
95 94 if (rval == RSEQ_ABORT) {
96 95 break;
97 96 }
98 97 ASSERT(rval == RSEQ_OK);
99 98 }
100 99 return (rval);
101 100 }
102 101
103 102
104 103 int
105 104 rseq_do(rseq_t *rseq, int num, uintptr_t arg, int flags)
106 105 {
107 106 return (rseq_do_common(rseq, num, arg, flags, 0, -1));
108 107 }
109 108
110 109
111 110 int
112 111 rseq_undo(rseq_t *rseq, int num, uintptr_t arg, int flags)
113 112 {
114 113 return (rseq_undo_common(rseq, num, arg, flags, 0, -1));
115 114 }
116 115
117 116 #ifdef DEBUG
118 117
119 118 #ifndef __lock_lint
120 119
121 120 static int
122 121 rseq_debug(rseq_t *rseq, int num, uintptr_t arg, int flags, int scenario,
123 122 uintptr_t sarg1, uintptr_t sarg2,
124 123 int (*func)(rseq_t *, int, uintptr_t, int, int, uintptr_t))
125 124 {
126 125 int rnd, rval = RSEQ_OK, i;
127 126
128 127 switch (scenario) {
129 128 case RSEQ_DBG_FAIL_ONE:
130 129 rval = func(rseq, num, arg, flags, sarg1, sarg2);
131 130 break;
132 131 case RSEQ_DBG_FAIL_ONE_RANDOM:
133 132 rnd = random() % num;
134 133 rval = func(rseq, num, arg, flags, sarg1, rnd);
135 134 break;
136 135 case RSEQ_DBG_FAIL_ONEBYONE:
137 136 for (i = 0; i < num; i++) {
138 137 rval = func(rseq, num, arg, flags, sarg1, i);
139 138 /*
140 139 * when aborted, the undo path is not executed, so we
141 140 * can't continue without the risk of resource leakage.
142 141 */
143 142 if (rval == RSEQ_ABORT) {
144 143 break;
145 144 }
146 145 }
147 146 break;
148 147 default:
149 148 ASSERT(!"rseq_debug: incorrect debug scenario");
150 149 rval = RSEQ_ABORT;
151 150 }
152 151 return (rval);
153 152 }
154 153
155 154
156 155 int
157 156 rseq_do_debug(rseq_t *rseq, int num, uintptr_t arg, int flags, int scenario,
158 157 uintptr_t sarg1, uintptr_t sarg2)
159 158 {
160 159 return (rseq_debug(rseq, num, arg, flags, scenario, sarg1, sarg2,
161 160 rseq_do_common));
162 161 }
163 162
164 163
165 164 int
166 165 rseq_undo_debug(rseq_t *rseq, int num, uintptr_t arg, int flags, int scenario,
167 166 uintptr_t sarg1, uintptr_t sarg2)
168 167 {
169 168 return (rseq_debug(rseq, num, arg, flags, scenario, sarg1, sarg2,
170 169 rseq_undo_common));
171 170 }
172 171
173 172 #ifdef _KERNEL
174 173 static long
175 174 rseq_random()
176 175 {
177 176 return (ddi_get_lbolt());
178 177 }
179 178 #endif /* _KERNEL */
180 179
181 180 #endif /* __lock_lint */
182 181
183 182 #endif /* DEBUG */
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX