mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
Merge branch 'live-file-static-analysis' into 'master'
Minor fixes from a scan-build run See merge request GNOME/glib!1200
This commit is contained in:
commit
8b43be0f7a
@ -504,7 +504,10 @@ get_xattrs (const char *path,
|
||||
}
|
||||
|
||||
if (list_res_size == -1)
|
||||
return;
|
||||
{
|
||||
g_free (list);
|
||||
return;
|
||||
}
|
||||
|
||||
attr = list;
|
||||
while (list_res_size > 0)
|
||||
|
@ -138,12 +138,12 @@ create_empty_file (GFile * parent, const char *filename,
|
||||
GFileOutputStream *outs;
|
||||
|
||||
child = g_file_get_child (parent, filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
|
||||
error = NULL;
|
||||
outs = g_file_replace (child, NULL, FALSE, create_flags, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (outs != NULL);
|
||||
g_assert_nonnull (outs);
|
||||
error = NULL;
|
||||
g_output_stream_close (G_OUTPUT_STREAM (outs), NULL, &error);
|
||||
g_object_unref (outs);
|
||||
@ -158,10 +158,10 @@ create_empty_dir (GFile * parent, const char *filename)
|
||||
GError *error;
|
||||
|
||||
child = g_file_get_child (parent, filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
error = NULL;
|
||||
res = g_file_make_directory (child, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
return child;
|
||||
}
|
||||
@ -174,10 +174,10 @@ create_symlink (GFile * parent, const char *filename, const char *points_to)
|
||||
GError *error;
|
||||
|
||||
child = g_file_get_child (parent, filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
error = NULL;
|
||||
res = g_file_make_symbolic_link (child, points_to, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
return child;
|
||||
}
|
||||
@ -188,22 +188,22 @@ test_create_structure (gconstpointer test_data)
|
||||
GFile *root;
|
||||
GFile *child;
|
||||
gboolean res;
|
||||
GError *error;
|
||||
GError *error = NULL;
|
||||
GFileOutputStream *outs;
|
||||
GDataOutputStream *outds;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Going to create testing structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
|
||||
/* create root directory */
|
||||
res = g_file_make_directory (root, NULL, NULL);
|
||||
/* don't care about errors here */
|
||||
g_file_make_directory (root, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
/* create any other items */
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
@ -237,17 +237,16 @@ test_create_structure (gconstpointer test_data)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
|
||||
if ((item.mode > 0) && (posix_compat))
|
||||
{
|
||||
error = NULL;
|
||||
res =
|
||||
g_file_set_attribute_uint32 (child, G_FILE_ATTRIBUTE_UNIX_MODE,
|
||||
item.mode,
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
@ -275,24 +274,22 @@ test_create_structure (gconstpointer test_data)
|
||||
/* create a pattern file */
|
||||
log (" Creating pattern file...");
|
||||
child = g_file_get_child (root, "pattern_file");
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
|
||||
error = NULL;
|
||||
outs =
|
||||
g_file_replace (child, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert (outs != NULL);
|
||||
g_assert_nonnull (outs);
|
||||
outds = g_data_output_stream_new (G_OUTPUT_STREAM (outs));
|
||||
g_assert (outds != NULL);
|
||||
g_assert_nonnull (outds);
|
||||
for (i = 0; i < PATTERN_FILE_SIZE; i++)
|
||||
{
|
||||
error = NULL;
|
||||
res = g_data_output_stream_put_byte (outds, i % 256, NULL, &error);
|
||||
g_data_output_stream_put_byte (outds, i % 256, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
error = NULL;
|
||||
res = g_output_stream_close (G_OUTPUT_STREAM (outs), NULL, &error);
|
||||
|
||||
g_output_stream_close (G_OUTPUT_STREAM (outs), NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_object_unref (outds);
|
||||
g_object_unref (outs);
|
||||
@ -312,7 +309,7 @@ file_exists (GFile * parent, const char *filename, gboolean * result)
|
||||
*result = FALSE;
|
||||
|
||||
child = g_file_get_child (parent, filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
res = g_file_query_exists (child, NULL);
|
||||
if (result)
|
||||
*result = res;
|
||||
@ -334,7 +331,7 @@ test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
|
||||
/* standard::type */
|
||||
has_attr = g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_TYPE);
|
||||
g_assert_cmpint (has_attr, ==, TRUE);
|
||||
g_assert_true (has_attr);
|
||||
ftype = g_file_info_get_file_type (info);
|
||||
g_assert_cmpint (ftype, !=, G_FILE_TYPE_UNKNOWN);
|
||||
g_assert_cmpint (ftype, ==, item.file_type);
|
||||
@ -354,7 +351,7 @@ test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
can_read =
|
||||
g_file_info_get_attribute_boolean (info,
|
||||
G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
|
||||
g_assert_cmpint (can_read, ==, TRUE);
|
||||
g_assert_true (can_read);
|
||||
}
|
||||
|
||||
/* access::can-write */
|
||||
@ -363,25 +360,25 @@ test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
can_write =
|
||||
g_file_info_get_attribute_boolean (info,
|
||||
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
|
||||
g_assert_cmpint (can_write, ==, TRUE);
|
||||
g_assert_true (can_write);
|
||||
}
|
||||
|
||||
/* standard::name */
|
||||
name = g_file_info_get_name (info);
|
||||
g_assert (name != NULL);
|
||||
g_assert_nonnull (name);
|
||||
|
||||
/* standard::display-name */
|
||||
display_name = g_file_info_get_display_name (info);
|
||||
g_assert (display_name != NULL);
|
||||
g_assert_nonnull (display_name);
|
||||
utf8_valid = g_utf8_validate (display_name, -1, NULL);
|
||||
g_assert_cmpint (utf8_valid, ==, TRUE);
|
||||
g_assert_true (utf8_valid);
|
||||
|
||||
/* standard::edit-name */
|
||||
edit_name = g_file_info_get_edit_name (info);
|
||||
if (edit_name)
|
||||
{
|
||||
utf8_valid = g_utf8_validate (edit_name, -1, NULL);
|
||||
g_assert_cmpint (utf8_valid, ==, TRUE);
|
||||
g_assert_true (utf8_valid);
|
||||
}
|
||||
|
||||
/* standard::copy-name */
|
||||
@ -391,7 +388,7 @@ test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
if (copy_name)
|
||||
{
|
||||
utf8_valid = g_utf8_validate (copy_name, -1, NULL);
|
||||
g_assert_cmpint (utf8_valid, ==, TRUE);
|
||||
g_assert_true (utf8_valid);
|
||||
}
|
||||
|
||||
/* standard::is-symlink */
|
||||
@ -415,7 +412,7 @@ test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
is_hidden =
|
||||
g_file_info_get_attribute_boolean (info,
|
||||
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN);
|
||||
g_assert_cmpint (is_hidden, ==, TRUE);
|
||||
g_assert_true (is_hidden);
|
||||
}
|
||||
|
||||
/* unix::is-mountpoint */
|
||||
@ -443,14 +440,13 @@ test_initial_structure (gconstpointer test_data)
|
||||
gssize read, total_read;
|
||||
struct StructureItem item;
|
||||
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Testing sample structure in '%s'...\n", (char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
/* test the structure */
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
@ -463,15 +459,15 @@ test_initial_structure (gconstpointer test_data)
|
||||
log (" Testing file '%s'...\n", item.filename);
|
||||
|
||||
child = file_exists (root, item.filename, &res);
|
||||
g_assert (child != NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_nonnull (child);
|
||||
g_assert_true (res);
|
||||
|
||||
error = NULL;
|
||||
info =
|
||||
g_file_query_info (child, "*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (info != NULL);
|
||||
g_assert_nonnull (info);
|
||||
|
||||
test_attributes (item, info);
|
||||
|
||||
@ -482,22 +478,22 @@ test_initial_structure (gconstpointer test_data)
|
||||
/* read and test the pattern file */
|
||||
log (" Testing pattern file...\n");
|
||||
child = file_exists (root, "pattern_file", &res);
|
||||
g_assert (child != NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_nonnull (child);
|
||||
g_assert_true (res);
|
||||
|
||||
error = NULL;
|
||||
info =
|
||||
g_file_query_info (child, "*", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL,
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (info != NULL);
|
||||
g_assert_nonnull (info);
|
||||
size = g_file_info_get_size (info);
|
||||
g_assert_cmpint (size, ==, PATTERN_FILE_SIZE);
|
||||
g_object_unref (info);
|
||||
|
||||
error = NULL;
|
||||
ins = g_file_read (child, NULL, &error);
|
||||
g_assert (ins != NULL);
|
||||
g_assert_nonnull (ins);
|
||||
g_assert_no_error (error);
|
||||
|
||||
buffer = g_malloc (PATTERN_FILE_SIZE);
|
||||
@ -519,7 +515,7 @@ test_initial_structure (gconstpointer test_data)
|
||||
error = NULL;
|
||||
res = g_input_stream_close (G_INPUT_STREAM (ins), NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
for (i = 0; i < PATTERN_FILE_SIZE; i++)
|
||||
g_assert_cmpint (*(buffer + i), ==, i % 256);
|
||||
@ -542,26 +538,26 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
guint i;
|
||||
gboolean found;
|
||||
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
|
||||
error = NULL;
|
||||
enumerator =
|
||||
g_file_enumerate_children (parent, "*",
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL,
|
||||
&error);
|
||||
g_assert (enumerator != NULL);
|
||||
g_assert_nonnull (enumerator);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert (g_file_enumerator_get_container (enumerator) == parent);
|
||||
g_assert_true (g_file_enumerator_get_container (enumerator) == parent);
|
||||
|
||||
error = NULL;
|
||||
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
||||
while ((info) && (!error))
|
||||
{
|
||||
descend = g_file_enumerator_get_child (enumerator, info);
|
||||
g_assert (descend != NULL);
|
||||
g_assert_nonnull (descend);
|
||||
relative_path = g_file_get_relative_path (root, descend);
|
||||
g_assert (relative_path != NULL);
|
||||
g_assert_nonnull (relative_path);
|
||||
|
||||
found = FALSE;
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
@ -575,7 +571,7 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_assert_cmpint (found, ==, TRUE);
|
||||
g_assert_true (found);
|
||||
|
||||
log (" Found file %s, relative to root: %s\n",
|
||||
g_file_info_get_display_name (info), relative_path);
|
||||
@ -594,9 +590,9 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
|
||||
error = NULL;
|
||||
res = g_file_enumerator_close (enumerator, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
g_assert (g_file_enumerator_is_closed (enumerator));
|
||||
g_assert_true (g_file_enumerator_is_closed (enumerator));
|
||||
|
||||
g_object_unref (enumerator);
|
||||
}
|
||||
@ -607,14 +603,14 @@ test_traverse_structure (gconstpointer test_data)
|
||||
GFile *root;
|
||||
gboolean res;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Traversing through the sample structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
traverse_recurse_dirs (root, root);
|
||||
|
||||
@ -636,13 +632,13 @@ test_enumerate (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Test enumerate '%s'...\n", (char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
@ -659,7 +655,7 @@ test_enumerate (gconstpointer test_data)
|
||||
{
|
||||
log (" Testing file '%s'\n", item.filename);
|
||||
child = g_file_get_child (root, item.filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
error = NULL;
|
||||
enumerator =
|
||||
g_file_enumerate_children (child, "*",
|
||||
@ -668,21 +664,21 @@ test_enumerate (gconstpointer test_data)
|
||||
|
||||
if ((item.extra_flags & TEST_NOT_EXISTS) == TEST_NOT_EXISTS)
|
||||
{
|
||||
g_assert (enumerator == NULL);
|
||||
g_assert_null (enumerator);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
||||
}
|
||||
if ((item.extra_flags & TEST_ENUMERATE_FILE) == TEST_ENUMERATE_FILE)
|
||||
{
|
||||
g_assert (enumerator == NULL);
|
||||
g_assert_null (enumerator);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY);
|
||||
}
|
||||
if ((item.extra_flags & TEST_NO_ACCESS) == TEST_NO_ACCESS)
|
||||
{
|
||||
g_assert (enumerator != NULL);
|
||||
g_assert_nonnull (enumerator);
|
||||
|
||||
error = NULL;
|
||||
info = g_file_enumerator_next_file (enumerator, NULL, &error);
|
||||
g_assert (info == NULL);
|
||||
g_assert_null (info);
|
||||
g_assert_no_error (error);
|
||||
/* no items should be found, no error should be logged */
|
||||
}
|
||||
@ -694,7 +690,7 @@ test_enumerate (gconstpointer test_data)
|
||||
{
|
||||
error = NULL;
|
||||
res = g_file_enumerator_close (enumerator, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_object_unref (enumerator);
|
||||
@ -716,11 +712,11 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
log (" do_copy_move: '%s' --> '%s'\n", item.filename, target_dir);
|
||||
|
||||
dst_dir = g_file_get_child (root, target_dir);
|
||||
g_assert (dst_dir != NULL);
|
||||
g_assert_nonnull (dst_dir);
|
||||
src_file = g_file_get_child (root, item.filename);
|
||||
g_assert (src_file != NULL);
|
||||
g_assert_nonnull (src_file);
|
||||
dst_file = g_file_get_child (dst_dir, item.filename);
|
||||
g_assert (dst_file != NULL);
|
||||
g_assert_nonnull (dst_file);
|
||||
|
||||
error = NULL;
|
||||
if ((item.extra_flags & TEST_COPY) == TEST_COPY)
|
||||
@ -743,28 +739,28 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
if (((item.extra_flags & TEST_NOT_EXISTS) != TEST_NOT_EXISTS) &&
|
||||
(extra_flags == TEST_ALREADY_EXISTS))
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS);
|
||||
}
|
||||
/* target file is a file, overwrite is not set */
|
||||
else if (((item.extra_flags & TEST_NOT_EXISTS) != TEST_NOT_EXISTS) &&
|
||||
(extra_flags == TEST_TARGET_IS_FILE))
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY);
|
||||
}
|
||||
/* source file is directory */
|
||||
else if ((item.extra_flags & TEST_COPY_ERROR_RECURSE) ==
|
||||
TEST_COPY_ERROR_RECURSE)
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_WOULD_RECURSE);
|
||||
}
|
||||
/* source or target path doesn't exist */
|
||||
else if (((item.extra_flags & TEST_NOT_EXISTS) == TEST_NOT_EXISTS) ||
|
||||
(extra_flags == TEST_NOT_EXISTS))
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
||||
}
|
||||
/* source or target path permission denied */
|
||||
@ -774,19 +770,19 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
/* This works for root, see bug #552912 */
|
||||
if (test_suite && getuid () == 0)
|
||||
{
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED);
|
||||
}
|
||||
}
|
||||
/* no error should be found, all exceptions defined above */
|
||||
else
|
||||
{
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
@ -809,11 +805,11 @@ test_copy_move (gconstpointer test_data)
|
||||
|
||||
log ("\n");
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
@ -899,13 +895,13 @@ test_create (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
GFileOutputStream *os;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n");
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
@ -918,7 +914,7 @@ test_create (gconstpointer test_data)
|
||||
log (" test_create: '%s'\n", item.filename);
|
||||
|
||||
child = g_file_get_child (root, item.filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
error = NULL;
|
||||
os = NULL;
|
||||
|
||||
@ -938,12 +934,12 @@ test_create (gconstpointer test_data)
|
||||
if (((item.extra_flags & TEST_NOT_EXISTS) == 0) &&
|
||||
((item.extra_flags & TEST_CREATE) == TEST_CREATE))
|
||||
{
|
||||
g_assert (os == NULL);
|
||||
g_assert_null (os);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS);
|
||||
}
|
||||
else if (item.file_type == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
g_assert (os == NULL);
|
||||
g_assert_null (os);
|
||||
if ((item.extra_flags & TEST_CREATE) == TEST_CREATE)
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS);
|
||||
else
|
||||
@ -951,7 +947,7 @@ test_create (gconstpointer test_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert (os != NULL);
|
||||
g_assert_nonnull (os);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
@ -966,7 +962,7 @@ test_create (gconstpointer test_data)
|
||||
if (error)
|
||||
log (" g_output_stream_close: error %d = %s\n",
|
||||
error->code, error->message);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
g_object_unref (os);
|
||||
}
|
||||
@ -986,13 +982,13 @@ test_open (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
GFileInputStream *input_stream;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n");
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
@ -1006,7 +1002,7 @@ test_open (gconstpointer test_data)
|
||||
log (" test_open: '%s'\n", item.filename);
|
||||
|
||||
child = g_file_get_child (root, item.filename);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
error = NULL;
|
||||
input_stream = g_file_read (child, NULL, &error);
|
||||
|
||||
@ -1014,17 +1010,17 @@ test_open (gconstpointer test_data)
|
||||
((item.extra_flags & TEST_INVALID_SYMLINK) ==
|
||||
TEST_INVALID_SYMLINK))
|
||||
{
|
||||
g_assert (input_stream == NULL);
|
||||
g_assert_null (input_stream);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
||||
}
|
||||
else if (item.file_type == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
g_assert (input_stream == NULL);
|
||||
g_assert_null (input_stream);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_assert (input_stream != NULL);
|
||||
g_assert_nonnull (input_stream);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
@ -1037,7 +1033,7 @@ test_open (gconstpointer test_data)
|
||||
res =
|
||||
g_input_stream_close (G_INPUT_STREAM (input_stream), NULL,
|
||||
&error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
g_object_unref (input_stream);
|
||||
}
|
||||
@ -1058,13 +1054,13 @@ test_delete (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
gchar *path;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n");
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
@ -1077,7 +1073,7 @@ test_delete (gconstpointer test_data)
|
||||
((item.extra_flags & TEST_DELETE_TRASH) == TEST_DELETE_TRASH))
|
||||
{
|
||||
child = file_exists (root, item.filename, &res);
|
||||
g_assert (child != NULL);
|
||||
g_assert_nonnull (child);
|
||||
/* we don't care about result here */
|
||||
|
||||
path = g_file_get_path (child);
|
||||
@ -1093,17 +1089,17 @@ test_delete (gconstpointer test_data)
|
||||
if ((item.extra_flags & TEST_DELETE_NON_EMPTY) ==
|
||||
TEST_DELETE_NON_EMPTY)
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY);
|
||||
}
|
||||
if ((item.extra_flags & TEST_DELETE_FAILURE) == TEST_DELETE_FAILURE)
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
||||
}
|
||||
if ((item.extra_flags & TEST_NOT_EXISTS) == TEST_NOT_EXISTS)
|
||||
{
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
|
||||
}
|
||||
|
||||
@ -1126,12 +1122,12 @@ test_make_directory_with_parents (gconstpointer test_data)
|
||||
gboolean res;
|
||||
GError *error = NULL;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
child = g_file_get_child (root, "a");
|
||||
grandchild = g_file_get_child (child, "b");
|
||||
@ -1141,27 +1137,27 @@ test_make_directory_with_parents (gconstpointer test_data)
|
||||
* depth 1, 2, or 3
|
||||
*/
|
||||
res = g_file_make_directory_with_parents (child, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
res = g_file_query_exists (child, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
g_file_delete (child, NULL, NULL);
|
||||
|
||||
res = g_file_make_directory_with_parents (grandchild, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
res = g_file_query_exists (grandchild, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
g_file_delete (grandchild, NULL, NULL);
|
||||
g_file_delete (child, NULL, NULL);
|
||||
|
||||
res = g_file_make_directory_with_parents (greatgrandchild, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
res = g_file_query_exists (greatgrandchild, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
g_file_delete (greatgrandchild, NULL, NULL);
|
||||
g_file_delete (grandchild, NULL, NULL);
|
||||
@ -1181,22 +1177,22 @@ test_make_directory_with_parents (gconstpointer test_data)
|
||||
#endif
|
||||
|
||||
g_file_make_directory (child, NULL, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
res = g_file_set_attribute_uint32 (child,
|
||||
G_FILE_ATTRIBUTE_UNIX_MODE,
|
||||
S_IRUSR + S_IXUSR, /* -r-x------ */
|
||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||
NULL, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
res = g_file_make_directory_with_parents (grandchild, NULL, &error);
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED);
|
||||
g_clear_error (&error);
|
||||
|
||||
res = g_file_make_directory_with_parents (greatgrandchild, NULL, &error);
|
||||
g_assert_cmpint (res, ==, FALSE);
|
||||
g_assert_false (res);
|
||||
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED);
|
||||
g_clear_error (&error);
|
||||
|
||||
@ -1218,7 +1214,7 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
||||
GFile *descend;
|
||||
char *relative_path;
|
||||
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
|
||||
enumerator =
|
||||
g_file_enumerate_children (parent, "*",
|
||||
@ -1232,9 +1228,9 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
||||
while ((info) && (!error))
|
||||
{
|
||||
descend = g_file_enumerator_get_child (enumerator, info);
|
||||
g_assert (descend != NULL);
|
||||
g_assert_nonnull (descend);
|
||||
relative_path = g_file_get_relative_path (root, descend);
|
||||
g_assert (relative_path != NULL);
|
||||
g_assert_nonnull (relative_path);
|
||||
g_free (relative_path);
|
||||
|
||||
log (" deleting '%s'\n", g_file_info_get_display_name (info));
|
||||
@ -1244,7 +1240,7 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
||||
|
||||
error = NULL;
|
||||
res = g_file_delete (descend, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
|
||||
g_object_unref (descend);
|
||||
error = NULL;
|
||||
@ -1256,7 +1252,7 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
|
||||
|
||||
error = NULL;
|
||||
res = g_file_enumerator_close (enumerator, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
g_assert_true (res);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_object_unref (enumerator);
|
||||
@ -1267,12 +1263,12 @@ prep_clean_structure (gconstpointer test_data)
|
||||
{
|
||||
GFile *root;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
g_assert_nonnull (test_data);
|
||||
log ("\n Cleaning target testing structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
|
||||
root = g_file_new_for_commandline_arg ((char *) test_data);
|
||||
g_assert (root != NULL);
|
||||
g_assert_nonnull (root);
|
||||
|
||||
cleanup_dir_recurse (root, root);
|
||||
|
||||
|
@ -2543,7 +2543,7 @@ g_variant_new_parsed_va (const gchar *format,
|
||||
ast_free (ast);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
if (error != NULL)
|
||||
g_error ("g_variant_new_parsed: %s", error->message);
|
||||
|
||||
if (*stream.stream)
|
||||
|
@ -414,7 +414,7 @@ test_check_start_and_stop (gpointer user_data)
|
||||
}
|
||||
|
||||
run_next = FALSE;
|
||||
return TRUE;
|
||||
return continue_timeout;
|
||||
}
|
||||
|
||||
if (test_number == 3) {
|
||||
|
Loading…
Reference in New Issue
Block a user