From: <svn...@op...> - 2009-07-13 12:38:46
|
Author: bellmich Date: Mon Jul 13 14:38:38 2009 New Revision: 1185 URL: http://libsyncml.opensync.org/changeset/1185 Log: - fixed wrong GError handling - fixed wrong error detection code in XML parser Modified: trunk/libsyncml/parser/sml_xml_parse.c trunk/tests/check_xml_fix_broken_item_data.c trunk/tests/support.h Modified: trunk/libsyncml/parser/sml_xml_parse.c ============================================================================== --- trunk/libsyncml/parser/sml_xml_parse.c Mon Jul 13 14:37:49 2009 (r1184) +++ trunk/libsyncml/parser/sml_xml_parse.c Mon Jul 13 14:38:38 2009 (r1185) @@ -1864,14 +1864,14 @@ /* convert the whole strong to UTF-8 */ smlTrace(TRACE_INTERNAL, "%s: Converting %d bytes ...", __func__, last_utf16 - position + 1); - size_t read_bytes = 0; - size_t written_bytes = 0; + gsize read_bytes = 0; + gsize written_bytes = 0; gchar *conv_string = g_convert( position, (last_utf16 - position + 1), "UTF-8", "UTF-16", &read_bytes, &written_bytes, error); - if (error != NULL) + if (*error != NULL) { GError *ext = NULL; g_set_error(&ext, SML_ERROR, SML_ERROR_GENERIC, Modified: trunk/tests/check_xml_fix_broken_item_data.c ============================================================================== --- trunk/tests/check_xml_fix_broken_item_data.c Mon Jul 13 14:37:49 2009 (r1184) +++ trunk/tests/check_xml_fix_broken_item_data.c Mon Jul 13 14:38:38 2009 (r1185) @@ -36,8 +36,8 @@ input_data, strlen(input_data), &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(fixed_size == strlen(input_data), "The data must not be fixed (size has changed)."); sml_fail_unless(strcmp(input_data, fixed_data) == 0, "The data must not be fixed."); g_free(fixed_data); @@ -57,8 +57,8 @@ input_data, strlen(input_data), &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(fixed_size == strlen(input_data), "The data must not be fixed (size has changed)."); sml_fail_unless(strcmp(input_data, fixed_data) == 0, "The data must not be fixed."); g_free(fixed_data); @@ -78,8 +78,8 @@ input_data, strlen(input_data), &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(fixed_size == strlen(input_data), "The data must not be fixed (size has changed)."); sml_fail_unless(strcmp(input_data, fixed_data) == 0, "The data must not be fixed."); g_free(fixed_data); @@ -100,8 +100,8 @@ input_data, strlen(input_data), &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); /* compare it and check the expected length */ sml_fail_unless(fixed_size != strlen(input_data), "The data must be fixed (size has not changed)."); @@ -129,8 +129,8 @@ input_data, strlen(input_data), &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); /* compare it and check the expected length */ sml_fail_unless(fixed_size != strlen(input_data), "The data must be fixed (size has not changed)."); @@ -164,8 +164,8 @@ input_data, strlen(input_data), &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); /* compare it and check the expected length */ sml_fail_unless(fixed_size != strlen(input_data), "The data must be fixed (size has not changed)."); @@ -181,7 +181,7 @@ { GError *error = NULL; char *input_data = smlTryMalloc0(20, &error); - sml_fail_unless(error == NULL, "%s", error->message); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); input_data[0] = 65; /* A */ input_data[1] = 66; /* B */ input_data[3] = 67; /* C */ @@ -192,10 +192,10 @@ input_data[10] = 72; /* H */ input_data[12] = 73; /* I */ input_data[13] = 74; /* J */ - size_t length = 14; + gsize length = 14; char *fixed_data = NULL; - unsigned int fixed_size = 0; + gsize fixed_size = 0; /* check UTF-16 conversion of_smlXmlParserFixBrokenItemData */ @@ -204,8 +204,8 @@ input_data, length, &fixed_data, &fixed_size, &error), - "%s", error->message); - sml_fail_unless(error == NULL, "%s", error->message); + "%s", GET_ERROR_MESSAGE(error)); + sml_fail_unless(error == NULL, "%s", GET_ERROR_MESSAGE(error)); sml_fail_unless(fixed_size == strlen("ABCDEFGHIJ"), "%d != %d", fixed_size, strlen("ABCDEFGHIJ")); sml_fail_unless(strcmp(fixed_data, "ABCDEFGHIJ") == 0, NULL); g_free(input_data); Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Mon Jul 13 14:37:49 2009 (r1184) +++ trunk/tests/support.h Mon Jul 13 14:38:38 2009 (r1185) @@ -115,4 +115,6 @@ ct = NULL; \ } +#define GET_ERROR_MESSAGE(error) error?error->message:"No GError set." + #endif // _TESTS_SUPPORT_H |