mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
Merge branch 'fix_warnings' into 'master'
Fix warnings See merge request GNOME/glib!1758
This commit is contained in:
commit
56cbdb1a66
118
glib/tests/uri.c
118
glib/tests/uri.c
@ -32,59 +32,59 @@ typedef struct
|
|||||||
char *filename;
|
char *filename;
|
||||||
char *hostname;
|
char *hostname;
|
||||||
char *expected_result;
|
char *expected_result;
|
||||||
GConvertError expected_error; /* If failed */
|
gint expected_error; /* If failed */
|
||||||
} FileToUriTest;
|
} FileToUriTest;
|
||||||
|
|
||||||
FileToUriTest
|
FileToUriTest
|
||||||
file_to_uri_tests[] = {
|
file_to_uri_tests[] = {
|
||||||
{ "/etc", NULL, "file:///etc"},
|
{ "/etc", NULL, "file:///etc", 0 },
|
||||||
{ "/etc", "", "file:///etc"},
|
{ "/etc", "", "file:///etc", 0 },
|
||||||
{ "/etc", "otherhost", "file://otherhost/etc"},
|
{ "/etc", "otherhost", "file://otherhost/etc", 0 },
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
{ "/etc", "localhost", "file:///etc"},
|
{ "/etc", "localhost", "file:///etc", 0 },
|
||||||
{ "c:\\windows", NULL, "file:///c:/windows"},
|
{ "c:\\windows", NULL, "file:///c:/windows", 0 },
|
||||||
{ "c:\\windows", "localhost", "file:///c:/windows"},
|
{ "c:\\windows", "localhost", "file:///c:/windows", 0 },
|
||||||
{ "c:\\windows", "otherhost", "file://otherhost/c:/windows"},
|
{ "c:\\windows", "otherhost", "file://otherhost/c:/windows", 0 },
|
||||||
{ "\\\\server\\share\\dir", NULL, "file:////server/share/dir"},
|
{ "\\\\server\\share\\dir", NULL, "file:////server/share/dir", 0 },
|
||||||
{ "\\\\server\\share\\dir", "localhost", "file:////server/share/dir"},
|
{ "\\\\server\\share\\dir", "localhost", "file:////server/share/dir", 0 },
|
||||||
#else
|
#else
|
||||||
{ "/etc", "localhost", "file://localhost/etc"},
|
{ "/etc", "localhost", "file://localhost/etc", 0 },
|
||||||
{ "c:\\windows", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH}, /* it's important to get this error on Unix */
|
{ "c:\\windows", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH}, /* it's important to get this error on Unix */
|
||||||
{ "c:\\windows", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "c:\\windows", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
{ "c:\\windows", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "c:\\windows", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
#endif
|
#endif
|
||||||
{ "etc", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "etc", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
#ifndef G_PLATFORM_WIN32
|
#ifndef G_PLATFORM_WIN32
|
||||||
{ "/etc/\xE5\xE4\xF6", NULL, "file:///etc/%E5%E4%F6" },
|
{ "/etc/\xE5\xE4\xF6", NULL, "file:///etc/%E5%E4%F6", 0 },
|
||||||
{ "/etc/\xC3\xB6\xC3\xA4\xC3\xA5", NULL, "file:///etc/%C3%B6%C3%A4%C3%A5"},
|
{ "/etc/\xC3\xB6\xC3\xA4\xC3\xA5", NULL, "file:///etc/%C3%B6%C3%A4%C3%A5", 0 },
|
||||||
#endif
|
#endif
|
||||||
{ "/etc", "\xC3\xB6\xC3\xA4\xC3\xA5", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
{ "/etc", "\xC3\xB6\xC3\xA4\xC3\xA5", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
||||||
{ "/etc", "\xE5\xE4\xF6", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
{ "/etc", "\xE5\xE4\xF6", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
||||||
{ "/etc/file with #%", NULL, "file:///etc/file%20with%20%23%25"},
|
{ "/etc/file with #%", NULL, "file:///etc/file%20with%20%23%25", 0 },
|
||||||
{ "", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
{ "", "", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "", "", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
{ "", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
{ "", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
{ "", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
|
||||||
{ "/0123456789", NULL, "file:///0123456789"},
|
{ "/0123456789", NULL, "file:///0123456789", 0 },
|
||||||
{ "/ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL, "file:///ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
|
{ "/ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL, "file:///ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0 },
|
||||||
{ "/abcdefghijklmnopqrstuvwxyz", NULL, "file:///abcdefghijklmnopqrstuvwxyz"},
|
{ "/abcdefghijklmnopqrstuvwxyz", NULL, "file:///abcdefghijklmnopqrstuvwxyz", 0 },
|
||||||
{ "/-_.!~*'()", NULL, "file:///-_.!~*'()"},
|
{ "/-_.!~*'()", NULL, "file:///-_.!~*'()", 0 },
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
/* As '\\' is a path separator on Win32, it gets turned into '/' in the URI */
|
/* As '\\' is a path separator on Win32, it gets turned into '/' in the URI */
|
||||||
{ "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B/%5D%5E%60%7B%7C%7D%7F"},
|
{ "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B/%5D%5E%60%7B%7C%7D%7F", 0 },
|
||||||
#else
|
#else
|
||||||
/* On Unix, '\\' is a normal character in the file name */
|
/* On Unix, '\\' is a normal character in the file name */
|
||||||
{ "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F"},
|
{ "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F", 0 },
|
||||||
#endif
|
#endif
|
||||||
{ "/;@+$,", NULL, "file:///%3B@+$,"},
|
{ "/;@+$,", NULL, "file:///%3B@+$,", 0 },
|
||||||
/* This and some of the following are of course as such illegal file names on Windows,
|
/* This and some of the following are of course as such illegal file names on Windows,
|
||||||
* and would not occur in real life.
|
* and would not occur in real life.
|
||||||
*/
|
*/
|
||||||
{ "/:", NULL, "file:///:"},
|
{ "/:", NULL, "file:///:", 0 },
|
||||||
{ "/?&=", NULL, "file:///%3F&="},
|
{ "/?&=", NULL, "file:///%3F&=", 0 },
|
||||||
{ "/", "0123456789-", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
{ "/", "0123456789-", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
||||||
{ "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/"},
|
{ "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/", 0 },
|
||||||
{ "/", "abcdefghijklmnopqrstuvwxyz", "file://abcdefghijklmnopqrstuvwxyz/"},
|
{ "/", "abcdefghijklmnopqrstuvwxyz", "file://abcdefghijklmnopqrstuvwxyz/", 0 },
|
||||||
{ "/", "_.!~*'()", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
{ "/", "_.!~*'()", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
||||||
{ "/", "\"#%<>[\\]^`{|}\x7F", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
{ "/", "\"#%<>[\\]^`{|}\x7F", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
||||||
{ "/", ";?&=+$,", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
{ "/", ";?&=+$,", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
|
||||||
@ -100,31 +100,31 @@ typedef struct
|
|||||||
char *uri;
|
char *uri;
|
||||||
char *expected_filename;
|
char *expected_filename;
|
||||||
char *expected_hostname;
|
char *expected_hostname;
|
||||||
GConvertError expected_error; /* If failed */
|
gint expected_error; /* If failed */
|
||||||
} FileFromUriTest;
|
} FileFromUriTest;
|
||||||
|
|
||||||
FileFromUriTest
|
FileFromUriTest
|
||||||
file_from_uri_tests[] = {
|
file_from_uri_tests[] = {
|
||||||
{ "file:///etc", "/etc"},
|
{ "file:///etc", "/etc", NULL, 0 },
|
||||||
{ "file:/etc", "/etc"},
|
{ "file:/etc", "/etc", NULL, 0 },
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
/* On Win32 we don't return "localhost" hostames, just in case
|
/* On Win32 we don't return "localhost" hostames, just in case
|
||||||
* it isn't recognized anyway.
|
* it isn't recognized anyway.
|
||||||
*/
|
*/
|
||||||
{ "file://localhost/etc", "/etc", NULL},
|
{ "file://localhost/etc", "/etc", NULL, 0 },
|
||||||
{ "file://localhost/etc/%23%25%20file", "/etc/#% file", NULL},
|
{ "file://localhost/etc/%23%25%20file", "/etc/#% file", NULL, 0 },
|
||||||
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", NULL},
|
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", NULL, 0 },
|
||||||
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", NULL},
|
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", NULL, 0 },
|
||||||
#else
|
#else
|
||||||
{ "file://localhost/etc", "/etc", "localhost"},
|
{ "file://localhost/etc", "/etc", "localhost", 0 },
|
||||||
{ "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost"},
|
{ "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost", 0 },
|
||||||
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost"},
|
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost", 0 },
|
||||||
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost"},
|
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost", 0 },
|
||||||
#endif
|
#endif
|
||||||
{ "file://otherhost/etc", "/etc", "otherhost"},
|
{ "file://otherhost/etc", "/etc", "otherhost", 0 },
|
||||||
{ "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"},
|
{ "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost", 0 },
|
||||||
{ "file://%C3%B6%C3%A4%C3%A5/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://%C3%B6%C3%A4%C3%A5/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file:////etc/%C3%B6%C3%C3%C3%A5", "//etc/\xc3\xb6\xc3\xc3\xc3\xa5", NULL},
|
{ "file:////etc/%C3%B6%C3%C3%C3%A5", "//etc/\xc3\xb6\xc3\xc3\xc3\xa5", NULL, 0 },
|
||||||
{ "file://\xE5\xE4\xF6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://\xE5\xE4\xF6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file://%E5%E4%F6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://%E5%E4%F6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
@ -132,25 +132,25 @@ file_from_uri_tests[] = {
|
|||||||
{ "", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file:test", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file:test", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "http://www.yahoo.com/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "http://www.yahoo.com/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file:////etc", "//etc"},
|
{ "file:////etc", "//etc", NULL, 0 },
|
||||||
{ "file://///etc", "///etc"},
|
{ "file://///etc", "///etc", NULL, 0 },
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
/* URIs with backslashes come from some nonstandard application, but accept them anyhow */
|
/* URIs with backslashes come from some nonstandard application, but accept them anyhow */
|
||||||
{ "file:///c:\\foo", "c:\\foo"},
|
{ "file:///c:\\foo", "c:\\foo", NULL, 0 },
|
||||||
{ "file:///c:/foo\\bar", "c:\\foo\\bar"},
|
{ "file:///c:/foo\\bar", "c:\\foo\\bar", NULL, 0 },
|
||||||
/* Accept also the old Netscape drive-letter-and-vertical bar convention */
|
/* Accept also the old Netscape drive-letter-and-vertical bar convention */
|
||||||
{ "file:///c|/foo", "c:\\foo"},
|
{ "file:///c|/foo", "c:\\foo", NULL, 0 },
|
||||||
{ "file:////server/share/dir", "\\\\server\\share\\dir"},
|
{ "file:////server/share/dir", "\\\\server\\share\\dir", NULL, 0 },
|
||||||
{ "file://localhost//server/share/foo", "\\\\server\\share\\foo"},
|
{ "file://localhost//server/share/foo", "\\\\server\\share\\foo", NULL, 0 },
|
||||||
{ "file://otherhost//server/share/foo", "\\\\server\\share\\foo", "otherhost"},
|
{ "file://otherhost//server/share/foo", "\\\\server\\share\\foo", "otherhost", 0 },
|
||||||
#else
|
#else
|
||||||
{ "file:///c:\\foo", "/c:\\foo"},
|
{ "file:///c:\\foo", "/c:\\foo", NULL, 0 },
|
||||||
{ "file:///c:/foo", "/c:/foo"},
|
{ "file:///c:/foo", "/c:/foo", NULL, 0 },
|
||||||
{ "file:////c:/foo", "//c:/foo"},
|
{ "file:////c:/foo", "//c:/foo", NULL, 0 },
|
||||||
#endif
|
#endif
|
||||||
{ "file://0123456789/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://0123456789/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/", "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
|
{ "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/", "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0 },
|
||||||
{ "file://abcdefghijklmnopqrstuvwxyz/", "/", "abcdefghijklmnopqrstuvwxyz"},
|
{ "file://abcdefghijklmnopqrstuvwxyz/", "/", "abcdefghijklmnopqrstuvwxyz", 0 },
|
||||||
{ "file://-_.!~*'()/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://-_.!~*'()/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file://\"<>[\\]^`{|}\x7F/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://\"<>[\\]^`{|}\x7F/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
{ "file://;?&=+$,/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
{ "file://;?&=+$,/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
|
||||||
@ -165,7 +165,7 @@ file_from_uri_tests[] = {
|
|||||||
static void
|
static void
|
||||||
run_file_to_uri_tests (void)
|
run_file_to_uri_tests (void)
|
||||||
{
|
{
|
||||||
int i;
|
gsize i;
|
||||||
gchar *res;
|
gchar *res;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ run_file_to_uri_tests (void)
|
|||||||
static void
|
static void
|
||||||
run_file_from_uri_tests (void)
|
run_file_from_uri_tests (void)
|
||||||
{
|
{
|
||||||
int i;
|
gsize i;
|
||||||
gchar *res;
|
gchar *res;
|
||||||
gchar *hostname;
|
gchar *hostname;
|
||||||
GError *error;
|
GError *error;
|
||||||
@ -269,7 +269,7 @@ safe_strcmp_hostname (const gchar *a, const gchar *b)
|
|||||||
static void
|
static void
|
||||||
run_file_roundtrip_tests (void)
|
run_file_roundtrip_tests (void)
|
||||||
{
|
{
|
||||||
int i;
|
gsize i;
|
||||||
gchar *uri, *hostname, *res;
|
gchar *uri, *hostname, *res;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ typedef struct {
|
|||||||
GUriFlags flags;
|
GUriFlags flags;
|
||||||
/* Outputs */
|
/* Outputs */
|
||||||
gboolean expected_success;
|
gboolean expected_success;
|
||||||
GUriError expected_error_code; /* unused if @expected_success is true */
|
gint expected_error_code; /* unused if @expected_success is true */
|
||||||
const UriParts expected_parts; /* unused if @expected_success is false */
|
const UriParts expected_parts; /* unused if @expected_success is false */
|
||||||
} UriAbsoluteTest;
|
} UriAbsoluteTest;
|
||||||
|
|
||||||
@ -1492,7 +1492,7 @@ test_uri_iter_params (gconstpointer test_data)
|
|||||||
g_test_message ("URI %" G_GSIZE_FORMAT ": %s", i, params_tests[i].uri);
|
g_test_message ("URI %" G_GSIZE_FORMAT ": %s", i, params_tests[i].uri);
|
||||||
|
|
||||||
g_assert (params_tests[i].expected_n_params < 0 ||
|
g_assert (params_tests[i].expected_n_params < 0 ||
|
||||||
params_tests[i].expected_n_params <= G_N_ELEMENTS (params_tests[i].expected_param_key_values) / 2);
|
params_tests[i].expected_n_params <= (gssize) G_N_ELEMENTS (params_tests[i].expected_param_key_values) / 2);
|
||||||
|
|
||||||
/* The tests get run twice: once with the length unspecified, using a
|
/* The tests get run twice: once with the length unspecified, using a
|
||||||
* nul-terminated string; and once with the length specified and a copy of
|
* nul-terminated string; and once with the length specified and a copy of
|
||||||
@ -1559,7 +1559,7 @@ test_uri_parse_params (gconstpointer test_data)
|
|||||||
g_test_message ("URI %" G_GSIZE_FORMAT ": %s", i, params_tests[i].uri);
|
g_test_message ("URI %" G_GSIZE_FORMAT ": %s", i, params_tests[i].uri);
|
||||||
|
|
||||||
g_assert (params_tests[i].expected_n_params < 0 ||
|
g_assert (params_tests[i].expected_n_params < 0 ||
|
||||||
params_tests[i].expected_n_params <= G_N_ELEMENTS (params_tests[i].expected_param_key_values) / 2);
|
params_tests[i].expected_n_params <= (gssize) G_N_ELEMENTS (params_tests[i].expected_param_key_values) / 2);
|
||||||
|
|
||||||
/* The tests get run twice: once with the length unspecified, using a
|
/* The tests get run twice: once with the length unspecified, using a
|
||||||
* nul-terminated string; and once with the length specified and a copy of
|
* nul-terminated string; and once with the length specified and a copy of
|
||||||
@ -1591,7 +1591,7 @@ test_uri_parse_params (gconstpointer test_data)
|
|||||||
g_assert_no_error (err);
|
g_assert_no_error (err);
|
||||||
g_assert_cmpint (g_hash_table_size (params), ==, params_tests[i].expected_n_params);
|
g_assert_cmpint (g_hash_table_size (params), ==, params_tests[i].expected_n_params);
|
||||||
|
|
||||||
for (j = 0; j < params_tests[i].expected_n_params; j += 2)
|
for (j = 0; j < (gsize) params_tests[i].expected_n_params; j += 2)
|
||||||
g_assert_cmpstr (g_hash_table_lookup (params, params_tests[i].expected_param_key_values[j]), ==,
|
g_assert_cmpstr (g_hash_table_lookup (params, params_tests[i].expected_param_key_values[j]), ==,
|
||||||
params_tests[i].expected_param_key_values[j + 1]);
|
params_tests[i].expected_param_key_values[j + 1]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user