Print this page
5910 libnisdb won't build with modern GCC
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libnisdb/db_index_entry_c.c
+++ new/usr/src/lib/libnisdb/db_index_entry_c.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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 +
22 23 /*
24 + * Copyright 2015 Gary Mills
25 + */
26 +
27 +/*
23 28 * This is a non-recursive version of XDR routine used for db_index_entry
24 29 * type.
25 30 */
26 31
27 -#pragma ident "%Z%%M% %I% %E% SMI"
28 -
29 32 #include <sys/types.h>
30 33 #include <sys/syslog.h>
31 34 #include <stdio.h>
32 35 #include <rpc/types.h>
33 36 #include <rpc/xdr.h>
34 37 #include <memory.h>
35 38 #include "db_index_entry_c.h"
36 39 #include "db_table_c.h"
40 +#include "xdr_nullptr.h"
37 41
38 42 bool_t
39 43 xdr_db_index_entry(xdrs, objp)
40 44 register XDR *xdrs;
41 45 db_index_entry *objp;
42 46 {
43 47 bool_t more_data;
44 48 register db_index_entry *ep = objp;
45 49 register db_index_entry *loc;
46 50 register db_index_entry *freeptr = NULL;
47 51
48 52 for (;;) {
49 53 if (!xdr_u_long(xdrs, &ep->hashval))
50 54 return (FALSE);
51 55 if (!xdr_pointer(xdrs, (char **)&ep->key, sizeof (item),
52 56 (xdrproc_t) xdr_item))
53 57 return (FALSE);
54 58 if (!xdr_entryp(xdrs, &ep->location))
55 59 return (FALSE);
56 60 if (!xdr_nullptr(xdrs, &ep->next_result))
57 61 return (FALSE);
58 62
59 63 /*
60 64 * The following code replaces the call to
61 65 * xdr_pointer(
62 66 * xdrs,
63 67 * (char **)&ep->next,
64 68 * sizeof (db_index_entry),
65 69 * (xdrproc_t) xdr_db_index_entry))
66 70 *
67 71 * It's a modified version of xdr_refer.c from the rpc library:
68 72 * @(#)xdr_refer.c 1.8 92/07/20 SMI
69 73 */
70 74
71 75
72 76 /*
73 77 * the following assignment to more_data is only useful when
74 78 * encoding and freeing. When decoding, more_data will be
75 79 * filled by the xdr_bool() routine.
76 80 */
77 81 more_data = (ep->next != NULL);
78 82 if (! xdr_bool(xdrs, &more_data))
79 83 return (FALSE);
80 84 if (! more_data) {
81 85 ep->next = NULL;
82 86 break;
83 87 }
84 88
85 89 loc = ep->next;
86 90
87 91
88 92 switch (xdrs->x_op) {
89 93 case XDR_DECODE:
90 94 if (loc == NULL) {
91 95 ep->next = loc = (db_index_entry *)
92 96 mem_alloc(sizeof (db_index_entry));
93 97 if (loc == NULL) {
94 98 syslog(LOG_ERR,
95 99 "xdr_db_index_entry: mem_alloc failed");
96 100 return (FALSE);
97 101 }
98 102 memset(loc, 0, sizeof (db_index_entry));
99 103 }
100 104 break;
101 105 case XDR_FREE:
102 106 if (freeptr != NULL) {
103 107 mem_free(freeptr, sizeof (db_index_entry));
104 108 } else
105 109 ep->next = NULL;
106 110 freeptr = loc;
107 111 break;
108 112 }
109 113
110 114 if (loc == NULL)
111 115 break;
112 116 ep = loc;
113 117 } /* for loop */
114 118
115 119 if ((freeptr != NULL) && (xdrs->x_op == XDR_FREE)) {
116 120 mem_free(freeptr, sizeof (db_index_entry));
117 121 }
118 122
119 123 return (TRUE);
120 124 }
121 125
122 126
123 127 bool_t
124 128 xdr_db_index_entry_p(xdrs, objp)
125 129 register XDR *xdrs;
126 130 db_index_entry_p *objp;
127 131 {
128 132
129 133 if (!xdr_pointer(xdrs, (char **)objp, sizeof (db_index_entry),
130 134 (xdrproc_t) xdr_db_index_entry))
131 135 return (FALSE);
132 136 return (TRUE);
133 137 }
134 138
135 139
136 140
137 141 bool_t
138 142 xdr_db_free_entry(xdrs, objp)
139 143 register XDR *xdrs;
140 144 db_free_entry *objp;
141 145 {
142 146 bool_t more_data;
143 147 register db_free_entry *ep = objp;
144 148 register db_free_entry *loc;
145 149 register db_free_entry *freeptr = NULL;
146 150
147 151 for (;;) {
148 152 if (!xdr_entryp(xdrs, &ep->where))
149 153 return (FALSE);
150 154
151 155 /*
152 156 * The following code replaces the call to
153 157 * xdr_pointer(
154 158 * xdrs,
155 159 * (char **)&ep->next,
156 160 * sizeof (db_free_entry),
157 161 * (xdrproc_t) xdr_db_free_entry))
158 162 *
159 163 * It's a modified version of xdr_refer.c from the rpc library:
160 164 * @(#)xdr_refer.c 1.8 92/07/20 SMI
161 165 */
162 166
163 167
164 168 /*
165 169 * the following assignment to more_data is only useful when
166 170 * encoding and freeing. When decoding, more_data will be
167 171 * filled by the xdr_bool() routine.
168 172 */
169 173 more_data = (ep->next != NULL);
170 174 if (! xdr_bool(xdrs, &more_data))
171 175 return (FALSE);
172 176 if (! more_data) {
173 177 ep->next = NULL;
174 178 break;
175 179 }
176 180
177 181 loc = ep->next;
178 182
179 183
180 184 switch (xdrs->x_op) {
181 185 case XDR_DECODE:
182 186 if (loc == NULL) {
183 187 ep->next = loc = (db_free_entry *)
184 188 mem_alloc(sizeof (db_free_entry));
185 189 if (loc == NULL) {
186 190 syslog(LOG_ERR,
187 191 "db_free_entry: mem_alloc failed");
188 192 return (FALSE);
189 193 }
190 194 memset(loc, 0, sizeof (db_free_entry));
191 195 }
192 196 break;
193 197 case XDR_FREE:
194 198 if (freeptr != NULL) {
195 199 mem_free(freeptr, sizeof (db_free_entry));
196 200 } else
197 201 ep->next = NULL;
198 202 freeptr = loc;
199 203 break;
200 204 }
201 205
202 206 if (loc == NULL)
203 207 break;
204 208 ep = loc;
205 209 } /* for loop */
206 210
207 211 if ((freeptr != NULL) && (xdrs->x_op == XDR_FREE)) {
208 212 mem_free(freeptr, sizeof (db_free_entry));
209 213 }
210 214 return (TRUE);
211 215 }
↓ open down ↓ |
165 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX