Coverage Report

Created: 2026-10-16 06:49

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
26
{
12
26
    OpenAPI_up_security_t *up_security_local_var = ogs_malloc(sizeof(OpenAPI_up_security_t));
13
26
    ogs_assert(up_security_local_var);
14
15
26
    up_security_local_var->up_integr = up_integr;
16
26
    up_security_local_var->up_confid = up_confid;
17
18
26
    return up_security_local_var;
19
26
}
20
21
void OpenAPI_up_security_free(OpenAPI_up_security_t *up_security)
22
26
{
23
26
    OpenAPI_lnode_t *node = NULL;
24
25
26
    if (NULL == up_security) {
26
0
        return;
27
0
    }
28
26
    ogs_free(up_security);
29
26
}
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
133
{
66
133
    OpenAPI_up_security_t *up_security_local_var = NULL;
67
133
    OpenAPI_lnode_t *node = NULL;
68
133
    cJSON *up_integr = NULL;
69
133
    OpenAPI_up_integrity_e up_integrVariable = 0;
70
133
    cJSON *up_confid = NULL;
71
133
    OpenAPI_up_confidentiality_e up_confidVariable = 0;
72
133
    up_integr = cJSON_GetObjectItemCaseSensitive(up_securityJSON, "upIntegr");
73
133
    if (!up_integr) {
74
9
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_integr]");
75
9
        goto end;
76
9
    }
77
124
    if (!cJSON_IsString(up_integr)) {
78
3
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_integr]");
79
3
        goto end;
80
3
    }
81
121
    up_integrVariable = OpenAPI_up_integrity_FromString(up_integr->valuestring);
82
83
121
    up_confid = cJSON_GetObjectItemCaseSensitive(up_securityJSON, "upConfid");
84
121
    if (!up_confid) {
85
87
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_confid]");
86
87
        goto end;
87
87
    }
88
34
    if (!cJSON_IsString(up_confid)) {
89
8
        ogs_error("OpenAPI_up_security_parseFromJSON() failed [up_confid]");
90
8
        goto end;
91
8
    }
92
26
    up_confidVariable = OpenAPI_up_confidentiality_FromString(up_confid->valuestring);
93
94
26
    up_security_local_var = OpenAPI_up_security_create (
95
26
        up_integrVariable,
96
26
        up_confidVariable
97
26
    );
98
99
26
    return up_security_local_var;
100
107
end:
101
107
    return NULL;
102
34
}
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