summaryrefslogtreecommitdiffstats
path: root/src/xplist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-05-21 00:12:57 +0200
committerGravatar Nikias Bassen2023-05-21 00:12:57 +0200
commitf28cf0f1e51c7554d590cbec56abac46b4a44b4e (patch)
tree4e2e2038fe0b780dd9595deecbe887d89a3e3de8 /src/xplist.c
parentd772fd74d2a52646c34d558220533547725a2298 (diff)
downloadlibplist-f28cf0f1e51c7554d590cbec56abac46b4a44b4e.tar.gz
libplist-f28cf0f1e51c7554d590cbec56abac46b4a44b4e.tar.bz2
Add explicit casts and fix return type mismatches
Diffstat (limited to 'src/xplist.c')
-rw-r--r--src/xplist.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/xplist.c b/src/xplist.c
index 4833a92..66e1dba 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -133,7 +133,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval)
return len;
}
-static int node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth)
+static plist_err_t node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth)
{
plist_data_t node_data = NULL;
@@ -366,7 +366,7 @@ static int node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth)
}
node_t ch;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
- int res = node_to_xml(ch, outbuf, depth+1);
+ plist_err_t res = node_to_xml(ch, outbuf, depth+1);
if (res < 0) return res;
}
@@ -444,7 +444,7 @@ static int num_digits_u(uint64_t i)
return n;
}
-static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth)
+static plist_err_t node_estimate_size(node_t node, uint64_t *size, uint32_t depth)
{
plist_data_t data;
if (!node) {
@@ -532,13 +532,13 @@ static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth)
plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)
{
uint64_t size = 0;
- int res;
+ plist_err_t res;
if (!plist || !plist_xml || !length) {
return PLIST_ERR_INVALID_ARG;
}
- res = node_estimate_size(plist, &size, 0);
+ res = node_estimate_size((node_t)plist, &size, 0);
if (res < 0) {
return res;
}
@@ -552,7 +552,7 @@ plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)
str_buf_append(outbuf, XML_PLIST_PROLOG, sizeof(XML_PLIST_PROLOG)-1);
- res = node_to_xml(plist, &outbuf, 0);
+ res = node_to_xml((node_t)plist, &outbuf, 0);
if (res < 0) {
str_buf_free(outbuf);
*plist_xml = NULL;
@@ -562,7 +562,7 @@ plist_err_t plist_to_xml(plist_t plist, char **plist_xml, uint32_t * length)
str_buf_append(outbuf, XML_PLIST_EPILOG, sizeof(XML_PLIST_EPILOG));
- *plist_xml = outbuf->data;
+ *plist_xml = (char*)outbuf->data;
*length = outbuf->len - 1;
outbuf->data = NULL;
@@ -671,14 +671,14 @@ static void text_parts_free(text_part_t *tp)
{
while (tp) {
text_part_t *tmp = tp;
- tp = tp->next;
+ tp = (text_part_t*)tp->next;
free(tmp);
}
}
static text_part_t* text_part_append(text_part_t* parts, const char *begin, size_t length, int is_cdata)
{
- text_part_t* newpart = malloc(sizeof(text_part_t));
+ text_part_t* newpart = (text_part_t*)malloc(sizeof(text_part_t));
assert(newpart);
parts->next = text_part_init(newpart, begin, length, is_cdata);
return newpart;
@@ -930,9 +930,9 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
text_part_t *tmp = tp;
while (tp && tp->begin) {
total_length += tp->length;
- tp = tp->next;
+ tp = (text_part_t*)tp->next;
}
- str = malloc(total_length + 1);
+ str = (char*)malloc(total_length + 1);
assert(str);
p = str;
tp = tmp;
@@ -947,7 +947,7 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
}
}
p += len;
- tp = tp->next;
+ tp = (text_part_t*)tp->next;
}
*p = '\0';
if (length) {
@@ -959,7 +959,7 @@ static char* text_parts_get_content(text_part_t *tp, int unesc_entities, size_t
return str;
}
-static int node_from_xml(parse_ctx ctx, plist_t *plist)
+static plist_err_t node_from_xml(parse_ctx ctx, plist_t *plist)
{
char *tag = NULL;
char *keyname = NULL;
@@ -1067,7 +1067,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
goto err_out;
}
int taglen = ctx->pos - p;
- tag = malloc(taglen + 1);
+ tag = (char*)malloc(taglen + 1);
strncpy(tag, p, taglen);
tag[taglen] = '\0';
if (*ctx->pos != '>') {
@@ -1105,7 +1105,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
goto err_out;
}
- struct node_path_item *path_item = malloc(sizeof(struct node_path_item));
+ struct node_path_item *path_item = (struct node_path_item*)malloc(sizeof(struct node_path_item));
if (!path_item) {
PLIST_XML_ERR("out of memory when allocating node path item\n");
ctx->err++;
@@ -1133,7 +1133,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
goto err_out;
}
struct node_path_item *path_item = node_path;
- node_path = node_path->prev;
+ node_path = (struct node_path_item*)node_path->prev;
free(path_item);
free(tag);
@@ -1156,7 +1156,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
if (!tp) {
PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1165,7 +1165,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free);
if (!str_content) {
PLIST_XML_ERR("Could not get text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1194,7 +1194,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
} else {
is_empty = 1;
}
- text_parts_free(tp->next);
+ text_parts_free((text_part_t*)tp->next);
}
if (is_empty) {
data->intval = 0;
@@ -1207,7 +1207,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
if (!tp) {
PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1216,7 +1216,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free);
if (!str_content) {
PLIST_XML_ERR("Could not get text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1225,7 +1225,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
free(str_content);
}
}
- text_parts_free(tp->next);
+ text_parts_free((text_part_t*)tp->next);
}
data->type = PLIST_REAL;
data->length = 8;
@@ -1251,12 +1251,12 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
size_t length = 0;
if (!tp) {
PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
str = text_parts_get_content(tp, 1, &length, NULL);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
if (!str) {
PLIST_XML_ERR("Could not get text content for '%s' node\n", tag);
ctx->err++;
@@ -1284,7 +1284,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
if (!tp) {
PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1293,7 +1293,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
char *str_content = text_parts_get_content(tp, 0, NULL, &requires_free);
if (!str_content) {
PLIST_XML_ERR("Could not get text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1307,7 +1307,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
free(str_content);
}
}
- text_parts_free(tp->next);
+ text_parts_free((text_part_t*)tp->next);
}
data->type = PLIST_DATA;
} else if (!strcmp(tag, XPLIST_DATE)) {
@@ -1316,7 +1316,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
text_part_t *tp = get_text_parts(ctx, tag, taglen, 1, &first_part);
if (!tp) {
PLIST_XML_ERR("Could not parse text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1327,7 +1327,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
char *str_content = text_parts_get_content(tp, 0, &length, &requires_free);
if (!str_content) {
PLIST_XML_ERR("Could not get text content for '%s' node\n", tag);
- text_parts_free(first_part.next);
+ text_parts_free((text_part_t*)first_part.next);
ctx->err++;
goto err_out;
}
@@ -1347,7 +1347,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
free(str_content);
}
}
- text_parts_free(tp->next);
+ text_parts_free((text_part_t*)tp->next);
data->realval = (double)(timev - MAC_EPOCH);
}
data->length = sizeof(double);
@@ -1391,7 +1391,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
}
}
if (!is_empty && (data->type == PLIST_DICT || data->type == PLIST_ARRAY)) {
- struct node_path_item *path_item = malloc(sizeof(struct node_path_item));
+ struct node_path_item *path_item = (struct node_path_item*)malloc(sizeof(struct node_path_item));
if (!path_item) {
PLIST_XML_ERR("out of memory when allocating node path item\n");
ctx->err++;
@@ -1416,7 +1416,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
goto err_out;
}
struct node_path_item *path_item = node_path;
- node_path = node_path->prev;
+ node_path = (struct node_path_item*)node_path->prev;
free(path_item);
parent = ((node_t)parent)->parent;
@@ -1447,7 +1447,7 @@ err_out:
/* clean up node_path if required */
while (node_path) {
struct node_path_item *path_item = node_path;
- node_path = path_item->prev;
+ node_path = (struct node_path_item*)path_item->prev;
free(path_item);
}