mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Merge branch 'fix-warnings-glib' into 'master'
Fix warnings glib See merge request GNOME/glib!680
This commit is contained in:
commit
c8692fffe0
28
glib/ghash.c
28
glib/ghash.c
@ -246,7 +246,7 @@
|
||||
|
||||
struct _GHashTable
|
||||
{
|
||||
gint size;
|
||||
gsize size;
|
||||
gint mod;
|
||||
guint mask;
|
||||
gint nnodes;
|
||||
@ -279,9 +279,9 @@ typedef struct
|
||||
GHashTable *hash_table;
|
||||
gpointer dummy1;
|
||||
gpointer dummy2;
|
||||
int position;
|
||||
gint position;
|
||||
gboolean dummy3;
|
||||
int version;
|
||||
gint version;
|
||||
} RealIter;
|
||||
|
||||
G_STATIC_ASSERT (sizeof (GHashTableIter) == sizeof (RealIter));
|
||||
@ -798,7 +798,7 @@ static void
|
||||
g_hash_table_resize (GHashTable *hash_table)
|
||||
{
|
||||
guint32 *reallocated_buckets_bitmap;
|
||||
guint old_size;
|
||||
gsize old_size;
|
||||
gboolean is_a_set;
|
||||
|
||||
old_size = hash_table->size;
|
||||
@ -1105,14 +1105,14 @@ g_hash_table_iter_next (GHashTableIter *iter,
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
g_return_val_if_fail (ri->version == ri->hash_table->version, FALSE);
|
||||
#endif
|
||||
g_return_val_if_fail (ri->position < ri->hash_table->size, FALSE);
|
||||
g_return_val_if_fail (ri->position < (gssize) ri->hash_table->size, FALSE);
|
||||
|
||||
position = ri->position;
|
||||
|
||||
do
|
||||
{
|
||||
position++;
|
||||
if (position >= ri->hash_table->size)
|
||||
if (position >= (gssize) ri->hash_table->size)
|
||||
{
|
||||
ri->position = position;
|
||||
return FALSE;
|
||||
@ -1155,7 +1155,7 @@ iter_remove_or_steal (RealIter *ri, gboolean notify)
|
||||
g_return_if_fail (ri->version == ri->hash_table->version);
|
||||
#endif
|
||||
g_return_if_fail (ri->position >= 0);
|
||||
g_return_if_fail (ri->position < ri->hash_table->size);
|
||||
g_return_if_fail ((gsize) ri->position < ri->hash_table->size);
|
||||
|
||||
g_hash_table_remove_node (ri->hash_table, ri->position, notify);
|
||||
|
||||
@ -1339,7 +1339,7 @@ g_hash_table_iter_replace (GHashTableIter *iter,
|
||||
g_return_if_fail (ri->version == ri->hash_table->version);
|
||||
#endif
|
||||
g_return_if_fail (ri->position >= 0);
|
||||
g_return_if_fail (ri->position < ri->hash_table->size);
|
||||
g_return_if_fail ((gsize) ri->position < ri->hash_table->size);
|
||||
|
||||
node_hash = ri->hash_table->hashes[ri->position];
|
||||
|
||||
@ -1880,7 +1880,7 @@ g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
|
||||
gboolean notify)
|
||||
{
|
||||
guint deleted = 0;
|
||||
gint i;
|
||||
gsize i;
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
gint version = hash_table->version;
|
||||
#endif
|
||||
@ -1989,7 +1989,7 @@ g_hash_table_foreach (GHashTable *hash_table,
|
||||
GHFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
gint version;
|
||||
#endif
|
||||
@ -2047,7 +2047,7 @@ g_hash_table_find (GHashTable *hash_table,
|
||||
GHRFunc predicate,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
gint version;
|
||||
#endif
|
||||
@ -2119,7 +2119,7 @@ g_hash_table_size (GHashTable *hash_table)
|
||||
GList *
|
||||
g_hash_table_get_keys (GHashTable *hash_table)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
GList *retval;
|
||||
|
||||
g_return_val_if_fail (hash_table != NULL, NULL);
|
||||
@ -2167,7 +2167,7 @@ g_hash_table_get_keys_as_array (GHashTable *hash_table,
|
||||
guint *length)
|
||||
{
|
||||
gpointer *result;
|
||||
guint i, j = 0;
|
||||
gsize i, j = 0;
|
||||
|
||||
result = g_new (gpointer, hash_table->nnodes + 1);
|
||||
for (i = 0; i < hash_table->size; i++)
|
||||
@ -2205,7 +2205,7 @@ g_hash_table_get_keys_as_array (GHashTable *hash_table,
|
||||
GList *
|
||||
g_hash_table_get_values (GHashTable *hash_table)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
GList *retval;
|
||||
|
||||
g_return_val_if_fail (hash_table != NULL, NULL);
|
||||
|
@ -2180,6 +2180,7 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
gsize *bytes_written,
|
||||
GError **error)
|
||||
{
|
||||
gsize count_unsigned;
|
||||
GIOStatus status;
|
||||
gssize wrote_bytes = 0;
|
||||
|
||||
@ -2190,8 +2191,9 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
|
||||
if ((count < 0) && buf)
|
||||
count = strlen (buf);
|
||||
|
||||
if (count == 0)
|
||||
count_unsigned = count;
|
||||
|
||||
if (count_unsigned == 0)
|
||||
{
|
||||
if (bytes_written)
|
||||
*bytes_written = 0;
|
||||
@ -2199,7 +2201,7 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
}
|
||||
|
||||
g_return_val_if_fail (buf != NULL, G_IO_STATUS_ERROR);
|
||||
g_return_val_if_fail (count > 0, G_IO_STATUS_ERROR);
|
||||
g_return_val_if_fail (count_unsigned > 0, G_IO_STATUS_ERROR);
|
||||
|
||||
/* Raw write case */
|
||||
|
||||
@ -2210,7 +2212,8 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
g_assert (!channel->write_buf || channel->write_buf->len == 0);
|
||||
g_assert (channel->partial_write_buf[0] == '\0');
|
||||
|
||||
status = channel->funcs->io_write (channel, buf, count, &tmp_bytes, error);
|
||||
status = channel->funcs->io_write (channel, buf, count_unsigned,
|
||||
&tmp_bytes, error);
|
||||
|
||||
if (bytes_written)
|
||||
*bytes_written = tmp_bytes;
|
||||
@ -2286,7 +2289,7 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
|
||||
if (!channel->encoding)
|
||||
{
|
||||
gssize write_this = MIN (space_in_buf, count - wrote_bytes);
|
||||
gssize write_this = MIN (space_in_buf, count_unsigned - wrote_bytes);
|
||||
|
||||
g_string_append_len (channel->write_buf, buf, write_this);
|
||||
buf += write_this;
|
||||
@ -2306,7 +2309,7 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
from_buf = channel->partial_write_buf;
|
||||
from_buf_old_len = strlen (channel->partial_write_buf);
|
||||
g_assert (from_buf_old_len > 0);
|
||||
from_buf_len = MIN (6, from_buf_old_len + count);
|
||||
from_buf_len = MIN (6, from_buf_old_len + count_unsigned);
|
||||
|
||||
memcpy (channel->partial_write_buf + from_buf_old_len, buf,
|
||||
from_buf_len - from_buf_old_len);
|
||||
@ -2314,7 +2317,7 @@ g_io_channel_write_chars (GIOChannel *channel,
|
||||
else
|
||||
{
|
||||
from_buf = buf;
|
||||
from_buf_len = count - wrote_bytes;
|
||||
from_buf_len = count_unsigned - wrote_bytes;
|
||||
from_buf_old_len = 0;
|
||||
}
|
||||
|
||||
@ -2404,7 +2407,7 @@ reconvert:
|
||||
memcpy (channel->partial_write_buf, from_buf, left_len);
|
||||
channel->partial_write_buf[left_len] = '\0';
|
||||
if (bytes_written)
|
||||
*bytes_written = count;
|
||||
*bytes_written = count_unsigned;
|
||||
return G_IO_STATUS_NORMAL;
|
||||
}
|
||||
|
||||
@ -2416,12 +2419,12 @@ reconvert:
|
||||
* less than a full character
|
||||
*/
|
||||
|
||||
g_assert (count == from_buf_len - from_buf_old_len);
|
||||
g_assert (count_unsigned == from_buf_len - from_buf_old_len);
|
||||
|
||||
channel->partial_write_buf[from_buf_len] = '\0';
|
||||
|
||||
if (bytes_written)
|
||||
*bytes_written = count;
|
||||
*bytes_written = count_unsigned;
|
||||
|
||||
return G_IO_STATUS_NORMAL;
|
||||
}
|
||||
@ -2483,7 +2486,7 @@ reconvert:
|
||||
}
|
||||
|
||||
if (bytes_written)
|
||||
*bytes_written = count;
|
||||
*bytes_written = count_unsigned;
|
||||
|
||||
return G_IO_STATUS_NORMAL;
|
||||
}
|
||||
|
@ -107,7 +107,8 @@ GSourceFuncs g_io_watch_funcs = {
|
||||
g_io_unix_prepare,
|
||||
g_io_unix_check,
|
||||
g_io_unix_dispatch,
|
||||
g_io_unix_finalize
|
||||
g_io_unix_finalize,
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
static GIOFuncs unix_channel_funcs = {
|
||||
|
@ -310,7 +310,7 @@ g_unix_fd_source_dispatch (GSource *source,
|
||||
}
|
||||
|
||||
GSourceFuncs g_unix_fd_source_funcs = {
|
||||
NULL, NULL, g_unix_fd_source_dispatch, NULL
|
||||
NULL, NULL, g_unix_fd_source_dispatch, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
/**
|
||||
|
20
glib/gmain.c
20
glib/gmain.c
@ -476,7 +476,8 @@ GSourceFuncs g_unix_signal_funcs =
|
||||
g_unix_signal_watch_prepare,
|
||||
g_unix_signal_watch_check,
|
||||
g_unix_signal_watch_dispatch,
|
||||
g_unix_signal_watch_finalize
|
||||
g_unix_signal_watch_finalize,
|
||||
NULL, NULL
|
||||
};
|
||||
#endif /* !G_OS_WIN32 */
|
||||
G_LOCK_DEFINE_STATIC (main_context_list);
|
||||
@ -487,7 +488,7 @@ GSourceFuncs g_timeout_funcs =
|
||||
NULL, /* prepare */
|
||||
NULL, /* check */
|
||||
g_timeout_dispatch,
|
||||
NULL
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
|
||||
GSourceFuncs g_child_watch_funcs =
|
||||
@ -495,7 +496,8 @@ GSourceFuncs g_child_watch_funcs =
|
||||
g_child_watch_prepare,
|
||||
g_child_watch_check,
|
||||
g_child_watch_dispatch,
|
||||
g_child_watch_finalize
|
||||
g_child_watch_finalize,
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
GSourceFuncs g_idle_funcs =
|
||||
@ -503,7 +505,7 @@ GSourceFuncs g_idle_funcs =
|
||||
g_idle_prepare,
|
||||
g_idle_check,
|
||||
g_idle_dispatch,
|
||||
NULL
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1609,10 +1611,12 @@ g_source_set_callback_indirect (GSource *source,
|
||||
LOCK_CONTEXT (context);
|
||||
|
||||
if (callback_funcs != &g_source_callback_funcs)
|
||||
TRACE (GLIB_SOURCE_SET_CALLBACK_INDIRECT (source, callback_data,
|
||||
callback_funcs->ref,
|
||||
callback_funcs->unref,
|
||||
callback_funcs->get));
|
||||
{
|
||||
TRACE (GLIB_SOURCE_SET_CALLBACK_INDIRECT (source, callback_data,
|
||||
callback_funcs->ref,
|
||||
callback_funcs->unref,
|
||||
callback_funcs->get));
|
||||
}
|
||||
|
||||
old_cb_data = source->callback_data;
|
||||
old_cb_funcs = source->callback_funcs;
|
||||
|
@ -150,7 +150,7 @@ mapped_file_new_from_fd (int fd,
|
||||
file->contents = MAP_FAILED;
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
if (st.st_size > G_MAXSIZE)
|
||||
if (sizeof (st.st_size) > sizeof (gsize) && st.st_size > (off_t) G_MAXSIZE)
|
||||
{
|
||||
errno = EINVAL;
|
||||
}
|
||||
|
@ -786,8 +786,8 @@ unescape_gstring_inplace (GMarkupParseContext *context,
|
||||
}
|
||||
}
|
||||
|
||||
g_assert (to - string->str <= string->len);
|
||||
if (to - string->str != string->len)
|
||||
g_assert (to - string->str <= (gssize) string->len);
|
||||
if (to - string->str != (gssize) string->len)
|
||||
g_string_truncate (string, to - string->str);
|
||||
|
||||
*is_ascii = !(mask & 0x80);
|
||||
@ -2629,7 +2629,7 @@ g_markup_parse_boolean (const char *string,
|
||||
{
|
||||
char const * const falses[] = { "false", "f", "no", "n", "0" };
|
||||
char const * const trues[] = { "true", "t", "yes", "y", "1" };
|
||||
int i;
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (falses); i++)
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ struct _GOptionGroup
|
||||
gpointer translate_data;
|
||||
|
||||
GOptionEntry *entries;
|
||||
gint n_entries;
|
||||
gsize n_entries;
|
||||
|
||||
GOptionParseFunc pre_parse_func;
|
||||
GOptionParseFunc post_parse_func;
|
||||
@ -665,7 +665,7 @@ calculate_max_length (GOptionGroup *group,
|
||||
GHashTable *aliases)
|
||||
{
|
||||
GOptionEntry *entry;
|
||||
gint i, len, max_length;
|
||||
gsize i, len, max_length;
|
||||
const gchar *long_name;
|
||||
|
||||
max_length = 0;
|
||||
@ -828,7 +828,7 @@ g_option_context_get_help (GOptionContext *context,
|
||||
{
|
||||
GList *list;
|
||||
gint max_length = 0, len;
|
||||
gint i;
|
||||
gsize i;
|
||||
GOptionEntry *entry;
|
||||
GHashTable *shadow_map;
|
||||
GHashTable *aliases;
|
||||
@ -1505,7 +1505,7 @@ parse_short_option (GOptionContext *context,
|
||||
GError **error,
|
||||
gboolean *parsed)
|
||||
{
|
||||
gint j;
|
||||
gsize j;
|
||||
|
||||
for (j = 0; j < group->n_entries; j++)
|
||||
{
|
||||
@ -1587,7 +1587,7 @@ parse_long_option (GOptionContext *context,
|
||||
GError **error,
|
||||
gboolean *parsed)
|
||||
{
|
||||
gint j;
|
||||
gsize j;
|
||||
|
||||
for (j = 0; j < group->n_entries; j++)
|
||||
{
|
||||
@ -1698,7 +1698,7 @@ parse_remaining_arg (GOptionContext *context,
|
||||
GError **error,
|
||||
gboolean *parsed)
|
||||
{
|
||||
gint j;
|
||||
gsize j;
|
||||
|
||||
for (j = 0; j < group->n_entries; j++)
|
||||
{
|
||||
@ -2353,7 +2353,7 @@ void
|
||||
g_option_group_add_entries (GOptionGroup *group,
|
||||
const GOptionEntry *entries)
|
||||
{
|
||||
gint i, n_entries;
|
||||
gsize i, n_entries;
|
||||
|
||||
g_return_if_fail (entries != NULL);
|
||||
|
||||
|
@ -86,7 +86,7 @@ static const guint g_primes[] =
|
||||
guint
|
||||
g_spaced_primes_closest (guint num)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (g_primes); i++)
|
||||
if (g_primes[i] > num)
|
||||
|
@ -271,7 +271,7 @@ g_quark_to_string (GQuark quark)
|
||||
{
|
||||
gchar* result = NULL;
|
||||
gchar **strings;
|
||||
gint seq_id;
|
||||
guint seq_id;
|
||||
|
||||
seq_id = g_atomic_int_get (&quark_seq_id);
|
||||
strings = g_atomic_pointer_get (&quarks);
|
||||
|
@ -341,6 +341,7 @@ static const GScannerConfig g_scanner_config_template =
|
||||
FALSE /* symbol_2_token */,
|
||||
FALSE /* scope_0_fallback */,
|
||||
FALSE /* store_int64 */,
|
||||
0 /* padding_dummy */
|
||||
};
|
||||
|
||||
|
||||
|
@ -640,7 +640,10 @@ magazine_cache_trim (Allocator *allocator,
|
||||
/* trim magazine cache from tail */
|
||||
ChunkLink *current = magazine_chain_prev (allocator->magazines[ix]);
|
||||
ChunkLink *trash = NULL;
|
||||
while (ABS (stamp - magazine_chain_uint_stamp (current)) >= allocator->config.working_set_msecs)
|
||||
while ((stamp >= magazine_chain_uint_stamp (current) &&
|
||||
stamp - magazine_chain_uint_stamp (current) >= allocator->config.working_set_msecs) ||
|
||||
(stamp <= magazine_chain_uint_stamp (current) &&
|
||||
magazine_chain_uint_stamp (current) - stamp >= allocator->config.working_set_msecs))
|
||||
{
|
||||
/* unlink */
|
||||
ChunkLink *prev = magazine_chain_prev (current);
|
||||
|
@ -2700,13 +2700,14 @@ g_strstr_len (const gchar *haystack,
|
||||
{
|
||||
const gchar *p = haystack;
|
||||
gsize needle_len = strlen (needle);
|
||||
gsize haystack_len_unsigned = haystack_len;
|
||||
const gchar *end;
|
||||
gsize i;
|
||||
|
||||
if (needle_len == 0)
|
||||
return (gchar *)haystack;
|
||||
|
||||
if (haystack_len < needle_len)
|
||||
if (haystack_len_unsigned < needle_len)
|
||||
return NULL;
|
||||
|
||||
end = haystack + haystack_len - needle_len;
|
||||
|
@ -428,6 +428,8 @@ g_string_insert_len (GString *string,
|
||||
const gchar *val,
|
||||
gssize len)
|
||||
{
|
||||
gsize len_unsigned, pos_unsigned;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (len == 0 || val != NULL, string);
|
||||
|
||||
@ -436,11 +438,15 @@ g_string_insert_len (GString *string,
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (val);
|
||||
len_unsigned = len;
|
||||
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
pos_unsigned = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, string);
|
||||
{
|
||||
pos_unsigned = pos;
|
||||
g_return_val_if_fail (pos_unsigned <= string->len, string);
|
||||
}
|
||||
|
||||
/* Check whether val represents a substring of string.
|
||||
* This test probably violates chapter and verse of the C standards,
|
||||
@ -452,45 +458,48 @@ g_string_insert_len (GString *string,
|
||||
gsize offset = val - string->str;
|
||||
gsize precount = 0;
|
||||
|
||||
g_string_maybe_expand (string, len);
|
||||
g_string_maybe_expand (string, len_unsigned);
|
||||
val = string->str + offset;
|
||||
/* At this point, val is valid again. */
|
||||
|
||||
/* Open up space where we are going to insert. */
|
||||
if (pos < string->len)
|
||||
memmove (string->str + pos + len, string->str + pos, string->len - pos);
|
||||
if (pos_unsigned < string->len)
|
||||
memmove (string->str + pos_unsigned + len_unsigned,
|
||||
string->str + pos_unsigned, string->len - pos_unsigned);
|
||||
|
||||
/* Move the source part before the gap, if any. */
|
||||
if (offset < pos)
|
||||
if (offset < pos_unsigned)
|
||||
{
|
||||
precount = MIN (len, pos - offset);
|
||||
memcpy (string->str + pos, val, precount);
|
||||
precount = MIN (len_unsigned, pos_unsigned - offset);
|
||||
memcpy (string->str + pos_unsigned, val, precount);
|
||||
}
|
||||
|
||||
/* Move the source part after the gap, if any. */
|
||||
if (len > precount)
|
||||
memcpy (string->str + pos + precount,
|
||||
val + /* Already moved: */ precount + /* Space opened up: */ len,
|
||||
len - precount);
|
||||
if (len_unsigned > precount)
|
||||
memcpy (string->str + pos_unsigned + precount,
|
||||
val + /* Already moved: */ precount +
|
||||
/* Space opened up: */ len_unsigned,
|
||||
len_unsigned - precount);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_string_maybe_expand (string, len);
|
||||
g_string_maybe_expand (string, len_unsigned);
|
||||
|
||||
/* If we aren't appending at the end, move a hunk
|
||||
* of the old string to the end, opening up space
|
||||
*/
|
||||
if (pos < string->len)
|
||||
memmove (string->str + pos + len, string->str + pos, string->len - pos);
|
||||
if (pos_unsigned < string->len)
|
||||
memmove (string->str + pos_unsigned + len_unsigned,
|
||||
string->str + pos_unsigned, string->len - pos_unsigned);
|
||||
|
||||
/* insert the new string */
|
||||
if (len == 1)
|
||||
string->str[pos] = *val;
|
||||
if (len_unsigned == 1)
|
||||
string->str[pos_unsigned] = *val;
|
||||
else
|
||||
memcpy (string->str + pos, val, len);
|
||||
memcpy (string->str + pos_unsigned, val, len_unsigned);
|
||||
}
|
||||
|
||||
string->len += len;
|
||||
string->len += len_unsigned;
|
||||
|
||||
string->str[string->len] = 0;
|
||||
|
||||
@ -778,6 +787,8 @@ g_string_insert_c (GString *string,
|
||||
gssize pos,
|
||||
gchar c)
|
||||
{
|
||||
gsize pos_unsigned;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
|
||||
g_string_maybe_expand (string, 1);
|
||||
@ -785,13 +796,15 @@ g_string_insert_c (GString *string,
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, string);
|
||||
g_return_val_if_fail ((gsize) pos <= string->len, string);
|
||||
pos_unsigned = pos;
|
||||
|
||||
/* If not just an append, move the old stuff */
|
||||
if (pos < string->len)
|
||||
memmove (string->str + pos + 1, string->str + pos, string->len - pos);
|
||||
if (pos_unsigned < string->len)
|
||||
memmove (string->str + pos_unsigned + 1,
|
||||
string->str + pos_unsigned, string->len - pos_unsigned);
|
||||
|
||||
string->str[pos] = c;
|
||||
string->str[pos_unsigned] = c;
|
||||
|
||||
string->len += 1;
|
||||
|
||||
@ -860,10 +873,10 @@ g_string_insert_unichar (GString *string,
|
||||
if (pos < 0)
|
||||
pos = string->len;
|
||||
else
|
||||
g_return_val_if_fail (pos <= string->len, string);
|
||||
g_return_val_if_fail ((gsize) pos <= string->len, string);
|
||||
|
||||
/* If not just an append, move the old stuff */
|
||||
if (pos < string->len)
|
||||
if ((gsize) pos < string->len)
|
||||
memmove (string->str + pos + charlen, string->str + pos, string->len - pos);
|
||||
|
||||
dest = string->str + pos;
|
||||
@ -970,21 +983,28 @@ g_string_erase (GString *string,
|
||||
gssize pos,
|
||||
gssize len)
|
||||
{
|
||||
gsize len_unsigned, pos_unsigned;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (pos >= 0, string);
|
||||
g_return_val_if_fail (pos <= string->len, string);
|
||||
pos_unsigned = pos;
|
||||
|
||||
g_return_val_if_fail (pos_unsigned <= string->len, string);
|
||||
|
||||
if (len < 0)
|
||||
len = string->len - pos;
|
||||
len_unsigned = string->len - pos_unsigned;
|
||||
else
|
||||
{
|
||||
g_return_val_if_fail (pos + len <= string->len, string);
|
||||
len_unsigned = len;
|
||||
g_return_val_if_fail (pos_unsigned + len_unsigned <= string->len, string);
|
||||
|
||||
if (pos + len < string->len)
|
||||
memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
|
||||
if (pos_unsigned + len_unsigned < string->len)
|
||||
memmove (string->str + pos_unsigned,
|
||||
string->str + pos_unsigned + len_unsigned,
|
||||
string->len - (pos_unsigned + len_unsigned));
|
||||
}
|
||||
|
||||
string->len -= len;
|
||||
string->len -= len_unsigned;
|
||||
|
||||
string->str[string->len] = 0;
|
||||
|
||||
|
@ -677,7 +677,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
guint ui;
|
||||
gint ui;
|
||||
|
||||
g_set_prgname (argv[0]);
|
||||
parse_args (&argc, &argv);
|
||||
|
@ -3829,7 +3829,7 @@ g_test_build_filename_va (GTestFileType file_type,
|
||||
va_list ap)
|
||||
{
|
||||
const gchar *pathv[16];
|
||||
gint num_path_segments;
|
||||
gsize num_path_segments;
|
||||
|
||||
if (file_type == G_TEST_DIST)
|
||||
pathv[0] = test_disted_files_dir;
|
||||
|
@ -1177,7 +1177,7 @@ g_system_thread_new (GThreadFunc proxy,
|
||||
#ifdef _SC_THREAD_STACK_MIN
|
||||
long min_stack_size = sysconf (_SC_THREAD_STACK_MIN);
|
||||
if (min_stack_size >= 0)
|
||||
stack_size = MAX (min_stack_size, stack_size);
|
||||
stack_size = MAX ((gulong) min_stack_size, stack_size);
|
||||
#endif /* _SC_THREAD_STACK_MIN */
|
||||
/* No error check here, because some systems can't do it and
|
||||
* we simply don't want threads to fail because of that. */
|
||||
|
@ -91,7 +91,7 @@ struct _GRealThreadPool
|
||||
GAsyncQueue *queue;
|
||||
GCond cond;
|
||||
gint max_threads;
|
||||
gint num_threads;
|
||||
guint num_threads;
|
||||
gboolean running;
|
||||
gboolean immediate;
|
||||
gboolean waiting;
|
||||
@ -154,7 +154,7 @@ g_thread_pool_wait_for_new_pool (void)
|
||||
|
||||
do
|
||||
{
|
||||
if (g_atomic_int_get (&unused_threads) >= local_max_unused_threads)
|
||||
if ((guint) g_atomic_int_get (&unused_threads) >= local_max_unused_threads)
|
||||
{
|
||||
/* If this is a superfluous thread, stop it. */
|
||||
pool = NULL;
|
||||
@ -234,7 +234,7 @@ g_thread_pool_wait_for_new_task (GRealThreadPool *pool)
|
||||
g_async_queue_length_unlocked (pool->queue) > 0))
|
||||
{
|
||||
/* This thread pool is still active. */
|
||||
if (pool->num_threads > pool->max_threads && pool->max_threads != -1)
|
||||
if (pool->max_threads != -1 && pool->num_threads > (guint) pool->max_threads)
|
||||
{
|
||||
/* This is a superfluous thread, so it goes to the global pool. */
|
||||
DEBUG_MSG (("superfluous thread %p in pool %p.",
|
||||
@ -340,7 +340,7 @@ g_thread_pool_thread_proxy (gpointer data)
|
||||
* queue, wakeup the remaining threads.
|
||||
*/
|
||||
if (g_async_queue_length_unlocked (pool->queue) ==
|
||||
- pool->num_threads)
|
||||
(gint) -pool->num_threads)
|
||||
g_thread_pool_wakeup_and_stop_all (pool);
|
||||
}
|
||||
}
|
||||
@ -386,7 +386,7 @@ g_thread_pool_start_thread (GRealThreadPool *pool,
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (pool->num_threads >= pool->max_threads && pool->max_threads != -1)
|
||||
if (pool->max_threads != -1 && pool->num_threads >= (guint) pool->max_threads)
|
||||
/* Enough threads are already running */
|
||||
return TRUE;
|
||||
|
||||
@ -504,7 +504,7 @@ g_thread_pool_new (GFunc func,
|
||||
{
|
||||
g_async_queue_lock (retval->queue);
|
||||
|
||||
while (retval->num_threads < retval->max_threads)
|
||||
while (retval->num_threads < (guint) retval->max_threads)
|
||||
{
|
||||
GError *local_error = NULL;
|
||||
|
||||
@ -777,12 +777,12 @@ g_thread_pool_free (GThreadPool *pool,
|
||||
|
||||
if (wait_)
|
||||
{
|
||||
while (g_async_queue_length_unlocked (real->queue) != -real->num_threads &&
|
||||
while (g_async_queue_length_unlocked (real->queue) != (gint) -real->num_threads &&
|
||||
!(immediate && real->num_threads == 0))
|
||||
g_cond_wait (&real->cond, _g_async_queue_get_mutex (real->queue));
|
||||
}
|
||||
|
||||
if (immediate || g_async_queue_length_unlocked (real->queue) == -real->num_threads)
|
||||
if (immediate || g_async_queue_length_unlocked (real->queue) == (gint) -real->num_threads)
|
||||
{
|
||||
/* No thread is currently doing something (and nothing is left
|
||||
* to process in the queue)
|
||||
|
@ -237,7 +237,7 @@ again:
|
||||
|
||||
if (tz->t_info != NULL)
|
||||
{
|
||||
gint idx;
|
||||
guint idx;
|
||||
for (idx = 0; idx < tz->t_info->len; idx++)
|
||||
{
|
||||
TransitionInfo *info = &g_array_index (tz->t_info, TransitionInfo, idx);
|
||||
@ -575,7 +575,7 @@ init_zone_from_iana_info (GTimeZone *gtz,
|
||||
trans.time = gint32_from_be (((gint32_be*)tz_transitions)[index]);
|
||||
trans.info_index = tz_type_index[index];
|
||||
g_assert (trans.info_index >= 0);
|
||||
g_assert (trans.info_index < gtz->t_info->len);
|
||||
g_assert ((guint) trans.info_index < gtz->t_info->len);
|
||||
g_array_append_val (gtz->transitions, trans);
|
||||
}
|
||||
}
|
||||
@ -690,7 +690,7 @@ register_tzi_to_tzi (RegTZI *reg, TIME_ZONE_INFORMATION *tzi)
|
||||
tzi->DaylightBias = reg->DaylightBias;
|
||||
}
|
||||
|
||||
static gint
|
||||
static guint
|
||||
rules_from_windows_time_zone (const gchar *identifier,
|
||||
gchar **out_identifier,
|
||||
TimeZoneRule **rules)
|
||||
@ -702,7 +702,7 @@ rules_from_windows_time_zone (const gchar *identifier,
|
||||
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\";
|
||||
TIME_ZONE_INFORMATION tzi;
|
||||
DWORD size;
|
||||
gint rules_num = 0;
|
||||
guint rules_num = 0;
|
||||
RegTZI regtzi, regtzi_prev;
|
||||
|
||||
g_assert (out_identifier != NULL);
|
||||
@ -830,7 +830,7 @@ failed:
|
||||
static void
|
||||
find_relative_date (TimeZoneDate *buffer)
|
||||
{
|
||||
gint wday;
|
||||
guint wday;
|
||||
GDate date;
|
||||
g_date_clear (&date, 1);
|
||||
wday = buffer->wday;
|
||||
@ -923,7 +923,7 @@ fill_transition_info_from_rule (TransitionInfo *info,
|
||||
static void
|
||||
init_zone_from_rules (GTimeZone *gtz,
|
||||
TimeZoneRule *rules,
|
||||
gint rules_num,
|
||||
guint rules_num,
|
||||
gchar *identifier /* (transfer full) */)
|
||||
{
|
||||
guint type_count = 0, trans_count = 0, info_index = 0;
|
||||
@ -1214,7 +1214,7 @@ parse_tz_boundary (const gchar *identifier,
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static guint
|
||||
create_ruleset_from_rule (TimeZoneRule **rules, TimeZoneRule *rule)
|
||||
{
|
||||
*rules = g_new0 (TimeZoneRule, 2);
|
||||
@ -1306,7 +1306,7 @@ parse_identifier_boundaries (gchar **pos, TimeZoneRule *tzr)
|
||||
* Creates an array of TimeZoneRule from a TZ environment variable
|
||||
* type of identifier. Should free rules afterwards
|
||||
*/
|
||||
static gint
|
||||
static guint
|
||||
rules_from_identifier (const gchar *identifier,
|
||||
gchar **out_identifier,
|
||||
TimeZoneRule **rules)
|
||||
@ -1779,8 +1779,8 @@ g_time_zone_adjust_time (GTimeZone *tz,
|
||||
GTimeType type,
|
||||
gint64 *time_)
|
||||
{
|
||||
gint i;
|
||||
guint intervals;
|
||||
guint i, intervals;
|
||||
gboolean interval_is_dst;
|
||||
|
||||
if (tz->transitions == NULL)
|
||||
return 0;
|
||||
@ -1822,16 +1822,21 @@ g_time_zone_adjust_time (GTimeZone *tz,
|
||||
*time_ = interval_local_start (tz, i);
|
||||
}
|
||||
|
||||
else if (interval_isdst (tz, i) != type)
|
||||
/* it's in this interval, but dst flag doesn't match.
|
||||
* check neighbours for a better fit. */
|
||||
else
|
||||
{
|
||||
if (i && *time_ <= interval_local_end (tz, i - 1))
|
||||
i--;
|
||||
interval_is_dst = interval_isdst (tz, i);
|
||||
if ((interval_is_dst && type != G_TIME_TYPE_DAYLIGHT) ||
|
||||
(!interval_is_dst && type == G_TIME_TYPE_DAYLIGHT))
|
||||
{
|
||||
/* it's in this interval, but dst flag doesn't match.
|
||||
* check neighbours for a better fit. */
|
||||
if (i && *time_ <= interval_local_end (tz, i - 1))
|
||||
i--;
|
||||
|
||||
else if (i < intervals &&
|
||||
*time_ >= interval_local_start (tz, i + 1))
|
||||
i++;
|
||||
else if (i < intervals &&
|
||||
*time_ >= interval_local_start (tz, i + 1))
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1872,8 +1877,8 @@ g_time_zone_find_interval (GTimeZone *tz,
|
||||
GTimeType type,
|
||||
gint64 time_)
|
||||
{
|
||||
gint i;
|
||||
guint intervals;
|
||||
guint i, intervals;
|
||||
gboolean interval_is_dst;
|
||||
|
||||
if (tz->transitions == NULL)
|
||||
return 0;
|
||||
@ -1897,13 +1902,18 @@ g_time_zone_find_interval (GTimeZone *tz,
|
||||
return -1;
|
||||
}
|
||||
|
||||
else if (interval_isdst (tz, i) != type)
|
||||
else
|
||||
{
|
||||
if (i && time_ <= interval_local_end (tz, i - 1))
|
||||
i--;
|
||||
interval_is_dst = interval_isdst (tz, i);
|
||||
if ((interval_is_dst && type != G_TIME_TYPE_DAYLIGHT) ||
|
||||
(!interval_is_dst && type == G_TIME_TYPE_DAYLIGHT))
|
||||
{
|
||||
if (i && time_ <= interval_local_end (tz, i - 1))
|
||||
i--;
|
||||
|
||||
else if (i < intervals && time_ >= interval_local_start (tz, i + 1))
|
||||
i++;
|
||||
else if (i < intervals && time_ >= interval_local_start (tz, i + 1))
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
|
@ -336,7 +336,7 @@ g_variant_ensure_size (GVariant *value)
|
||||
{
|
||||
g_assert (value->state & STATE_LOCKED);
|
||||
|
||||
if (value->size == (gssize) -1)
|
||||
if (value->size == (gsize) -1)
|
||||
{
|
||||
gpointer *children;
|
||||
gsize n_children;
|
||||
|
@ -1938,7 +1938,8 @@ number_get_value (AST *ast,
|
||||
return number_overflow (ast, type, error);
|
||||
if (negative && abs_val > G_MAXINT16)
|
||||
return g_variant_new_int16 (G_MININT16);
|
||||
return g_variant_new_int16 (negative ? -((gint16) abs_val) : abs_val);
|
||||
return g_variant_new_int16 (negative ?
|
||||
-((gint16) abs_val) : ((gint16) abs_val));
|
||||
|
||||
case 'q':
|
||||
if (negative || abs_val > G_MAXUINT16)
|
||||
@ -1950,7 +1951,8 @@ number_get_value (AST *ast,
|
||||
return number_overflow (ast, type, error);
|
||||
if (negative && abs_val > G_MAXINT32)
|
||||
return g_variant_new_int32 (G_MININT32);
|
||||
return g_variant_new_int32 (negative ? -((gint32) abs_val) : abs_val);
|
||||
return g_variant_new_int32 (negative ?
|
||||
-((gint32) abs_val) : ((gint32) abs_val));
|
||||
|
||||
case 'u':
|
||||
if (negative || abs_val > G_MAXUINT32)
|
||||
@ -1962,7 +1964,8 @@ number_get_value (AST *ast,
|
||||
return number_overflow (ast, type, error);
|
||||
if (negative && abs_val > G_MAXINT64)
|
||||
return g_variant_new_int64 (G_MININT64);
|
||||
return g_variant_new_int64 (negative ? -((gint64) abs_val) : abs_val);
|
||||
return g_variant_new_int64 (negative ?
|
||||
-((gint64) abs_val) : ((gint64) abs_val));
|
||||
|
||||
case 't':
|
||||
if (negative)
|
||||
@ -1974,7 +1977,8 @@ number_get_value (AST *ast,
|
||||
return number_overflow (ast, type, error);
|
||||
if (negative && abs_val > G_MAXINT32)
|
||||
return g_variant_new_handle (G_MININT32);
|
||||
return g_variant_new_handle (negative ? -((gint32) abs_val) : abs_val);
|
||||
return g_variant_new_handle (negative ?
|
||||
-((gint32) abs_val) : ((gint32) abs_val));
|
||||
|
||||
default:
|
||||
return ast_type_error (ast, type, error);
|
||||
@ -2630,7 +2634,7 @@ g_variant_builder_add_parsed (GVariantBuilder *builder,
|
||||
static gboolean
|
||||
parse_num (const gchar *num,
|
||||
const gchar *limit,
|
||||
gint *result)
|
||||
guint *result)
|
||||
{
|
||||
gchar *endptr;
|
||||
gint64 bignum;
|
||||
@ -2643,7 +2647,7 @@ parse_num (const gchar *num,
|
||||
if (bignum < 0 || bignum > G_MAXINT)
|
||||
return FALSE;
|
||||
|
||||
*result = bignum;
|
||||
*result = (guint) bignum;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -2799,7 +2803,7 @@ g_variant_parse_error_print_context (GError *error,
|
||||
|
||||
if (dash == NULL || colon < dash)
|
||||
{
|
||||
gint point;
|
||||
guint point;
|
||||
|
||||
/* we have a single point */
|
||||
if (!parse_num (error->message, colon, &point))
|
||||
@ -2817,7 +2821,7 @@ g_variant_parse_error_print_context (GError *error,
|
||||
/* We have one or two ranges... */
|
||||
if (comma && comma < colon)
|
||||
{
|
||||
gint start1, end1, start2, end2;
|
||||
guint start1, end1, start2, end2;
|
||||
const gchar *dash2;
|
||||
|
||||
/* Two ranges */
|
||||
@ -2833,7 +2837,7 @@ g_variant_parse_error_print_context (GError *error,
|
||||
}
|
||||
else
|
||||
{
|
||||
gint start, end;
|
||||
guint start, end;
|
||||
|
||||
/* One range */
|
||||
if (!parse_num (error->message, dash, &start) || !parse_num (dash + 1, colon, &end))
|
||||
|
@ -1552,19 +1552,20 @@ g_variant_new_strv (const gchar * const *strv,
|
||||
gssize length)
|
||||
{
|
||||
GVariant **strings;
|
||||
gsize i;
|
||||
gsize i, length_unsigned;
|
||||
|
||||
g_return_val_if_fail (length == 0 || strv != NULL, NULL);
|
||||
|
||||
if (length < 0)
|
||||
length = g_strv_length ((gchar **) strv);
|
||||
length_unsigned = length;
|
||||
|
||||
strings = g_new (GVariant *, length);
|
||||
for (i = 0; i < length; i++)
|
||||
strings = g_new (GVariant *, length_unsigned);
|
||||
for (i = 0; i < length_unsigned; i++)
|
||||
strings[i] = g_variant_ref_sink (g_variant_new_string (strv[i]));
|
||||
|
||||
return g_variant_new_from_children (G_VARIANT_TYPE_STRING_ARRAY,
|
||||
strings, length, TRUE);
|
||||
strings, length_unsigned, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1688,19 +1689,20 @@ g_variant_new_objv (const gchar * const *strv,
|
||||
gssize length)
|
||||
{
|
||||
GVariant **strings;
|
||||
gsize i;
|
||||
gsize i, length_unsigned;
|
||||
|
||||
g_return_val_if_fail (length == 0 || strv != NULL, NULL);
|
||||
|
||||
if (length < 0)
|
||||
length = g_strv_length ((gchar **) strv);
|
||||
length_unsigned = length;
|
||||
|
||||
strings = g_new (GVariant *, length);
|
||||
for (i = 0; i < length; i++)
|
||||
strings = g_new (GVariant *, length_unsigned);
|
||||
for (i = 0; i < length_unsigned; i++)
|
||||
strings[i] = g_variant_ref_sink (g_variant_new_object_path (strv[i]));
|
||||
|
||||
return g_variant_new_from_children (G_VARIANT_TYPE_OBJECT_PATH_ARRAY,
|
||||
strings, length, TRUE);
|
||||
strings, length_unsigned, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1928,19 +1930,20 @@ g_variant_new_bytestring_array (const gchar * const *strv,
|
||||
gssize length)
|
||||
{
|
||||
GVariant **strings;
|
||||
gsize i;
|
||||
gsize i, length_unsigned;
|
||||
|
||||
g_return_val_if_fail (length == 0 || strv != NULL, NULL);
|
||||
|
||||
if (length < 0)
|
||||
length = g_strv_length ((gchar **) strv);
|
||||
length_unsigned = length;
|
||||
|
||||
strings = g_new (GVariant *, length);
|
||||
for (i = 0; i < length; i++)
|
||||
strings = g_new (GVariant *, length_unsigned);
|
||||
for (i = 0; i < length_unsigned; i++)
|
||||
strings[i] = g_variant_ref_sink (g_variant_new_bytestring (strv[i]));
|
||||
|
||||
return g_variant_new_from_children (G_VARIANT_TYPE_BYTESTRING_ARRAY,
|
||||
strings, length, TRUE);
|
||||
strings, length_unsigned, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,10 +108,10 @@ typedef struct
|
||||
|
||||
/* Hard-code the base types in a constant array */
|
||||
static const GVariantTypeInfo g_variant_type_info_basic_table[24] = {
|
||||
#define fixed_aligned(x) x, x - 1
|
||||
#define not_a_type 0,
|
||||
#define unaligned 0, 0
|
||||
#define aligned(x) 0, x - 1
|
||||
#define fixed_aligned(x) x, x - 1, 0
|
||||
#define not_a_type 0, 0, 0
|
||||
#define unaligned 0, 0, 0
|
||||
#define aligned(x) 0, x - 1, 0
|
||||
/* 'b' */ { fixed_aligned(1) }, /* boolean */
|
||||
/* 'c' */ { not_a_type },
|
||||
/* 'd' */ { fixed_aligned(8) }, /* double */
|
||||
@ -362,7 +362,7 @@ static void
|
||||
tuple_info_free (GVariantTypeInfo *info)
|
||||
{
|
||||
TupleInfo *tuple_info;
|
||||
gint i;
|
||||
gsize i;
|
||||
|
||||
g_assert (info->container_class == GV_TUPLE_INFO_CLASS);
|
||||
tuple_info = (TupleInfo *) info;
|
||||
@ -640,7 +640,7 @@ tuple_set_base_info (TupleInfo *info)
|
||||
* offsets are stored and the last item is fixed-sized too (since
|
||||
* an offset is never stored for the last item).
|
||||
*/
|
||||
if (m->i == -1 && m->type_info->fixed_size)
|
||||
if (m->i == (gsize) -1 && m->type_info->fixed_size)
|
||||
/* in that case, the fixed size can be found by finding the
|
||||
* start of the last item (in the usual way) and adding its
|
||||
* fixed size.
|
||||
|
@ -183,7 +183,7 @@ static guint
|
||||
honeyman_hash (gconstpointer key)
|
||||
{
|
||||
const gchar *name = (const gchar *) key;
|
||||
gint size;
|
||||
gsize size;
|
||||
guint sum = 0;
|
||||
|
||||
g_assert (name != NULL);
|
||||
@ -1347,7 +1347,7 @@ test_lookup_extended (void)
|
||||
|
||||
struct _GHashTable
|
||||
{
|
||||
gint size;
|
||||
gsize size;
|
||||
gint mod;
|
||||
guint mask;
|
||||
gint nnodes;
|
||||
@ -1374,7 +1374,7 @@ struct _GHashTable
|
||||
static void
|
||||
count_keys (GHashTable *h, gint *unused, gint *occupied, gint *tombstones)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
|
||||
*unused = 0;
|
||||
*occupied = 0;
|
||||
@ -1410,7 +1410,7 @@ fetch_key_or_value (gpointer a, guint index, gboolean is_big)
|
||||
static void
|
||||
check_data (GHashTable *h)
|
||||
{
|
||||
gint i;
|
||||
gsize i;
|
||||
|
||||
for (i = 0; i < h->size; i++)
|
||||
{
|
||||
|
@ -352,6 +352,8 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||
'-Wmisleading-indentation',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wunused',
|
||||
# Due to maintained deprecated code, we do not want to see unused parameters
|
||||
'-Wno-unused-parameter',
|
||||
# Due to pervasive use of things like GPOINTER_TO_UINT(), we do not support
|
||||
# building with -Wbad-function-cast.
|
||||
'-Wno-bad-function-cast',
|
||||
|
Loading…
Reference in New Issue
Block a user