Coverage Report

Created: 2026-11-06 06:15

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