Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanBeck committed Jan 21, 2010
1 parent 874942e commit babec33
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 52 deletions.
9 changes: 5 additions & 4 deletions plutil/plutil.c
Expand Up @@ -38,7 +38,8 @@ int main(int argc, char *argv[])
FILE *iplist = NULL; FILE *iplist = NULL;
plist_t root_node = NULL; plist_t root_node = NULL;
char *plist_out = NULL; char *plist_out = NULL;
int size = 0; uint32_t size = 0;
int read_size = 0;
char *plist_entire = NULL; char *plist_entire = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
Options *options = parse_arguments(argc, argv); Options *options = parse_arguments(argc, argv);
Expand All @@ -55,7 +56,7 @@ int main(int argc, char *argv[])
return 1; return 1;
stat(options->in_file, filestats); stat(options->in_file, filestats);
plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1)); plist_entire = (char *) malloc(sizeof(char) * (filestats->st_size + 1));
fread(plist_entire, sizeof(char), filestats->st_size, iplist); read_size = fread(plist_entire, sizeof(char), filestats->st_size, iplist);
fclose(iplist); fclose(iplist);




Expand All @@ -64,12 +65,12 @@ int main(int argc, char *argv[])


if (memcmp(plist_entire, "bplist00", 8) == 0) if (memcmp(plist_entire, "bplist00", 8) == 0)
{ {
plist_from_bin(plist_entire, filestats->st_size, &root_node); plist_from_bin(plist_entire, read_size, &root_node);
plist_to_xml(root_node, &plist_out, &size); plist_to_xml(root_node, &plist_out, &size);
} }
else else
{ {
plist_from_xml(plist_entire, filestats->st_size, &root_node); plist_from_xml(plist_entire, read_size, &root_node);
plist_to_bin(root_node, &plist_out, &size); plist_to_bin(root_node, &plist_out, &size);
} }
plist_free(root_node); plist_free(root_node);
Expand Down
5 changes: 2 additions & 3 deletions src/bplist.c
Expand Up @@ -82,7 +82,7 @@ static void byte_convert(uint8_t * address, size_t size)
static uint32_t uint24_from_be(char *buff) static uint32_t uint24_from_be(char *buff)
{ {
uint32_t ret = 0; uint32_t ret = 0;
char *tmp = (char *) &ret; uint8_t *tmp = (uint8_t *) &ret;
memcpy(tmp + 1, buff, 3 * sizeof(char)); memcpy(tmp + 1, buff, 3 * sizeof(char));
byte_convert(tmp, sizeof(uint32_t)); byte_convert(tmp, sizeof(uint32_t));
return ret; return ret;
Expand Down Expand Up @@ -192,7 +192,6 @@ static plist_t parse_unicode_node(char *bnode, uint64_t size)
uint64_t i = 0; uint64_t i = 0;
gunichar2 *unicodestr = NULL; gunichar2 *unicodestr = NULL;
gchar *tmpstr = NULL; gchar *tmpstr = NULL;
int type = 0;
glong items_read = 0; glong items_read = 0;
glong items_written = 0; glong items_written = 0;
GError *error = NULL; GError *error = NULL;
Expand Down Expand Up @@ -858,7 +857,7 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length)
case PLIST_KEY: case PLIST_KEY:
case PLIST_STRING: case PLIST_STRING:
len = strlen(data->strval); len = strlen(data->strval);
type = xmlDetectCharEncoding(data->strval, len); type = xmlDetectCharEncoding((const unsigned char *)data->strval, len);
if (XML_CHAR_ENCODING_UTF8 == type) if (XML_CHAR_ENCODING_UTF8 == type)
{ {
unicodestr = g_utf8_to_utf16(data->strval, len, &items_read, &items_written, &error); unicodestr = g_utf8_to_utf16(data->strval, len, &items_read, &items_written, &error);
Expand Down
36 changes: 2 additions & 34 deletions src/plist.c
Expand Up @@ -414,38 +414,6 @@ void plist_dict_remove_item(plist_t node, const char* key)
return; return;
} }


static char compare_node_value(plist_type type, plist_data_t data, const void *value, uint64_t length)
{
char res = FALSE;
switch (type)
{
case PLIST_BOOLEAN:
res = data->boolval == *((char *) value) ? TRUE : FALSE;
break;
case PLIST_UINT:
res = data->intval == *((uint64_t *) value) ? TRUE : FALSE;
break;
case PLIST_REAL:
res = data->realval == *((double *) value) ? TRUE : FALSE;
break;
case PLIST_KEY:
case PLIST_STRING:
res = !strcmp(data->strval, ((char *) value));
break;
case PLIST_DATA:
res = !memcmp(data->buff, (char *) value, length);
break;
case PLIST_DATE:
res = !memcmp(&(data->timeval), value, sizeof(GTimeVal));
break;
case PLIST_ARRAY:
case PLIST_DICT:
default:
break;
}
return res;
}

plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v) plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)
{ {
plist_t current = plist; plist_t current = plist;
Expand All @@ -458,8 +426,8 @@ plist_t plist_access_pathv(plist_t plist, uint32_t length, va_list v)


if (type == PLIST_ARRAY) if (type == PLIST_ARRAY)
{ {
uint32_t index = va_arg(v, uint32_t); uint32_t n = va_arg(v, uint32_t);
current = plist_array_get_item(current, index); current = plist_array_get_item(current, n);
} }
else if (type == PLIST_DICT) else if (type == PLIST_DICT)
{ {
Expand Down
3 changes: 2 additions & 1 deletion src/xplist.c
Expand Up @@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>


#include <inttypes.h>


#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/tree.h> #include <libxml/tree.h>
Expand Down Expand Up @@ -149,7 +150,7 @@ static void node_to_xml(GNode * node, gpointer xml_struct)


case PLIST_UINT: case PLIST_UINT:
tag = XPLIST_INT; tag = XPLIST_INT;
val = g_strdup_printf("%llu", node_data->intval); val = g_strdup_printf("%"PRIu64, node_data->intval);
break; break;


case PLIST_REAL: case PLIST_REAL:
Expand Down
7 changes: 1 addition & 6 deletions test/plist_cmp.c
Expand Up @@ -43,12 +43,7 @@ static plist_t plist_get_next_sibling(plist_t node)
return (plist_t) g_node_next_sibling((GNode *) node); return (plist_t) g_node_next_sibling((GNode *) node);
} }


static plist_t plist_get_prev_sibling(plist_t node) static char compare_plist(plist_t node_l, plist_t node_r)
{
return (plist_t) g_node_prev_sibling((GNode *) node);
}

char compare_plist(plist_t node_l, plist_t node_r)
{ {
plist_t cur_l = NULL; plist_t cur_l = NULL;
plist_t cur_r = NULL; plist_t cur_r = NULL;
Expand Down
7 changes: 3 additions & 4 deletions test/plist_test.c
Expand Up @@ -35,15 +35,14 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FILE *iplist = NULL; FILE *iplist = NULL;
FILE *oplist = NULL;
plist_t root_node1 = NULL; plist_t root_node1 = NULL;
plist_t root_node2 = NULL; plist_t root_node2 = NULL;
char *plist_xml = NULL; char *plist_xml = NULL;
char *plist_xml2 = NULL; char *plist_xml2 = NULL;
char *plist_bin = NULL; char *plist_bin = NULL;
int size_in = 0; int size_in = 0;
int size_out = 0; uint32_t size_out = 0;
int size_out2 = 0; uint32_t size_out2 = 0;
char *file_in = NULL; char *file_in = NULL;
struct stat *filestats = (struct stat *) malloc(sizeof(struct stat)); struct stat *filestats = (struct stat *) malloc(sizeof(struct stat));
if (argc!= 2) if (argc!= 2)
Expand Down Expand Up @@ -123,7 +122,7 @@ int main(int argc, char *argv[])
free(plist_xml2); free(plist_xml2);
free(filestats); free(filestats);


if (size_in != size_out2) if ((uint32_t)size_in != size_out2)
{ {
printf("Size of input and output is different\n"); printf("Size of input and output is different\n");
printf("Input size : %i\n", size_in); printf("Input size : %i\n", size_in);
Expand Down

0 comments on commit babec33

Please sign in to comment.