Commit 0f6b25ca authored by Matthias Clasen's avatar Matthias Clasen

Fix some compiler warnings

svn path=/trunk/; revision=7755
parent caa5ed0d
2008-12-30 Matthias Clasen <mclasen@redhat.com>
* glib/gspawn.c:
* glib/gthread.c:
* glib/goption.c:
* glib/gmain.c:
* glib/gkeyfile.c:
* glib/gfileutils.c:
* glib/gdate.c:
* glib/garray.c:
* glib/gbookmarkfile.c:
* glib/gbacktrace.c: Fix some compiler warnings.
2008-12-19 Tor Lillqvist <tml@novell.com>
* glib/glib.symbols: Add g_thread_get_initialized here,
......
......@@ -102,8 +102,8 @@ GArray* g_array_sized_new (gboolean zero_terminated,
}
gchar*
g_array_free (GArray *array,
gboolean free_segment)
g_array_free (GArray *array,
gboolean free_segment)
{
gchar* segment;
......@@ -164,7 +164,7 @@ g_array_prepend_vals (GArray *farray,
GArray*
g_array_insert_vals (GArray *farray,
guint index,
guint index_,
gconstpointer data,
guint len)
{
......@@ -172,11 +172,11 @@ g_array_insert_vals (GArray *farray,
g_array_maybe_expand (array, len);
g_memmove (g_array_elt_pos (array, len + index),
g_array_elt_pos (array, index),
g_array_elt_len (array, array->len - index));
g_memmove (g_array_elt_pos (array, len + index_),
g_array_elt_pos (array, index_),
g_array_elt_len (array, array->len - index_));
memcpy (g_array_elt_pos (array, index), data, g_array_elt_len (array, len));
memcpy (g_array_elt_pos (array, index_), data, g_array_elt_len (array, len));
array->len += len;
......@@ -208,19 +208,19 @@ g_array_set_size (GArray *farray,
}
GArray*
g_array_remove_index (GArray* farray,
guint index)
g_array_remove_index (GArray *farray,
guint index_)
{
GRealArray* array = (GRealArray*) farray;
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index < array->len, NULL);
g_return_val_if_fail (index_ < array->len, NULL);
if (index != array->len - 1)
g_memmove (g_array_elt_pos (array, index),
g_array_elt_pos (array, index + 1),
g_array_elt_len (array, array->len - index - 1));
if (index_ != array->len - 1)
g_memmove (g_array_elt_pos (array, index_),
g_array_elt_pos (array, index_ + 1),
g_array_elt_len (array, array->len - index_ - 1));
array->len -= 1;
......@@ -233,17 +233,17 @@ g_array_remove_index (GArray* farray,
}
GArray*
g_array_remove_index_fast (GArray* farray,
guint index)
g_array_remove_index_fast (GArray *farray,
guint index_)
{
GRealArray* array = (GRealArray*) farray;
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index < array->len, NULL);
g_return_val_if_fail (index_ < array->len, NULL);
if (index != array->len - 1)
memcpy (g_array_elt_pos (array, index),
if (index_ != array->len - 1)
memcpy (g_array_elt_pos (array, index_),
g_array_elt_pos (array, array->len - 1),
g_array_elt_len (array, 1));
......@@ -258,9 +258,9 @@ g_array_remove_index_fast (GArray* farray,
}
GArray*
g_array_remove_range (GArray *farray,
guint index_,
guint length)
g_array_remove_range (GArray *farray,
guint index_,
guint length)
{
GRealArray *array = (GRealArray*) farray;
......@@ -382,8 +382,8 @@ g_ptr_array_sized_new (guint reserved_size)
}
gpointer*
g_ptr_array_free (GPtrArray *array,
gboolean free_segment)
g_ptr_array_free (GPtrArray *array,
gboolean free_segment)
{
gpointer* segment;
......@@ -404,7 +404,7 @@ g_ptr_array_free (GPtrArray *array,
static void
g_ptr_array_maybe_expand (GRealPtrArray *array,
gint len)
gint len)
{
if ((array->len + len) > array->alloc)
{
......@@ -419,8 +419,8 @@ g_ptr_array_maybe_expand (GRealPtrArray *array,
}
void
g_ptr_array_set_size (GPtrArray *farray,
gint length)
g_ptr_array_set_size (GPtrArray *farray,
gint length)
{
GRealPtrArray* array = (GRealPtrArray*) farray;
......@@ -450,21 +450,21 @@ g_ptr_array_set_size (GPtrArray *farray,
}
gpointer
g_ptr_array_remove_index (GPtrArray* farray,
guint index)
g_ptr_array_remove_index (GPtrArray *farray,
guint index_)
{
GRealPtrArray* array = (GRealPtrArray*) farray;
gpointer result;
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index < array->len, NULL);
g_return_val_if_fail (index_ < array->len, NULL);
result = array->pdata[index];
result = array->pdata[index_];
if (index != array->len - 1)
g_memmove (array->pdata + index, array->pdata + index + 1,
sizeof (gpointer) * (array->len - index - 1));
if (index_ != array->len - 1)
g_memmove (array->pdata + index_, array->pdata + index_ + 1,
sizeof (gpointer) * (array->len - index_ - 1));
array->len -= 1;
......@@ -475,20 +475,20 @@ g_ptr_array_remove_index (GPtrArray* farray,
}
gpointer
g_ptr_array_remove_index_fast (GPtrArray* farray,
guint index)
g_ptr_array_remove_index_fast (GPtrArray *farray,
guint index_)
{
GRealPtrArray* array = (GRealPtrArray*) farray;
gpointer result;
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index < array->len, NULL);
g_return_val_if_fail (index_ < array->len, NULL);
result = array->pdata[index];
result = array->pdata[index_];
if (index != array->len - 1)
array->pdata[index] = array->pdata[array->len - 1];
if (index_ != array->len - 1)
array->pdata[index_] = array->pdata[array->len - 1];
array->len -= 1;
......@@ -499,7 +499,7 @@ g_ptr_array_remove_index_fast (GPtrArray* farray,
}
void
g_ptr_array_remove_range (GPtrArray* farray,
g_ptr_array_remove_range (GPtrArray *farray,
guint index_,
guint length)
{
......@@ -524,8 +524,8 @@ g_ptr_array_remove_range (GPtrArray* farray,
}
gboolean
g_ptr_array_remove (GPtrArray* farray,
gpointer data)
g_ptr_array_remove (GPtrArray *farray,
gpointer data)
{
GRealPtrArray* array = (GRealPtrArray*) farray;
guint i;
......@@ -545,8 +545,8 @@ g_ptr_array_remove (GPtrArray* farray,
}
gboolean
g_ptr_array_remove_fast (GPtrArray* farray,
gpointer data)
g_ptr_array_remove_fast (GPtrArray *farray,
gpointer data)
{
GRealPtrArray* array = (GRealPtrArray*) farray;
guint i;
......@@ -566,8 +566,8 @@ g_ptr_array_remove_fast (GPtrArray* farray,
}
void
g_ptr_array_add (GPtrArray* farray,
gpointer data)
g_ptr_array_add (GPtrArray *farray,
gpointer data)
{
GRealPtrArray* array = (GRealPtrArray*) farray;
......@@ -630,7 +630,7 @@ g_ptr_array_foreach (GPtrArray *array,
/* Byte arrays
*/
GByteArray* g_byte_array_new (void)
GByteArray* g_byte_array_new (void)
{
return (GByteArray*) g_array_sized_new (FALSE, FALSE, 1, 0);
}
......@@ -646,18 +646,18 @@ guint8* g_byte_array_free (GByteArray *array,
return (guint8*) g_array_free ((GArray*) array, free_segment);
}
GByteArray* g_byte_array_append (GByteArray *array,
GByteArray* g_byte_array_append (GByteArray *array,
const guint8 *data,
guint len)
guint len)
{
g_array_append_vals ((GArray*) array, (guint8*)data, len);
return array;
}
GByteArray* g_byte_array_prepend (GByteArray *array,
GByteArray* g_byte_array_prepend (GByteArray *array,
const guint8 *data,
guint len)
guint len)
{
g_array_prepend_vals ((GArray*) array, (guint8*)data, len);
......@@ -673,25 +673,25 @@ GByteArray* g_byte_array_set_size (GByteArray *array,
}
GByteArray* g_byte_array_remove_index (GByteArray *array,
guint index)
guint index_)
{
g_array_remove_index((GArray*) array, index);
g_array_remove_index ((GArray*) array, index_);
return array;
}
GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
guint index)
guint index_)
{
g_array_remove_index_fast((GArray*) array, index);
g_array_remove_index_fast ((GArray*) array, index_);
return array;
}
GByteArray*
g_byte_array_remove_range (GByteArray *array,
guint index_,
guint length)
guint index_,
guint length)
{
g_return_val_if_fail (array, NULL);
g_return_val_if_fail (index_ < array->len, NULL);
......
......@@ -212,7 +212,7 @@ stack_trace (char **args)
SELECT_MASK fdset;
SELECT_MASK readset;
struct timeval tv;
int sel, index, state;
int sel, idx, state;
char buffer[256];
char c;
......@@ -249,7 +249,7 @@ stack_trace (char **args)
write (in_fd[1], "p x = 0\n", 8);
write (in_fd[1], "quit\n", 5);
index = 0;
idx = 0;
state = 0;
while (1)
......@@ -272,18 +272,18 @@ stack_trace (char **args)
if (c == '#')
{
state = 1;
index = 0;
buffer[index++] = c;
idx = 0;
buffer[idx++] = c;
}
break;
case 1:
buffer[index++] = c;
buffer[idx++] = c;
if ((c == '\n') || (c == '\r'))
{
buffer[index] = 0;
buffer[idx] = 0;
_g_fprintf (stdout, "%s", buffer);
state = 0;
index = 0;
idx = 0;
}
break;
default:
......
......@@ -1409,7 +1409,7 @@ g_bookmark_file_parse (GBookmarkFile *bookmark,
if (!buffer)
return FALSE;
if (length == -1)
if (length == (gsize) -1)
length = strlen (buffer);
parse_data = parse_data_new ();
......
......@@ -176,7 +176,7 @@ g_date_update_julian (const GDate *const_d)
{
GDate *d = (GDate *) const_d;
GDateYear year;
gint index;
gint idx;
g_return_if_fail (d != NULL);
g_return_if_fail (d->dmy);
......@@ -184,10 +184,10 @@ g_date_update_julian (const GDate *const_d)
g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year));
/* What we actually do is: multiply years * 365 days in the year,
* add the number of years divided by 4, subtract the number of
* years divided by 100 and add the number of years divided by 400,
* which accounts for leap year stuff. Code from Steffen Beyer's
* DateCalc.
* add the number of years divided by 4, subtract the number of
* years divided by 100 and add the number of years divided by 400,
* which accounts for leap year stuff. Code from Steffen Beyer's
* DateCalc.
*/
year = d->year - 1; /* we know d->year > 0 since it's valid */
......@@ -197,9 +197,9 @@ g_date_update_julian (const GDate *const_d)
d->julian_days -= (year /= 25); /* divides original # years by 100 */
d->julian_days += year >> 2; /* divides by 4, which divides original by 400 */
index = g_date_is_leap_year (d->year) ? 1 : 0;
idx = g_date_is_leap_year (d->year) ? 1 : 0;
d->julian_days += days_in_year[index][d->month] + d->day;
d->julian_days += days_in_year[idx][d->month] + d->day;
g_return_if_fail (g_date_valid_julian (d->julian_days));
......@@ -321,7 +321,7 @@ g_date_get_julian (const GDate *d)
guint
g_date_get_day_of_year (const GDate *d)
{
gint index;
gint idx;
g_return_val_if_fail (g_date_valid (d), 0);
......@@ -330,9 +330,9 @@ g_date_get_day_of_year (const GDate *d)
g_return_val_if_fail (d->dmy, 0);
index = g_date_is_leap_year (d->year) ? 1 : 0;
idx = g_date_is_leap_year (d->year) ? 1 : 0;
return (days_in_year[index][d->month] + d->day);
return (days_in_year[idx][d->month] + d->day);
}
guint
......@@ -672,7 +672,9 @@ g_date_prepare_to_parse (const gchar *str,
++i;
}
if (using_twodigit_years)
DEBUG_MSG (("**Using twodigit years with cutoff year: %u", twodigit_start_year));
{
DEBUG_MSG (("**Using twodigit years with cutoff year: %u", twodigit_start_year));
}
{
gchar *strings[3];
i = 0;
......@@ -851,7 +853,9 @@ g_date_set_parse (GDate *d,
}
#ifdef G_ENABLE_DEBUG
else
DEBUG_MSG (("Rejected DMY %u %u %u", day, m, y));
{
DEBUG_MSG (("Rejected DMY %u %u %u", day, m, y));
}
#endif
G_UNLOCK (g_date_global);
}
......@@ -1053,7 +1057,7 @@ g_date_is_first_of_month (const GDate *d)
gboolean
g_date_is_last_of_month (const GDate *d)
{
gint index;
gint idx;
g_return_val_if_fail (g_date_valid (d), FALSE);
......@@ -1062,9 +1066,9 @@ g_date_is_last_of_month (const GDate *d)
g_return_val_if_fail (d->dmy, FALSE);
index = g_date_is_leap_year (d->year) ? 1 : 0;
idx = g_date_is_leap_year (d->year) ? 1 : 0;
if (d->day == days_in_months[index][d->month]) return TRUE;
if (d->day == days_in_months[idx][d->month]) return TRUE;
else return FALSE;
}
......@@ -1104,7 +1108,7 @@ g_date_add_months (GDate *d,
guint nmonths)
{
guint years, months;
gint index;
gint idx;
g_return_if_fail (g_date_valid (d));
......@@ -1121,10 +1125,10 @@ g_date_add_months (GDate *d,
d->month = months + 1;
d->year += years;
index = g_date_is_leap_year (d->year) ? 1 : 0;
idx = g_date_is_leap_year (d->year) ? 1 : 0;
if (d->day > days_in_months[index][d->month])
d->day = days_in_months[index][d->month];
if (d->day > days_in_months[idx][d->month])
d->day = days_in_months[idx][d->month];
d->julian = FALSE;
......@@ -1136,7 +1140,7 @@ g_date_subtract_months (GDate *d,
guint nmonths)
{
guint years, months;
gint index;
gint idx;
g_return_if_fail (g_date_valid (d));
......@@ -1160,10 +1164,10 @@ g_date_subtract_months (GDate *d,
d->year -= 1;
}
index = g_date_is_leap_year (d->year) ? 1 : 0;
idx = g_date_is_leap_year (d->year) ? 1 : 0;
if (d->day > days_in_months[index][d->month])
d->day = days_in_months[index][d->month];
if (d->day > days_in_months[idx][d->month])
d->day = days_in_months[idx][d->month];
d->julian = FALSE;
......@@ -1228,14 +1232,14 @@ guint8
g_date_get_days_in_month (GDateMonth month,
GDateYear year)
{
gint index;
gint idx;
g_return_val_if_fail (g_date_valid_year (year), 0);
g_return_val_if_fail (g_date_valid_month (month), 0);
index = g_date_is_leap_year (year) ? 1 : 0;
idx = g_date_is_leap_year (year) ? 1 : 0;
return days_in_months[index][month];
return days_in_months[idx][month];
}
guint8
......
......@@ -518,11 +518,11 @@ g_file_error_from_errno (gint err_no)
}
static gboolean
get_contents_stdio (const gchar *display_filename,
FILE *f,
gchar **contents,
gsize *length,
GError **error)
get_contents_stdio (const gchar *display_filename,
FILE *f,
gchar **contents,
gsize *length,
GError **error)
{
gchar buf[4096];
gsize bytes;
......@@ -620,12 +620,12 @@ get_contents_stdio (const gchar *display_filename,
#ifndef G_OS_WIN32
static gboolean
get_contents_regfile (const gchar *display_filename,
struct stat *stat_buf,
gint fd,
gchar **contents,
gsize *length,
GError **error)
get_contents_regfile (const gchar *display_filename,
struct stat *stat_buf,
gint fd,
gchar **contents,
gsize *length,
GError **error)
{
gchar *buf;
gsize bytes_read;
......@@ -698,10 +698,10 @@ get_contents_regfile (const gchar *display_filename,
}
static gboolean
get_contents_posix (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
get_contents_posix (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
{
struct stat stat_buf;
gint fd;
......@@ -786,10 +786,10 @@ get_contents_posix (const gchar *filename,
#else /* G_OS_WIN32 */
static gboolean
get_contents_win32 (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
get_contents_win32 (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
{
FILE *f;
gboolean retval;
......@@ -841,10 +841,10 @@ get_contents_win32 (const gchar *filename,
* Return value: %TRUE on success, %FALSE if an error occurred
**/
gboolean
g_file_get_contents (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
g_file_get_contents (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
{
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (contents != NULL, FALSE);
......@@ -867,10 +867,10 @@ g_file_get_contents (const gchar *filename,
/* Binary compatibility version. Not for newly compiled code. */
gboolean
g_file_get_contents (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
g_file_get_contents (const gchar *filename,
gchar **contents,
gsize *length,
GError **error)
{
gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, error);
gboolean retval;
......@@ -888,9 +888,9 @@ g_file_get_contents (const gchar *filename,
#endif
static gboolean
rename_file (const char *old_name,
const char *new_name,
GError **err)
rename_file (const char *old_name,
const char *new_name,
GError **err)
{
errno = 0;
if (g_rename (old_name, new_name) == -1)
......@@ -917,10 +917,10 @@ rename_file (const char *old_name,
}
static gchar *
write_to_temp_file (const gchar *contents,
gssize length,
const gchar *template,
GError **err)
write_to_temp_file (const gchar *contents,
gssize length,
const gchar *template,
GError **err)
{
gchar *tmp_name;
gchar *display_name;
......@@ -1061,10 +1061,10 @@ write_to_temp_file (const gchar *contents,
* Since: 2.8
**/
gboolean
g_file_set_contents (const gchar *filename,
const gchar *contents,
gssize length,
GError **error)
g_file_set_contents (const gchar *filename,
const gchar *contents,
gssize length,
GError **error)
{
gchar *tmp_filename;
gboolean retval;
......@@ -1337,13 +1337,13 @@ g_mkstemp (gchar *tmpl)
* and @error will be set.
**/
gint
g_file_open_tmp (const gchar *tmpl,
gchar **name_used,
GError **error)
g_file_open_tmp (const gchar *tmpl,
gchar **name_used,
GError **error)
{
int retval;
const char *tmpdir;
char *sep;
const char *sep;
char *fulltemplate;
const char *slash;
......@@ -1424,9 +1424,9 @@ g_file_open_tmp (const gchar *tmpl,
/* Binary compatibility version. Not for newly compiled code. */
gint
g_file_open_tmp (const gchar *tmpl,
gchar **name_used,
GError **error)
g_file_open_tmp (const gchar *tmpl,
gchar **name_used,
GError **error)
{
gchar *utf8_tmpl = g_locale_to_utf8 (tmpl, -1, NULL, NULL, error);
gchar *utf8_name_used;
......@@ -1880,8 +1880,8 @@ g_format_size_for_display (goffset size)
* Since: 2.4
*/
gchar *
g_file_read_link (const gchar *filename,
GError **error)
g_file_read_link (const gchar *filename,
GError **error)
{
#ifdef HAVE_READLINK
gchar *buffer;
......
......@@ -182,7 +182,6 @@ g_io_error_get_from_g_error (GIOStatus status,
}
default:
g_assert_not_reached ();
return G_IO_ERROR_UNKNOWN; /* Keep the compiler happy */
}
}
......
......@@ -2526,8 +2526,6 @@ g_key_file_set_key_comment (GKeyFile *key_file,
tmp = key_node->next;
while (tmp != NULL)
{
GKeyFileKeyValuePair *pair;
pair = (GKeyFileKeyValuePair *) tmp->data;
if (pair->key != NULL)
......@@ -2748,8 +2746,6 @@ g_key_file_get_key_comment (GKeyFile *key_file,
while (tmp != key_node)
{
GKeyFileKeyValuePair *pair;
pair = (GKeyFileKeyValuePair *) tmp->data;
if (string == NULL)
......
......@@ -3668,8 +3668,8 @@ g_child_watch_source_init_single (void)
sigaction (SIGCHLD, &action, NULL);
}
static gpointer
child_watch_helper_thread (gpointer data)
G_GNUC_NORETURN static gpointer
child_watch_helper_thread (gpointer data)
{
while (1)
{
......@@ -3694,8 +3694,6 @@ child_watch_helper_thread (gpointer data)
}
G_UNLOCK (main_context_list);
}
return NULL;
}
static void
......
......@@ -656,13 +656,13 @@ g_option_context_get_help (GOptionContext *context,
list = context->groups;
while (list != NULL)
{
GOptionGroup *group = list->data;
for (i = 0; i < group->n_entries; i++)
GOptionGroup *g = list->data;
for (i = 0; i < g->n_entries; i++)
{
entry = &group->entries[i];
entry = &g->entries[i];
if (g_hash_table_lookup (shadow_map, entry->long_name) &&
!(entry->flags & G_OPTION_FLAG_NOALIAS))
entry->long_name = g_strdup_printf ("%s-%s", group->name, entry->long_name);
entry->long_name = g_strdup_printf ("%s-%s", g->name, entry->long_name);
else
g_hash_table_insert (shadow_map, (gpointer)entry->long_name, entry);
......@@ -695,14 +695,14 @@ g_option_context_get_help (GOptionContext *context,
while (list != NULL)
{