1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
From e7b94411b174c8445d9bdc84ec6c94b5d4343470 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Mon, 15 Apr 2024 15:38:57 +0800
Subject: [PATCH 60/69] cdi:return int instead of error string
---
src/daemon/modules/api/cdi_operate_api.h | 7 ++++---
.../device/cdi/behavior/cdi_container_edits.c | 12 ++++++------
.../device/cdi/behavior/cdi_container_edits.h | 6 +++---
.../modules/device/cdi/behavior/cdi_device.c | 2 +-
.../modules/device/cdi/behavior/cdi_device.h | 2 +-
.../modules/device/cdi/behavior/cdi_spec.c | 2 +-
.../modules/device/cdi/behavior/cdi_spec.h | 2 +-
.../modules/device/cdi/behavior/cdi_spec_dirs.c | 4 ++--
.../modules/device/cdi/behavior/cdi_spec_dirs.h | 6 +++---
.../device/cdi/behavior/parser/cdi_parser.c | 16 ++++++++--------
.../device/cdi/behavior/parser/cdi_parser.h | 8 ++++----
src/daemon/modules/device/cdi/cdi_annotations.c | 5 +++--
src/daemon/modules/device/cdi/cdi_annotations.h | 3 ++-
src/daemon/modules/device/cdi/cdi_cache.c | 14 +++++++-------
src/daemon/modules/device/cdi/cdi_cache.h | 8 ++++----
src/daemon/modules/device/cdi_operate.c | 13 +++++++------
16 files changed, 57 insertions(+), 53 deletions(-)
diff --git a/src/daemon/modules/api/cdi_operate_api.h b/src/daemon/modules/api/cdi_operate_api.h
index 4f4c339e..49820ed7 100644
--- a/src/daemon/modules/api/cdi_operate_api.h
+++ b/src/daemon/modules/api/cdi_operate_api.h
@@ -26,11 +26,12 @@ extern "C" {
int cdi_operate_registry_init(char **specs_dirs, size_t specs_dirs_len);
-char *cdi_operate_refresh(void);
+int cdi_operate_refresh(void);
-string_array *cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices, char **error);
+int cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices);
-char *cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices);
+int cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys,
+ string_array **devices, char **error);
#ifdef __cplusplus
}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
index ce7b16db..590118b1 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
+++ b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.c
@@ -27,19 +27,19 @@
// POSTSTOP_HOOK is the name of the OCI "poststop" hook.
#define POSTSTOP_HOOK "poststop"
-char *cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec)
+int cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec)
{
- return NULL;
+ return 0;
}
-char *cdi_container_edits_validate(cdi_container_edits *e)
+int cdi_container_edits_validate(cdi_container_edits *e, char **error)
{
- return NULL;
+ return 0;
}
-cdi_container_edits *cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o)
+int cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o)
{
- return NULL;
+ return 0;
}
bool cdi_container_edits_is_empty(cdi_container_edits *e)
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
index 7b16d2bc..ea921e37 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
+++ b/src/daemon/modules/device/cdi/behavior/cdi_container_edits.h
@@ -27,9 +27,9 @@
extern "C" {
#endif
-char *cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec);
-char *cdi_container_edits_validate(cdi_container_edits *e);
-cdi_container_edits *cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o);
+int cdi_container_edits_apply(cdi_container_edits *e, oci_runtime_spec *spec);
+int cdi_container_edits_validate(cdi_container_edits *e, char **error);
+int cdi_container_edits_append(cdi_container_edits *e, cdi_container_edits *o);
bool cdi_container_edits_is_empty(cdi_container_edits *e);
#ifdef __cplusplus
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_device.c b/src/daemon/modules/device/cdi/behavior/cdi_device.c
index 9904e9ee..0fef8f42 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_device.c
+++ b/src/daemon/modules/device/cdi/behavior/cdi_device.c
@@ -34,7 +34,7 @@ char *cdi_device_get_qualified_name(struct cdi_cache_device *d)
return NULL;
}
-cdi_container_edits *cdi_device_edits(struct cdi_cache_device *d)
+cdi_container_edits *cdi_device_get_edits(struct cdi_cache_device *d)
{
return NULL;
}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_device.h b/src/daemon/modules/device/cdi/behavior/cdi_device.h
index 3f460152..5d63a576 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_device.h
+++ b/src/daemon/modules/device/cdi/behavior/cdi_device.h
@@ -37,7 +37,7 @@ void free_cdi_cache_device(struct cdi_cache_device *d);
struct cdi_cache_device *cdi_device_new_device(struct cdi_cache_spec *spec, cdi_device *d, char **error);
struct cdi_cache_spec *cdi_device_get_spec(struct cdi_cache_device *d);
char *cdi_device_get_qualified_name(struct cdi_cache_device *d);
-cdi_container_edits *cdi_device_edits(struct cdi_cache_device *d);
+cdi_container_edits *cdi_device_get_edits(struct cdi_cache_device *d);
#ifdef __cplusplus
}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec.c b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
index 38fc9e38..f79b5a44 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec.c
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.c
@@ -54,7 +54,7 @@ int cdi_spec_get_priority(struct cdi_cache_spec *s)
return 0;
}
-cdi_container_edits *cdi_spec_edits(struct cdi_cache_spec *s)
+cdi_container_edits *cdi_spec_get_edits(struct cdi_cache_spec *s)
{
return NULL;
}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec.h b/src/daemon/modules/device/cdi/behavior/cdi_spec.h
index bd4fc9d1..87248041 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec.h
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec.h
@@ -47,7 +47,7 @@ const char *cdi_spec_get_class(struct cdi_cache_spec *s);
struct cdi_cache_device *cdi_spec_get_cache_device(struct cdi_cache_spec *s, const char *name);
const char *cdi_spec_get_path(struct cdi_cache_spec *s);
int cdi_spec_get_priority(struct cdi_cache_spec *s);
-cdi_container_edits *cdi_spec_edits(struct cdi_cache_spec *s);
+cdi_container_edits *cdi_spec_get_edits(struct cdi_cache_spec *s);
#ifdef __cplusplus
}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
index 5df4c937..e340abc0 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.c
@@ -23,7 +23,7 @@ string_array g_default_spec_dirs = {
.cap = DEFAULT_SPEC_DIRS_LEN,
};
-char *cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn)
+int cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn)
{
- return NULL;
+ return 0;
}
diff --git a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
index bd00e318..73d8c0f5 100644
--- a/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
+++ b/src/daemon/modules/device/cdi/behavior/cdi_spec_dirs.h
@@ -35,10 +35,10 @@ struct cdi_scan_fn_maps {
map_t *spec_errors;
string_array *result;
};
-typedef char *(*cdi_scan_spec_func)(struct cdi_scan_fn_maps *scan_fn_maps, const char *path, int priority,
- struct cdi_cache_spec *spec, char **error);
+typedef void(*cdi_scan_spec_func)(struct cdi_scan_fn_maps *scan_fn_maps, const char *path, int priority,
+ struct cdi_cache_spec *spec, char *error);
-char *cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn);
+int cdi_scan_spec_dirs(string_array *dirs, struct cdi_scan_fn_maps *scan_fn_maps, cdi_scan_spec_func scan_fn);
#ifdef __cplusplus
}
diff --git a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
index 45048f9a..14293c72 100644
--- a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
+++ b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.c
@@ -24,9 +24,9 @@ bool cdi_parser_is_qualified_name(const char *device)
return true;
}
-char *cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name)
+int cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name)
{
- return NULL;
+ return 0;
}
int cdi_parser_parse_device(const char *device, char **vendor, char **class, char **name)
@@ -39,17 +39,17 @@ int cdi_parser_parse_qualifier(const char *kind, char **vendor, char **class)
return 0;
}
-char *cdi_parser_validate_vendor_name(const char *vendor)
+int cdi_parser_validate_vendor_name(const char *vendor, char **error)
{
- return NULL;
+ return 0;
}
-char *cdi_parser_validate_class_name(const char *class)
+int cdi_parser_validate_class_name(const char *class, char **error)
{
- return NULL;
+ return 0;
}
-char *cdi_parser_validate_device_name(const char *name)
+int cdi_parser_validate_device_name(const char *name, char **error)
{
- return NULL;
+ return 0;
}
diff --git a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
index d9c057ea..467641a1 100644
--- a/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
+++ b/src/daemon/modules/device/cdi/behavior/parser/cdi_parser.h
@@ -24,12 +24,12 @@ extern "C" {
char *cdi_parser_qualified_name(const char *vendor, const char *class, const char *name);
bool cdi_parser_is_qualified_name(const char *device);
-char *cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name);
+int cdi_parser_parse_qualified_name(const char *device, char **vendor, char **class, char **name);
int cdi_parser_parse_device(const char *device, char **vendor, char **class, char **name);
int cdi_parser_parse_qualifier(const char *kind, char **vendor, char **class);
-char *cdi_parser_validate_vendor_name(const char *vendor);
-char *cdi_parser_validate_class_name(const char *class);
-char *cdi_parser_validate_device_name(const char *name);
+int cdi_parser_validate_vendor_name(const char *vendor, char **error);
+int cdi_parser_validate_class_name(const char *class, char **error);
+int cdi_parser_validate_device_name(const char *name, char **error);
#ifdef __cplusplus
}
diff --git a/src/daemon/modules/device/cdi/cdi_annotations.c b/src/daemon/modules/device/cdi/cdi_annotations.c
index 3cb9be84..cfe6e099 100644
--- a/src/daemon/modules/device/cdi/cdi_annotations.c
+++ b/src/daemon/modules/device/cdi/cdi_annotations.c
@@ -25,7 +25,8 @@
#define CDI_ANNOTATIONS_PREFIX "cdi.k8s.io/"
-char *cdi_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices)
+int cdi_parse_annotations(json_map_string_string *annotations, string_array **keys,
+ string_array **devices, char **error)
{
- return NULL;
+ return 0;
}
diff --git a/src/daemon/modules/device/cdi/cdi_annotations.h b/src/daemon/modules/device/cdi/cdi_annotations.h
index 52355099..49930963 100644
--- a/src/daemon/modules/device/cdi/cdi_annotations.h
+++ b/src/daemon/modules/device/cdi/cdi_annotations.h
@@ -23,7 +23,8 @@
extern "C" {
#endif
-char *cdi_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices);
+int cdi_parse_annotations(json_map_string_string *annotations, string_array **keys,
+ string_array **devices, char **error);
#ifdef __cplusplus
}
diff --git a/src/daemon/modules/device/cdi/cdi_cache.c b/src/daemon/modules/device/cdi/cdi_cache.c
index 9c54acbf..cfc23a1c 100644
--- a/src/daemon/modules/device/cdi/cdi_cache.c
+++ b/src/daemon/modules/device/cdi/cdi_cache.c
@@ -19,24 +19,24 @@ void free_cdi_cache(struct cdi_cache *c)
(void)c;
}
-struct cdi_cache *cdi_new_cache(string_array *spec_dirs, char **error)
+struct cdi_cache *cdi_new_cache(string_array *spec_dirs)
{
return NULL;
}
-static string_array *cdi_inject_devices(struct cdi_cache *c, oci_runtime_spec *oci_spec, string_array *devices, char **error)
+static int cdi_inject_devices(struct cdi_cache *c, oci_runtime_spec *oci_spec, string_array *devices)
{
- return NULL;
+ return 0;
}
-static char *cdi_configure(struct cdi_cache *c, string_array *spec_dirs)
+static int cdi_configure(struct cdi_cache *c, string_array *spec_dirs)
{
- return NULL;
+ return 0;
}
-static char *cdi_refresh(struct cdi_cache *c)
+static int cdi_refresh(struct cdi_cache *c)
{
- return NULL;
+ return 0;
}
static map_t *cdi_get_errors(struct cdi_cache *c)
diff --git a/src/daemon/modules/device/cdi/cdi_cache.h b/src/daemon/modules/device/cdi/cdi_cache.h
index 92fb64af..34c27471 100644
--- a/src/daemon/modules/device/cdi/cdi_cache.h
+++ b/src/daemon/modules/device/cdi/cdi_cache.h
@@ -33,12 +33,12 @@ struct cdi_cache;
struct cdi_cache_ops {
// injecting CDI devices into an OCI Spec.
// Resolver
- string_array *(*inject_devices)(struct cdi_cache *c, oci_runtime_spec *spec, string_array *devices, char **error);
+ int (*inject_devices)(struct cdi_cache *c, oci_runtime_spec *spec, string_array *devices);
// refreshing the cache of CDI Specs and devices.
// Refresher
- char *(*configure)(struct cdi_cache *c, string_array *spec_dirs);
- char *(*refresh)(struct cdi_cache *c);
+ int (*configure)(struct cdi_cache *c, string_array *spec_dirs);
+ int (*refresh)(struct cdi_cache *c);
map_t *(*get_errors)(struct cdi_cache *c);
string_array *(*get_spec_directories)(struct cdi_cache *c);
map_t *(*get_spec_dir_errors)(struct cdi_cache *c);
@@ -65,7 +65,7 @@ struct cdi_cache {
void free_cdi_cache(struct cdi_cache *c);
-struct cdi_cache *cdi_new_cache(string_array *spec_dirs, char **error);
+struct cdi_cache *cdi_new_cache(string_array *spec_dirs);
struct cdi_cache_ops *cdi_get_cache_ops(void);
#ifdef __cplusplus
diff --git a/src/daemon/modules/device/cdi_operate.c b/src/daemon/modules/device/cdi_operate.c
index c7aa77d8..c5187ab1 100644
--- a/src/daemon/modules/device/cdi_operate.c
+++ b/src/daemon/modules/device/cdi_operate.c
@@ -19,17 +19,18 @@ int cdi_operate_registry_init(char **specs_dirs, size_t specs_dirs_len)
return 0;
}
-char *cdi_operate_refresh(void)
+int cdi_operate_refresh(void)
{
- return NULL;
+ return 0;
}
-string_array *cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices, char **error)
+int cdi_operate_inject_devices(oci_runtime_spec *spec, string_array *devices)
{
- return NULL;
+ return 0;
}
-char *cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys, string_array **devices)
+int cdi_operate_parse_annotations(json_map_string_string *annotations, string_array **keys,
+ string_array **devices, char **error)
{
- return NULL;
+ return 0;
}
\ No newline at end of file
--
2.34.1
|