Coverage Report

Created: 2026-09-27 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/up_security.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "up_security.h"
6
7
OpenAPI_up_security_t *OpenAPI_up_security_create(
8
    OpenAPI_up_integrity_e up_integr,
9
    OpenAPI_up_confidentiality_e up_confid
10
)
11
0
{
12
0
    OpenAPI_up_security_t *up_security_local_var = ogs_malloc(sizeof(OpenAPI_up_security_t));
13
0
    ogs_assert(up_security_local_var);
14
15
0
    up_security_local_var->up_integr = up_integr;
16
0
    up_security_local_var->up_confid = up_confid;
17
18
0
    return up_security_local_var;
19
0
}
20
21
void OpenAPI_up_security_free(OpenAPI_up_security_t *up_security)
22
0
{
23
0
    OpenAPI_lnode_t *node = NULL;
24
25
0
    if (NULL == up_security) {
26
0
        return;
27
0
    }
28
0
    ogs_free(up_security);
29
0
}
30
31
cJSON *OpenAPI_up_security_convertToJSON(OpenAPI_up_security_t *up_security)
32
0
{
33
0
    cJSON *item = NULL;
34
0
    OpenAPI_lnode_t *node = NULL;
35
36
0
    if (up_security == NULL) {
37
0
        ogs_error("OpenAPI_up_security_convertToJSON() failed [UpSecurity]");
38
0
        return NULL;
39
0
    }
40
41
0
    item = cJSON_CreateObject();
42
0
    if (up_security->up_integr == OpenAPI_up_integrity_NULL) {
43
0
        ogs_error("OpenAPI_up_security_convertToJSON() failed [up_integr]");
44
0
        return NULL;
45
0
    }
46
0
    if (cJSON_AddStringToObject(item, "upIntegr", OpenAPI_up_integrity_ToString(up_security->up_integr)) == NULL) {
47
0
        ogs_error("OpenAPI_up_security_convertToJSON() failed [up_integr]");
48
0
        goto end;
49
0
    }
50
51
0
    if (up_security->up_confid == OpenAPI_up_confidentiality_NULL) {
52
0
        ogs_error("OpenAPI_up_security_convertToJSON() failed [up_confid]");
53
0
        return NULL;
54
0
    }
55
0
    if (cJSON_AddStringToObject(item, "upConfid", OpenAPI_up_confidentiality_ToString(up_security->up_confid)) == NULL) {
56
0
        ogs_error("OpenAPI_up_security_convertToJSON() failed [up_confid]");
57
0
        goto end;
58
0
    }
59
60
0
end:
61
0
    return item;
62
0
}
63
64
OpenAPI_up_security_t *OpenAPI_up_security_parseFromJSON(cJSON *up_securityJSON)
65
0
{
66
0
    OpenAPI_up_security_t *up_security_local_var = NULL;
67
0
    OpenAPI_lnode_t *node = NULL;
68
0
    cJSON *up_integr = NULL;
69
0
    OpenAPI_up_integrity_e up_integrVariable = 0;
70
0
    cJSON *up_confid = NULL;
71
0
    OpenAPI_up_confidentiality_e up_confidVariable = 0;
72
0
    up_integr = cJSON_GetObjectItemCaseSensitive(up_securityJSON, "upIntegr");
73
0
    if (!up_integr) {
74
0
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_integr]");
75
0
        goto end;
76
0
    }
77
0
    if (!cJSON_IsString(up_integr)) {
78
0
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_integr]");
79
0
        goto end;
80
0
    }
81
0
    up_integrVariable = OpenAPI_up_integrity_FromString(up_integr->valuestring);
82
83
0
    up_confid = cJSON_GetObjectItemCaseSensitive(up_securityJSON, "upConfid");
84
0
    if (!up_confid) {
85
0
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_confid]");
86
0
        goto end;
87
0
    }
88
0
    if (!cJSON_IsString(up_confid)) {
89
0
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_confid]");
90
0
        goto end;
91
0
    }
92
0
    up_confidVariable = OpenAPI_up_confidentiality_FromString(up_confid->valuestring);
93
94
0
    up_security_local_var = OpenAPI_up_security_create (
95
0
        up_integrVariable,
96
0
        up_confidVariable
97
0
    );
98
99
0
    return up_security_local_var;
100
0
end:
101
0
    return NULL;
102
0
}
103
104
OpenAPI_up_security_t *OpenAPI_up_security_copy(OpenAPI_up_security_t *dst, OpenAPI_up_security_t *src)
105
0
{
106
0
    cJSON *item = NULL;
107
0
    char *content = NULL;
108
109
0
    ogs_assert(src);
110
0
    item = OpenAPI_up_security_convertToJSON(src);
111
0
    if (!item) {
112
0
        ogs_error("OpenAPI_up_security_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_up_security_free(dst);
132
0
    dst = OpenAPI_up_security_parseFromJSON(item);
133
0
    cJSON_Delete(item);
134
135
0
    return dst;
136
0
}
137