Coverage Report

Created: 2026-06-30 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/invalid_param.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "invalid_param.h"
6
7
OpenAPI_invalid_param_t *OpenAPI_invalid_param_create(
8
    char *param,
9
    char *reason
10
)
11
0
{
12
0
    OpenAPI_invalid_param_t *invalid_param_local_var = ogs_malloc(sizeof(OpenAPI_invalid_param_t));
13
0
    ogs_assert(invalid_param_local_var);
14
15
0
    invalid_param_local_var->param = param;
16
0
    invalid_param_local_var->reason = reason;
17
18
0
    return invalid_param_local_var;
19
0
}
20
21
void OpenAPI_invalid_param_free(OpenAPI_invalid_param_t *invalid_param)
22
0
{
23
0
    OpenAPI_lnode_t *node = NULL;
24
25
0
    if (NULL == invalid_param) {
26
0
        return;
27
0
    }
28
0
    if (invalid_param->param) {
29
0
        ogs_free(invalid_param->param);
30
0
        invalid_param->param = NULL;
31
0
    }
32
0
    if (invalid_param->reason) {
33
0
        ogs_free(invalid_param->reason);
34
0
        invalid_param->reason = NULL;
35
0
    }
36
0
    ogs_free(invalid_param);
37
0
}
38
39
cJSON *OpenAPI_invalid_param_convertToJSON(OpenAPI_invalid_param_t *invalid_param)
40
0
{
41
0
    cJSON *item = NULL;
42
0
    OpenAPI_lnode_t *node = NULL;
43
44
0
    if (invalid_param == NULL) {
45
0
        ogs_error("OpenAPI_invalid_param_convertToJSON() failed [InvalidParam]");
46
0
        return NULL;
47
0
    }
48
49
0
    item = cJSON_CreateObject();
50
0
    if (!invalid_param->param) {
51
0
        ogs_error("OpenAPI_invalid_param_convertToJSON() failed [param]");
52
0
        return NULL;
53
0
    }
54
0
    if (cJSON_AddStringToObject(item, "param", invalid_param->param) == NULL) {
55
0
        ogs_error("OpenAPI_invalid_param_convertToJSON() failed [param]");
56
0
        goto end;
57
0
    }
58
59
0
    if (invalid_param->reason) {
60
0
    if (cJSON_AddStringToObject(item, "reason", invalid_param->reason) == NULL) {
61
0
        ogs_error("OpenAPI_invalid_param_convertToJSON() failed [reason]");
62
0
        goto end;
63
0
    }
64
0
    }
65
66
0
end:
67
0
    return item;
68
0
}
69
70
OpenAPI_invalid_param_t *OpenAPI_invalid_param_parseFromJSON(cJSON *invalid_paramJSON)
71
0
{
72
0
    OpenAPI_invalid_param_t *invalid_param_local_var = NULL;
73
0
    OpenAPI_lnode_t *node = NULL;
74
0
    cJSON *param = NULL;
75
0
    cJSON *reason = NULL;
76
0
    param = cJSON_GetObjectItemCaseSensitive(invalid_paramJSON, "param");
77
0
    if (!param) {
78
0
        ogs_error("OpenAPI_invalid_param_parseFromJSON() failed [param]");
79
0
        goto end;
80
0
    }
81
0
    if (!cJSON_IsString(param)) {
82
0
        ogs_error("OpenAPI_invalid_param_parseFromJSON() failed [param]");
83
0
        goto end;
84
0
    }
85
86
0
    reason = cJSON_GetObjectItemCaseSensitive(invalid_paramJSON, "reason");
87
0
    if (reason) {
88
0
    if (!cJSON_IsString(reason) && !cJSON_IsNull(reason)) {
89
0
        ogs_error("OpenAPI_invalid_param_parseFromJSON() failed [reason]");
90
0
        goto end;
91
0
    }
92
0
    }
93
94
0
    invalid_param_local_var = OpenAPI_invalid_param_create (
95
0
        ogs_strdup(param->valuestring),
96
0
        reason && !cJSON_IsNull(reason) ? ogs_strdup(reason->valuestring) : NULL
97
0
    );
98
99
0
    return invalid_param_local_var;
100
0
end:
101
0
    return NULL;
102
0
}
103
104
OpenAPI_invalid_param_t *OpenAPI_invalid_param_copy(OpenAPI_invalid_param_t *dst, OpenAPI_invalid_param_t *src)
105
0
{
106
0
    cJSON *item = NULL;
107
0
    char *content = NULL;
108
109
0
    ogs_assert(src);
110
0
    item = OpenAPI_invalid_param_convertToJSON(src);
111
0
    if (!item) {
112
0
        ogs_error("OpenAPI_invalid_param_convertToJSON() failed");
113
0
        return NULL;
114
0
    }
115
116
0
    content = cJSON_Print(item);
117
0
    cJSON_Delete(item);
118
119
0
    if (!content) {
120
0
        ogs_error("cJSON_Print() failed");
121
0
        return NULL;
122
0
    }
123
124
0
    item = cJSON_Parse(content);
125
0
    ogs_free(content);
126
0
    if (!item) {
127
0
        ogs_error("cJSON_Parse() failed");
128
0
        return NULL;
129
0
    }
130
131
0
    OpenAPI_invalid_param_free(dst);
132
0
    dst = OpenAPI_invalid_param_parseFromJSON(item);
133
0
    cJSON_Delete(item);
134
135
0
    return dst;
136
0
}
137