Coverage Report

Created: 2026-08-17 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/configured_snssai.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "configured_snssai.h"
6
7
OpenAPI_configured_snssai_t *OpenAPI_configured_snssai_create(
8
    OpenAPI_snssai_t *configured_snssai,
9
    OpenAPI_snssai_t *mapped_home_snssai
10
)
11
0
{
12
0
    OpenAPI_configured_snssai_t *configured_snssai_local_var = ogs_malloc(sizeof(OpenAPI_configured_snssai_t));
13
0
    ogs_assert(configured_snssai_local_var);
14
15
0
    configured_snssai_local_var->configured_snssai = configured_snssai;
16
0
    configured_snssai_local_var->mapped_home_snssai = mapped_home_snssai;
17
18
0
    return configured_snssai_local_var;
19
0
}
20
21
void OpenAPI_configured_snssai_free(OpenAPI_configured_snssai_t *configured_snssai)
22
0
{
23
0
    OpenAPI_lnode_t *node = NULL;
24
25
0
    if (NULL == configured_snssai) {
26
0
        return;
27
0
    }
28
0
    if (configured_snssai->configured_snssai) {
29
0
        OpenAPI_snssai_free(configured_snssai->configured_snssai);
30
0
        configured_snssai->configured_snssai = NULL;
31
0
    }
32
0
    if (configured_snssai->mapped_home_snssai) {
33
0
        OpenAPI_snssai_free(configured_snssai->mapped_home_snssai);
34
0
        configured_snssai->mapped_home_snssai = NULL;
35
0
    }
36
0
    ogs_free(configured_snssai);
37
0
}
38
39
cJSON *OpenAPI_configured_snssai_convertToJSON(OpenAPI_configured_snssai_t *configured_snssai)
40
0
{
41
0
    cJSON *item = NULL;
42
0
    OpenAPI_lnode_t *node = NULL;
43
44
0
    if (configured_snssai == NULL) {
45
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed [ConfiguredSnssai]");
46
0
        return NULL;
47
0
    }
48
49
0
    item = cJSON_CreateObject();
50
0
    if (!configured_snssai->configured_snssai) {
51
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed [configured_snssai]");
52
0
        return NULL;
53
0
    }
54
0
    cJSON *configured_snssai_local_JSON = OpenAPI_snssai_convertToJSON(configured_snssai->configured_snssai);
55
0
    if (configured_snssai_local_JSON == NULL) {
56
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed [configured_snssai]");
57
0
        goto end;
58
0
    }
59
0
    cJSON_AddItemToObject(item, "configuredSnssai", configured_snssai_local_JSON);
60
0
    if (item->child == NULL) {
61
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed [configured_snssai]");
62
0
        goto end;
63
0
    }
64
65
0
    if (configured_snssai->mapped_home_snssai) {
66
0
    cJSON *mapped_home_snssai_local_JSON = OpenAPI_snssai_convertToJSON(configured_snssai->mapped_home_snssai);
67
0
    if (mapped_home_snssai_local_JSON == NULL) {
68
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed [mapped_home_snssai]");
69
0
        goto end;
70
0
    }
71
0
    cJSON_AddItemToObject(item, "mappedHomeSnssai", mapped_home_snssai_local_JSON);
72
0
    if (item->child == NULL) {
73
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed [mapped_home_snssai]");
74
0
        goto end;
75
0
    }
76
0
    }
77
78
0
end:
79
0
    return item;
80
0
}
81
82
OpenAPI_configured_snssai_t *OpenAPI_configured_snssai_parseFromJSON(cJSON *configured_snssaiJSON)
83
0
{
84
0
    OpenAPI_configured_snssai_t *configured_snssai_local_var = NULL;
85
0
    OpenAPI_lnode_t *node = NULL;
86
0
    cJSON *configured_snssai = NULL;
87
0
    OpenAPI_snssai_t *configured_snssai_local_nonprim = NULL;
88
0
    cJSON *mapped_home_snssai = NULL;
89
0
    OpenAPI_snssai_t *mapped_home_snssai_local_nonprim = NULL;
90
0
    configured_snssai = cJSON_GetObjectItemCaseSensitive(configured_snssaiJSON, "configuredSnssai");
91
0
    if (!configured_snssai) {
92
0
        ogs_error("OpenAPI_configured_snssai_parseFromJSON() failed [configured_snssai]");
93
0
        goto end;
94
0
    }
95
0
    configured_snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(configured_snssai);
96
0
    if (!configured_snssai_local_nonprim) {
97
0
        ogs_error("OpenAPI_snssai_parseFromJSON failed [configured_snssai]");
98
0
        goto end;
99
0
    }
100
101
0
    mapped_home_snssai = cJSON_GetObjectItemCaseSensitive(configured_snssaiJSON, "mappedHomeSnssai");
102
0
    if (mapped_home_snssai) {
103
0
    mapped_home_snssai_local_nonprim = OpenAPI_snssai_parseFromJSON(mapped_home_snssai);
104
0
    if (!mapped_home_snssai_local_nonprim) {
105
0
        ogs_error("OpenAPI_snssai_parseFromJSON failed [mapped_home_snssai]");
106
0
        goto end;
107
0
    }
108
0
    }
109
110
0
    configured_snssai_local_var = OpenAPI_configured_snssai_create (
111
0
        configured_snssai_local_nonprim,
112
0
        mapped_home_snssai ? mapped_home_snssai_local_nonprim : NULL
113
0
    );
114
115
0
    return configured_snssai_local_var;
116
0
end:
117
0
    if (configured_snssai_local_nonprim) {
118
0
        OpenAPI_snssai_free(configured_snssai_local_nonprim);
119
0
        configured_snssai_local_nonprim = NULL;
120
0
    }
121
0
    if (mapped_home_snssai_local_nonprim) {
122
0
        OpenAPI_snssai_free(mapped_home_snssai_local_nonprim);
123
0
        mapped_home_snssai_local_nonprim = NULL;
124
0
    }
125
0
    return NULL;
126
0
}
127
128
OpenAPI_configured_snssai_t *OpenAPI_configured_snssai_copy(OpenAPI_configured_snssai_t *dst, OpenAPI_configured_snssai_t *src)
129
0
{
130
0
    cJSON *item = NULL;
131
0
    char *content = NULL;
132
133
0
    ogs_assert(src);
134
0
    item = OpenAPI_configured_snssai_convertToJSON(src);
135
0
    if (!item) {
136
0
        ogs_error("OpenAPI_configured_snssai_convertToJSON() failed");
137
0
        return NULL;
138
0
    }
139
140
0
    content = cJSON_Print(item);
141
0
    cJSON_Delete(item);
142
143
0
    if (!content) {
144
0
        ogs_error("cJSON_Print() failed");
145
0
        return NULL;
146
0
    }
147
148
0
    item = cJSON_Parse(content);
149
0
    ogs_free(content);
150
0
    if (!item) {
151
0
        ogs_error("cJSON_Parse() failed");
152
0
        return NULL;
153
0
    }
154
155
0
    OpenAPI_configured_snssai_free(dst);
156
0
    dst = OpenAPI_configured_snssai_parseFromJSON(item);
157
0
    cJSON_Delete(item);
158
159
0
    return dst;
160
0
}
161