mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Fix sparse warnings (#519489)
2008-03-06 Alexander Larsson <alexl@redhat.com> * gdesktopappinfo.c: * gfilemonitor.c: * gthemedicon.c: * gunionvolumemonitor.c: * gunixmounts.c: * tests/g-file.c: * tests/live-g-file.c: * xdgmime/xdgmimecache.c: Fix sparse warnings (#519489) svn path=/trunk/; revision=6632
This commit is contained in:
committed by
Alexander Larsson
parent
c2237ec397
commit
5241d96b21
@@ -436,7 +436,7 @@ static void
|
||||
roundtrip_parent_child (const gboolean use_uri, const gboolean under_root_descending,
|
||||
const char *path, const char *dir_holder)
|
||||
{
|
||||
GFile *files[6] = {0};
|
||||
GFile *files[6] = {NULL};
|
||||
int i;
|
||||
|
||||
if (use_uri)
|
||||
|
@@ -26,9 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define PATTERN_FILE_SIZE 0x10000
|
||||
|
||||
#define TEST_HANDLE_SPECIAL TRUE
|
||||
|
||||
enum StructureExtraFlags
|
||||
@@ -71,7 +69,7 @@ struct StructureItem
|
||||
#define TEST_TARGET_FILE "target-file"
|
||||
|
||||
|
||||
const struct StructureItem sample_struct[] = {
|
||||
static const struct StructureItem sample_struct[] = {
|
||||
/* filename link file_type create_flags mode | handle_special | extra_flags */
|
||||
{"dir1", NULL, G_FILE_TYPE_DIRECTORY, G_FILE_CREATE_NONE, 0, 0, TEST_DELETE_NORMAL | TEST_DELETE_NON_EMPTY | TEST_REPLACE | TEST_OPEN},
|
||||
{"dir1/subdir", NULL, G_FILE_TYPE_DIRECTORY, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_COPY_ERROR_RECURSE | TEST_APPEND},
|
||||
@@ -100,22 +98,13 @@ const struct StructureItem sample_struct[] = {
|
||||
{"lost_symlink", "nowhere", G_FILE_TYPE_SYMBOLIC_LINK, G_FILE_CREATE_NONE, 0, 0, TEST_COPY | TEST_DELETE_NORMAL | TEST_OPEN | TEST_INVALID_SYMLINK},
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static gboolean write_test;
|
||||
static gboolean verbose;
|
||||
static gboolean posix_compat;
|
||||
|
||||
#define log(msg...) if (verbose) g_print (msg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GFile *
|
||||
static GFile *
|
||||
create_empty_file (GFile * parent, const char *filename,
|
||||
GFileCreateFlags create_flags)
|
||||
{
|
||||
@@ -124,7 +113,6 @@ create_empty_file (GFile * parent, const char *filename,
|
||||
GError *error;
|
||||
GFileOutputStream *outs;
|
||||
|
||||
|
||||
child = g_file_get_child (parent, filename);
|
||||
g_assert (child != NULL);
|
||||
|
||||
@@ -138,7 +126,7 @@ create_empty_file (GFile * parent, const char *filename,
|
||||
return child;
|
||||
}
|
||||
|
||||
GFile *
|
||||
static GFile *
|
||||
create_empty_dir (GFile * parent, const char *filename)
|
||||
{
|
||||
GFile *child;
|
||||
@@ -154,7 +142,7 @@ create_empty_dir (GFile * parent, const char *filename)
|
||||
return child;
|
||||
}
|
||||
|
||||
GFile *
|
||||
static GFile *
|
||||
create_symlink (GFile * parent, const char *filename, const char *points_to)
|
||||
{
|
||||
GFile *child;
|
||||
@@ -182,7 +170,6 @@ test_create_structure (gconstpointer test_data)
|
||||
int i;
|
||||
struct StructureItem item;
|
||||
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
log ("\n Going to create testing structure in '%s'...\n",
|
||||
(char *) test_data);
|
||||
@@ -194,7 +181,6 @@ test_create_structure (gconstpointer test_data)
|
||||
res = g_file_make_directory (root, NULL, NULL);
|
||||
/* don't care about errors here */
|
||||
|
||||
|
||||
/* create any other items */
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
@@ -270,11 +256,7 @@ test_create_structure (gconstpointer test_data)
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GFile *
|
||||
static GFile *
|
||||
file_exists (GFile * parent, const char *filename, gboolean * result)
|
||||
{
|
||||
GFile *child;
|
||||
@@ -292,7 +274,7 @@ file_exists (GFile * parent, const char *filename, gboolean * result)
|
||||
return child;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
{
|
||||
GFileType ftype;
|
||||
@@ -381,7 +363,6 @@ test_attributes (struct StructureItem item, GFileInfo * info)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_initial_structure (gconstpointer test_data)
|
||||
{
|
||||
@@ -406,7 +387,6 @@ test_initial_structure (gconstpointer test_data)
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
|
||||
|
||||
/* test the structure */
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
@@ -433,7 +413,6 @@ test_initial_structure (gconstpointer test_data)
|
||||
g_object_unref (child);
|
||||
}
|
||||
|
||||
|
||||
/* read and test the pattern file */
|
||||
log (" Testing pattern file...\n");
|
||||
child = file_exists (root, "pattern_file", &res);
|
||||
@@ -484,12 +463,7 @@ test_initial_structure (gconstpointer test_data)
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
{
|
||||
gboolean res;
|
||||
@@ -501,7 +475,6 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
int i;
|
||||
gboolean found;
|
||||
|
||||
|
||||
g_assert (root != NULL);
|
||||
|
||||
error = NULL;
|
||||
@@ -547,7 +520,6 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
}
|
||||
g_assert (error == NULL);
|
||||
|
||||
|
||||
error = NULL;
|
||||
res = g_file_enumerator_close (enumerator, NULL, &error);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
@@ -656,12 +628,7 @@ test_enumerate (gconstpointer test_data)
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
enum StructureExtraFlags extra_flags)
|
||||
{
|
||||
@@ -695,7 +662,6 @@ do_copy_move (GFile * root, struct StructureItem item, const char *target_dir,
|
||||
log (" res = %d, error code %d = %s\n", res, error->code,
|
||||
error->message);
|
||||
|
||||
|
||||
/* copying file/directory to itself (".") */
|
||||
if (((item.extra_flags & TEST_NOT_EXISTS) != TEST_NOT_EXISTS) &&
|
||||
(extra_flags == TEST_ALREADY_EXISTS))
|
||||
@@ -758,7 +724,6 @@ test_copy_move (gconstpointer test_data)
|
||||
int i;
|
||||
struct StructureItem item;
|
||||
|
||||
|
||||
log ("\n");
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
@@ -814,10 +779,6 @@ test_copy_move (gconstpointer test_data)
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_create (gconstpointer test_data)
|
||||
{
|
||||
@@ -828,7 +789,6 @@ test_create (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
GFileOutputStream *os;
|
||||
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
log ("\n");
|
||||
|
||||
@@ -837,7 +797,6 @@ test_create (gconstpointer test_data)
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
item = sample_struct[i];
|
||||
@@ -866,7 +825,6 @@ test_create (gconstpointer test_data)
|
||||
if (error)
|
||||
log (" error code %d = %s\n", error->code, error->message);
|
||||
|
||||
|
||||
if (((item.extra_flags & TEST_NOT_EXISTS) == 0) &&
|
||||
((item.extra_flags & TEST_CREATE) == TEST_CREATE))
|
||||
{
|
||||
@@ -909,9 +867,6 @@ test_create (gconstpointer test_data)
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_open (gconstpointer test_data)
|
||||
{
|
||||
@@ -922,7 +877,6 @@ test_open (gconstpointer test_data)
|
||||
struct StructureItem item;
|
||||
GFileInputStream *input_stream;
|
||||
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
log ("\n");
|
||||
|
||||
@@ -931,7 +885,6 @@ test_open (gconstpointer test_data)
|
||||
res = g_file_query_exists (root, NULL);
|
||||
g_assert_cmpint (res, ==, TRUE);
|
||||
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (sample_struct); i++)
|
||||
{
|
||||
item = sample_struct[i];
|
||||
@@ -984,10 +937,6 @@ test_open (gconstpointer test_data)
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_delete (gconstpointer test_data)
|
||||
{
|
||||
@@ -998,7 +947,6 @@ test_delete (gconstpointer test_data)
|
||||
int i;
|
||||
struct StructureItem item;
|
||||
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
log ("\n");
|
||||
|
||||
@@ -1055,19 +1003,12 @@ test_delete (gconstpointer test_data)
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
|
||||
g_object_unref (child);
|
||||
}
|
||||
}
|
||||
g_object_unref (root);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -1115,8 +1056,6 @@ main (int argc, char *argv[])
|
||||
}
|
||||
target_path = strdup (argv[1]);
|
||||
|
||||
|
||||
|
||||
/* Write test - create new testing structure */
|
||||
if (write_test || create_struct)
|
||||
g_test_add_data_func ("/live-g-file/create_structure", target_path,
|
||||
|
Reference in New Issue
Block a user