Skip to content

Commit c14ef1f

Browse files
authored
Merge pull request #162 from ityuhui/yh-string-null-1229
Allow cJSON_IsNull() if the string is not mandatory
2 parents 3a13070 + c740f06 commit c14ef1f

File tree

308 files changed

+1331
-1331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+1331
-1331
lines changed

kubernetes/external/cJSON.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ typedef struct internal_hooks
125125
} internal_hooks;
126126

127127
#if defined(_MSC_VER)
128-
/* work around MSVC error C2322: '...' address of dillimport '...' is not static */
128+
/* work around MSVC error C2322: '...' address of dllimport '...' is not static */
129129
static void *internal_malloc(size_t size)
130130
{
131131
return malloc(size);

kubernetes/model/admissionregistration_v1_service_reference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ admissionregistration_v1_service_reference_t *admissionregistration_v1_service_r
119119
// admissionregistration_v1_service_reference->path
120120
cJSON *path = cJSON_GetObjectItemCaseSensitive(admissionregistration_v1_service_referenceJSON, "path");
121121
if (path) {
122-
if(!cJSON_IsString(path))
122+
if(!cJSON_IsString(path) && !cJSON_IsNull(path))
123123
{
124124
goto end; //String
125125
}
@@ -138,7 +138,7 @@ admissionregistration_v1_service_reference_t *admissionregistration_v1_service_r
138138
admissionregistration_v1_service_reference_local_var = admissionregistration_v1_service_reference_create (
139139
strdup(name->valuestring),
140140
strdup(_namespace->valuestring),
141-
path ? strdup(path->valuestring) : NULL,
141+
path && !cJSON_IsNull(path) ? strdup(path->valuestring) : NULL,
142142
port ? port->valuedouble : 0
143143
);
144144

kubernetes/model/admissionregistration_v1_webhook_client_config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ admissionregistration_v1_webhook_client_config_t *admissionregistration_v1_webho
106106
// admissionregistration_v1_webhook_client_config->url
107107
cJSON *url = cJSON_GetObjectItemCaseSensitive(admissionregistration_v1_webhook_client_configJSON, "url");
108108
if (url) {
109-
if(!cJSON_IsString(url))
109+
if(!cJSON_IsString(url) && !cJSON_IsNull(url))
110110
{
111111
goto end; //String
112112
}
@@ -116,7 +116,7 @@ admissionregistration_v1_webhook_client_config_t *admissionregistration_v1_webho
116116
admissionregistration_v1_webhook_client_config_local_var = admissionregistration_v1_webhook_client_config_create (
117117
ca_bundle ? strdup(ca_bundle->valuestring) : NULL,
118118
service ? service_local_nonprim : NULL,
119-
url ? strdup(url->valuestring) : NULL
119+
url && !cJSON_IsNull(url) ? strdup(url->valuestring) : NULL
120120
);
121121

122122
return admissionregistration_v1_webhook_client_config_local_var;

kubernetes/model/apiextensions_v1_service_reference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ apiextensions_v1_service_reference_t *apiextensions_v1_service_reference_parseFr
119119
// apiextensions_v1_service_reference->path
120120
cJSON *path = cJSON_GetObjectItemCaseSensitive(apiextensions_v1_service_referenceJSON, "path");
121121
if (path) {
122-
if(!cJSON_IsString(path))
122+
if(!cJSON_IsString(path) && !cJSON_IsNull(path))
123123
{
124124
goto end; //String
125125
}
@@ -138,7 +138,7 @@ apiextensions_v1_service_reference_t *apiextensions_v1_service_reference_parseFr
138138
apiextensions_v1_service_reference_local_var = apiextensions_v1_service_reference_create (
139139
strdup(name->valuestring),
140140
strdup(_namespace->valuestring),
141-
path ? strdup(path->valuestring) : NULL,
141+
path && !cJSON_IsNull(path) ? strdup(path->valuestring) : NULL,
142142
port ? port->valuedouble : 0
143143
);
144144

kubernetes/model/apiextensions_v1_webhook_client_config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ apiextensions_v1_webhook_client_config_t *apiextensions_v1_webhook_client_config
106106
// apiextensions_v1_webhook_client_config->url
107107
cJSON *url = cJSON_GetObjectItemCaseSensitive(apiextensions_v1_webhook_client_configJSON, "url");
108108
if (url) {
109-
if(!cJSON_IsString(url))
109+
if(!cJSON_IsString(url) && !cJSON_IsNull(url))
110110
{
111111
goto end; //String
112112
}
@@ -116,7 +116,7 @@ apiextensions_v1_webhook_client_config_t *apiextensions_v1_webhook_client_config
116116
apiextensions_v1_webhook_client_config_local_var = apiextensions_v1_webhook_client_config_create (
117117
ca_bundle ? strdup(ca_bundle->valuestring) : NULL,
118118
service ? service_local_nonprim : NULL,
119-
url ? strdup(url->valuestring) : NULL
119+
url && !cJSON_IsNull(url) ? strdup(url->valuestring) : NULL
120120
);
121121

122122
return apiextensions_v1_webhook_client_config_local_var;

kubernetes/model/apiregistration_v1_service_reference.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ apiregistration_v1_service_reference_t *apiregistration_v1_service_reference_par
7979
// apiregistration_v1_service_reference->name
8080
cJSON *name = cJSON_GetObjectItemCaseSensitive(apiregistration_v1_service_referenceJSON, "name");
8181
if (name) {
82-
if(!cJSON_IsString(name))
82+
if(!cJSON_IsString(name) && !cJSON_IsNull(name))
8383
{
8484
goto end; //String
8585
}
@@ -88,7 +88,7 @@ apiregistration_v1_service_reference_t *apiregistration_v1_service_reference_par
8888
// apiregistration_v1_service_reference->_namespace
8989
cJSON *_namespace = cJSON_GetObjectItemCaseSensitive(apiregistration_v1_service_referenceJSON, "namespace");
9090
if (_namespace) {
91-
if(!cJSON_IsString(_namespace))
91+
if(!cJSON_IsString(_namespace) && !cJSON_IsNull(_namespace))
9292
{
9393
goto end; //String
9494
}
@@ -105,8 +105,8 @@ apiregistration_v1_service_reference_t *apiregistration_v1_service_reference_par
105105

106106

107107
apiregistration_v1_service_reference_local_var = apiregistration_v1_service_reference_create (
108-
name ? strdup(name->valuestring) : NULL,
109-
_namespace ? strdup(_namespace->valuestring) : NULL,
108+
name && !cJSON_IsNull(name) ? strdup(name->valuestring) : NULL,
109+
_namespace && !cJSON_IsNull(_namespace) ? strdup(_namespace->valuestring) : NULL,
110110
port ? port->valuedouble : 0
111111
);
112112

kubernetes/model/authentication_v1_token_request.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ authentication_v1_token_request_t *authentication_v1_token_request_parseFromJSON
136136
// authentication_v1_token_request->api_version
137137
cJSON *api_version = cJSON_GetObjectItemCaseSensitive(authentication_v1_token_requestJSON, "apiVersion");
138138
if (api_version) {
139-
if(!cJSON_IsString(api_version))
139+
if(!cJSON_IsString(api_version) && !cJSON_IsNull(api_version))
140140
{
141141
goto end; //String
142142
}
@@ -145,7 +145,7 @@ authentication_v1_token_request_t *authentication_v1_token_request_parseFromJSON
145145
// authentication_v1_token_request->kind
146146
cJSON *kind = cJSON_GetObjectItemCaseSensitive(authentication_v1_token_requestJSON, "kind");
147147
if (kind) {
148-
if(!cJSON_IsString(kind))
148+
if(!cJSON_IsString(kind) && !cJSON_IsNull(kind))
149149
{
150150
goto end; //String
151151
}
@@ -174,8 +174,8 @@ authentication_v1_token_request_t *authentication_v1_token_request_parseFromJSON
174174

175175

176176
authentication_v1_token_request_local_var = authentication_v1_token_request_create (
177-
api_version ? strdup(api_version->valuestring) : NULL,
178-
kind ? strdup(kind->valuestring) : NULL,
177+
api_version && !cJSON_IsNull(api_version) ? strdup(api_version->valuestring) : NULL,
178+
kind && !cJSON_IsNull(kind) ? strdup(kind->valuestring) : NULL,
179179
metadata ? metadata_local_nonprim : NULL,
180180
spec_local_nonprim,
181181
status ? status_local_nonprim : NULL

kubernetes/model/core_v1_endpoint_port.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ core_v1_endpoint_port_t *core_v1_endpoint_port_parseFromJSON(cJSON *core_v1_endp
9494
// core_v1_endpoint_port->app_protocol
9595
cJSON *app_protocol = cJSON_GetObjectItemCaseSensitive(core_v1_endpoint_portJSON, "appProtocol");
9696
if (app_protocol) {
97-
if(!cJSON_IsString(app_protocol))
97+
if(!cJSON_IsString(app_protocol) && !cJSON_IsNull(app_protocol))
9898
{
9999
goto end; //String
100100
}
@@ -103,7 +103,7 @@ core_v1_endpoint_port_t *core_v1_endpoint_port_parseFromJSON(cJSON *core_v1_endp
103103
// core_v1_endpoint_port->name
104104
cJSON *name = cJSON_GetObjectItemCaseSensitive(core_v1_endpoint_portJSON, "name");
105105
if (name) {
106-
if(!cJSON_IsString(name))
106+
if(!cJSON_IsString(name) && !cJSON_IsNull(name))
107107
{
108108
goto end; //String
109109
}
@@ -124,18 +124,18 @@ core_v1_endpoint_port_t *core_v1_endpoint_port_parseFromJSON(cJSON *core_v1_endp
124124
// core_v1_endpoint_port->protocol
125125
cJSON *protocol = cJSON_GetObjectItemCaseSensitive(core_v1_endpoint_portJSON, "protocol");
126126
if (protocol) {
127-
if(!cJSON_IsString(protocol))
127+
if(!cJSON_IsString(protocol) && !cJSON_IsNull(protocol))
128128
{
129129
goto end; //String
130130
}
131131
}
132132

133133

134134
core_v1_endpoint_port_local_var = core_v1_endpoint_port_create (
135-
app_protocol ? strdup(app_protocol->valuestring) : NULL,
136-
name ? strdup(name->valuestring) : NULL,
135+
app_protocol && !cJSON_IsNull(app_protocol) ? strdup(app_protocol->valuestring) : NULL,
136+
name && !cJSON_IsNull(name) ? strdup(name->valuestring) : NULL,
137137
port->valuedouble,
138-
protocol ? strdup(protocol->valuestring) : NULL
138+
protocol && !cJSON_IsNull(protocol) ? strdup(protocol->valuestring) : NULL
139139
);
140140

141141
return core_v1_endpoint_port_local_var;

kubernetes/model/core_v1_event.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
317317
// core_v1_event->action
318318
cJSON *action = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "action");
319319
if (action) {
320-
if(!cJSON_IsString(action))
320+
if(!cJSON_IsString(action) && !cJSON_IsNull(action))
321321
{
322322
goto end; //String
323323
}
@@ -326,7 +326,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
326326
// core_v1_event->api_version
327327
cJSON *api_version = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "apiVersion");
328328
if (api_version) {
329-
if(!cJSON_IsString(api_version))
329+
if(!cJSON_IsString(api_version) && !cJSON_IsNull(api_version))
330330
{
331331
goto end; //String
332332
}
@@ -371,7 +371,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
371371
// core_v1_event->kind
372372
cJSON *kind = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "kind");
373373
if (kind) {
374-
if(!cJSON_IsString(kind))
374+
if(!cJSON_IsString(kind) && !cJSON_IsNull(kind))
375375
{
376376
goto end; //String
377377
}
@@ -389,7 +389,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
389389
// core_v1_event->message
390390
cJSON *message = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "message");
391391
if (message) {
392-
if(!cJSON_IsString(message))
392+
if(!cJSON_IsString(message) && !cJSON_IsNull(message))
393393
{
394394
goto end; //String
395395
}
@@ -407,7 +407,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
407407
// core_v1_event->reason
408408
cJSON *reason = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "reason");
409409
if (reason) {
410-
if(!cJSON_IsString(reason))
410+
if(!cJSON_IsString(reason) && !cJSON_IsNull(reason))
411411
{
412412
goto end; //String
413413
}
@@ -422,7 +422,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
422422
// core_v1_event->reporting_component
423423
cJSON *reporting_component = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "reportingComponent");
424424
if (reporting_component) {
425-
if(!cJSON_IsString(reporting_component))
425+
if(!cJSON_IsString(reporting_component) && !cJSON_IsNull(reporting_component))
426426
{
427427
goto end; //String
428428
}
@@ -431,7 +431,7 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
431431
// core_v1_event->reporting_instance
432432
cJSON *reporting_instance = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "reportingInstance");
433433
if (reporting_instance) {
434-
if(!cJSON_IsString(reporting_instance))
434+
if(!cJSON_IsString(reporting_instance) && !cJSON_IsNull(reporting_instance))
435435
{
436436
goto end; //String
437437
}
@@ -452,31 +452,31 @@ core_v1_event_t *core_v1_event_parseFromJSON(cJSON *core_v1_eventJSON){
452452
// core_v1_event->type
453453
cJSON *type = cJSON_GetObjectItemCaseSensitive(core_v1_eventJSON, "type");
454454
if (type) {
455-
if(!cJSON_IsString(type))
455+
if(!cJSON_IsString(type) && !cJSON_IsNull(type))
456456
{
457457
goto end; //String
458458
}
459459
}
460460

461461

462462
core_v1_event_local_var = core_v1_event_create (
463-
action ? strdup(action->valuestring) : NULL,
464-
api_version ? strdup(api_version->valuestring) : NULL,
463+
action && !cJSON_IsNull(action) ? strdup(action->valuestring) : NULL,
464+
api_version && !cJSON_IsNull(api_version) ? strdup(api_version->valuestring) : NULL,
465465
count ? count->valuedouble : 0,
466466
event_time && !cJSON_IsNull(event_time) ? strdup(event_time->valuestring) : NULL,
467467
first_timestamp && !cJSON_IsNull(first_timestamp) ? strdup(first_timestamp->valuestring) : NULL,
468468
involved_object_local_nonprim,
469-
kind ? strdup(kind->valuestring) : NULL,
469+
kind && !cJSON_IsNull(kind) ? strdup(kind->valuestring) : NULL,
470470
last_timestamp && !cJSON_IsNull(last_timestamp) ? strdup(last_timestamp->valuestring) : NULL,
471-
message ? strdup(message->valuestring) : NULL,
471+
message && !cJSON_IsNull(message) ? strdup(message->valuestring) : NULL,
472472
metadata_local_nonprim,
473-
reason ? strdup(reason->valuestring) : NULL,
473+
reason && !cJSON_IsNull(reason) ? strdup(reason->valuestring) : NULL,
474474
related ? related_local_nonprim : NULL,
475-
reporting_component ? strdup(reporting_component->valuestring) : NULL,
476-
reporting_instance ? strdup(reporting_instance->valuestring) : NULL,
475+
reporting_component && !cJSON_IsNull(reporting_component) ? strdup(reporting_component->valuestring) : NULL,
476+
reporting_instance && !cJSON_IsNull(reporting_instance) ? strdup(reporting_instance->valuestring) : NULL,
477477
series ? series_local_nonprim : NULL,
478478
source ? source_local_nonprim : NULL,
479-
type ? strdup(type->valuestring) : NULL
479+
type && !cJSON_IsNull(type) ? strdup(type->valuestring) : NULL
480480
);
481481

482482
return core_v1_event_local_var;

kubernetes/model/core_v1_event_list.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ core_v1_event_list_t *core_v1_event_list_parseFromJSON(cJSON *core_v1_event_list
124124
// core_v1_event_list->api_version
125125
cJSON *api_version = cJSON_GetObjectItemCaseSensitive(core_v1_event_listJSON, "apiVersion");
126126
if (api_version) {
127-
if(!cJSON_IsString(api_version))
127+
if(!cJSON_IsString(api_version) && !cJSON_IsNull(api_version))
128128
{
129129
goto end; //String
130130
}
@@ -157,7 +157,7 @@ core_v1_event_list_t *core_v1_event_list_parseFromJSON(cJSON *core_v1_event_list
157157
// core_v1_event_list->kind
158158
cJSON *kind = cJSON_GetObjectItemCaseSensitive(core_v1_event_listJSON, "kind");
159159
if (kind) {
160-
if(!cJSON_IsString(kind))
160+
if(!cJSON_IsString(kind) && !cJSON_IsNull(kind))
161161
{
162162
goto end; //String
163163
}
@@ -171,9 +171,9 @@ core_v1_event_list_t *core_v1_event_list_parseFromJSON(cJSON *core_v1_event_list
171171

172172

173173
core_v1_event_list_local_var = core_v1_event_list_create (
174-
api_version ? strdup(api_version->valuestring) : NULL,
174+
api_version && !cJSON_IsNull(api_version) ? strdup(api_version->valuestring) : NULL,
175175
itemsList,
176-
kind ? strdup(kind->valuestring) : NULL,
176+
kind && !cJSON_IsNull(kind) ? strdup(kind->valuestring) : NULL,
177177
metadata ? metadata_local_nonprim : NULL
178178
);
179179

0 commit comments

Comments
 (0)