Merge branch 'cleanup-warnings-split-5' into 'main'

Cleanup warnings split 5

See merge request GNOME/glib!2494
This commit is contained in:
Philip Withnall 2022-03-31 23:36:36 +00:00
commit 5486e00cf9
9 changed files with 56 additions and 58 deletions

View File

@ -2228,7 +2228,7 @@ g_socket_w32_get_adapter_ipv4_addr (const gchar *name_or_ip)
unsigned int malloc_iterations = 0;
PIP_ADAPTER_ADDRESSES addr_buf = NULL, eth_adapter;
wchar_t *wchar_name_or_ip = NULL;
gulong ip_result;
gulong ip_result = 0;
NET_IFINDEX if_index;
/*
@ -2247,8 +2247,7 @@ g_socket_w32_get_adapter_ipv4_addr (const gchar *name_or_ip)
*/
/* Step 1: Check if string is an IP address: */
ip_result = inet_addr (name_or_ip);
if (ip_result != INADDR_NONE)
if (inet_pton (AF_INET, name_or_ip, &ip_result) == 1)
return ip_result; /* Success, IP address string was given directly */
/*
@ -3887,7 +3886,7 @@ update_condition_unlocked (GSocket *socket)
if (socket->priv->current_events & FD_CLOSE)
{
int r, errsv, buffer;
int r, errsv = NO_ERROR, buffer;
r = recv (socket->priv->fd, &buffer, sizeof (buffer), MSG_PEEK);
if (r < 0)

View File

@ -734,7 +734,6 @@ nego_reply_read_cb (GObject *source,
if (data->offset == data->length)
{
GError *error = NULL;
gboolean must_auth = FALSE;
gboolean has_auth = data->username || data->password;

View File

@ -302,19 +302,19 @@ do_lookup_by_address (GTask *task,
GCancellable *cancellable)
{
GInetAddress *address = task_data;
struct sockaddr_storage sockaddr;
gsize sockaddr_size;
struct sockaddr_storage sockaddr_address;
gsize sockaddr_address_size;
GSocketAddress *gsockaddr;
gchar name[NI_MAXHOST];
gint retval;
gsockaddr = g_inet_socket_address_new (address, 0);
g_socket_address_to_native (gsockaddr, (struct sockaddr *)&sockaddr,
sizeof (sockaddr), NULL);
sockaddr_size = g_socket_address_get_native_size (gsockaddr);
g_socket_address_to_native (gsockaddr, (struct sockaddr *)&sockaddr_address,
sizeof (sockaddr_address), NULL);
sockaddr_address_size = g_socket_address_get_native_size (gsockaddr);
g_object_unref (gsockaddr);
retval = getnameinfo ((struct sockaddr *)&sockaddr, sockaddr_size,
retval = getnameinfo ((struct sockaddr *) &sockaddr_address, sockaddr_address_size,
name, sizeof (name), NULL, 0, NI_NAMEREQD);
if (retval == 0)
g_task_return_pointer (task, g_strdup (name), g_free);

View File

@ -571,13 +571,13 @@ parse_and_create_certificate_list (const gchar *data,
while (p < end && p && *p)
{
gchar *cert_pem;
GError *error = NULL;
GError *my_error = NULL;
cert_pem = parse_next_pem_certificate (&p, end, FALSE, &error);
if (error)
cert_pem = parse_next_pem_certificate (&p, end, FALSE, &my_error);
if (my_error)
{
g_slist_free_full (pem_list, g_free);
g_error_free (error);
g_error_free (my_error);
return first_pem_list;
}
else if (!cert_pem)

View File

@ -1742,7 +1742,7 @@ handler_add_verb (gpointer handler_data1,
{
GWin32AppInfoHandler *handler_rec = (GWin32AppInfoHandler *) handler_data1;
GWin32AppInfoApplication *app_rec = (GWin32AppInfoApplication *) handler_data2;
GWin32AppInfoShellVerb *shverb;
GWin32AppInfoShellVerb *shverb = NULL;
_verb_lookup (handler_rec->verbs, verb, &shverb);
@ -1788,7 +1788,7 @@ generate_new_verb_name (GPtrArray *verbs,
gchar **new_displayname)
{
gsize counter;
GWin32AppInfoShellVerb *shverb;
GWin32AppInfoShellVerb *shverb = NULL;
gsize orig_len = g_utf16_len (verb);
gsize new_verb_name_len = orig_len + strlen (" ()") + 2 + 1;
gunichar2 *new_verb_name = g_new (gunichar2, new_verb_name_len);
@ -1828,7 +1828,7 @@ app_add_verb (gpointer handler_data1,
gunichar2 *new_verb = NULL;
gchar *new_displayname = NULL;
GWin32AppInfoApplication *app_rec = (GWin32AppInfoApplication *) handler_data2;
GWin32AppInfoShellVerb *shverb;
GWin32AppInfoShellVerb *shverb = NULL;
_verb_lookup (app_rec->verbs, verb, &shverb);
@ -1899,7 +1899,7 @@ uwp_app_add_verb (GWin32AppInfoApplication *app_rec,
const gunichar2 *verb,
const gchar *verb_displayname)
{
GWin32AppInfoShellVerb *shverb;
GWin32AppInfoShellVerb *shverb = NULL;
_verb_lookup (app_rec->verbs, verb, &shverb);
@ -1934,7 +1934,7 @@ uwp_handler_add_verb (GWin32AppInfoHandler *handler_rec,
const gchar *verb_displayname,
gboolean verb_is_preferred)
{
GWin32AppInfoShellVerb *shverb;
GWin32AppInfoShellVerb *shverb = NULL;
_verb_lookup (handler_rec->verbs, verb, &shverb);
@ -2530,8 +2530,8 @@ read_capable_app (const gunichar2 *app_key_path,
while (g_win32_registry_value_iter_next (&iter, TRUE, NULL))
{
gchar *schema_u8;
gchar *schema_u8_folded;
gchar *schema_u8 = NULL;
gchar *schema_u8_folded = NULL;
if ((!g_win32_registry_value_iter_get_value_type (&iter,
&value_type,
@ -2791,18 +2791,18 @@ read_incapable_app (GWin32RegistryKey *incapable_app,
static void
read_exeapps (void)
{
GWin32RegistryKey *applications_key;
GWin32RegistryKey *local_applications_key;
GWin32RegistrySubkeyIter app_iter;
applications_key =
local_applications_key =
g_win32_registry_key_new_w (L"HKEY_CLASSES_ROOT\\Applications", NULL);
if (applications_key == NULL)
if (local_applications_key == NULL)
return;
if (!g_win32_registry_subkey_iter_init (&app_iter, applications_key, NULL))
if (!g_win32_registry_subkey_iter_init (&app_iter, local_applications_key, NULL))
{
g_object_unref (applications_key);
g_object_unref (local_applications_key);
return;
}
@ -2825,7 +2825,7 @@ read_exeapps (void)
continue;
incapable_app =
g_win32_registry_key_get_child_w (applications_key,
g_win32_registry_key_get_child_w (local_applications_key,
app_exe_basename,
NULL);
@ -2841,7 +2841,7 @@ read_exeapps (void)
}
g_win32_registry_subkey_iter_clear (&app_iter);
g_object_unref (applications_key);
g_object_unref (local_applications_key);
}
/* Iterates over subkeys of HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\
@ -3091,7 +3091,7 @@ link_handlers_to_unregistered_apps (void)
GOT_SH_INFO,
ERROR_GETTING_SH_INFO,
} have_stat_handler = SH_UNKNOWN;
GWin32PrivateStat handler_verb_exec_info;
GWin32PrivateStat handler_verb_exec_info = { 0 };
handler_verb = _verb_idx (handler->verbs, vi);
@ -3365,7 +3365,7 @@ uwp_package_cb (gpointer user_data,
gchar *app_user_model_id_u8;
gchar *app_user_model_id_u8_folded;
GHashTableIter iter;
GWin32AppInfoHandler *ext;
GWin32AppInfoHandler *ext_handler;
GWin32AppInfoHandler *url;
if (!g_utf16_to_utf8_and_fold (app_user_model_id,
@ -3457,18 +3457,18 @@ uwp_package_cb (gpointer user_data,
/* Pile up all handler verbs into the app too,
* for cases when we don't have a ref to a handler.
*/
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &ext))
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &ext_handler))
{
guint i_hverb;
if (!ext)
if (!ext_handler)
continue;
for (i_hverb = 0; i_hverb < ext->verbs->len; i_hverb++)
for (i_hverb = 0; i_hverb < ext_handler->verbs->len; i_hverb++)
{
GWin32AppInfoShellVerb *handler_verb;
handler_verb = _verb_idx (ext->verbs, i_hverb);
handler_verb = _verb_idx (ext_handler->verbs, i_hverb);
uwp_app_add_verb (app, handler_verb->verb_name, handler_verb->verb_displayname);
if (handler_verb->app == NULL && handler_verb->is_uwp)
handler_verb->app = g_object_ref (app);
@ -4453,7 +4453,7 @@ Legend: (from http://msdn.microsoft.com/en-us/library/windows/desktop/cc144101%2
{
gint i;
GList *o;
gint n;
gint n = 0;
switch (macro)
{

View File

@ -386,8 +386,8 @@ _file_sync_stream_stat (IStream *self_ptr,
if (buffer_size == 0)
{
DWORD error = GetLastError ();
return __HRESULT_FROM_WIN32 (error);
DWORD my_error = GetLastError ();
return __HRESULT_FROM_WIN32 (my_error);
}
buffer = CoTaskMemAlloc (buffer_size);

View File

@ -131,7 +131,7 @@ test_async_queue_destroy (void)
g_assert_cmpint (destroy_count, ==, 4);
}
static GAsyncQueue *q;
static GAsyncQueue *global_queue;
static GThread *threads[10];
static gint counts[10];
@ -146,7 +146,7 @@ thread_func (gpointer data)
while (1)
{
value = GPOINTER_TO_INT (g_async_queue_pop (q));
value = GPOINTER_TO_INT (g_async_queue_pop (global_queue));
if (value == -1)
break;
@ -167,32 +167,32 @@ test_async_queue_threads (void)
gint s, c;
gint value;
q = g_async_queue_new ();
global_queue = g_async_queue_new ();
for (i = 0; i < 10; i++)
threads[i] = g_thread_new ("test", thread_func, GINT_TO_POINTER (i));
for (i = 0; i < 100; i++)
{
g_async_queue_lock (q);
g_async_queue_lock (global_queue);
for (j = 0; j < 10; j++)
{
value = g_random_int_range (1, 100);
total += value;
g_async_queue_push_unlocked (q, GINT_TO_POINTER (value));
g_async_queue_push_unlocked (global_queue, GINT_TO_POINTER (value));
}
g_async_queue_unlock (q);
g_async_queue_unlock (global_queue);
g_usleep (1000);
}
for (i = 0; i < 10; i++)
g_async_queue_push (q, GINT_TO_POINTER(-1));
g_async_queue_push (global_queue, GINT_TO_POINTER (-1));
for (i = 0; i < 10; i++)
g_thread_join (threads[i]);
g_assert_cmpint (g_async_queue_length (q), ==, 0);
g_assert_cmpint (g_async_queue_length (global_queue), ==, 0);
s = c = 0;
@ -207,7 +207,7 @@ test_async_queue_threads (void)
g_assert_cmpint (s, ==, total);
g_assert_cmpint (c, ==, 1000);
g_async_queue_unref (q);
g_async_queue_unref (global_queue);
}
static void

View File

@ -5,7 +5,7 @@
#define DATA_SIZE 1024
#define BLOCK_SIZE 32
#define NUM_BLOCKS 32
static guchar data[DATA_SIZE];
static guchar global_data[DATA_SIZE];
static void
test_incremental (gboolean line_break,
@ -28,7 +28,7 @@ test_incremental (gboolean line_break,
while (input_len < length)
{
block_size = MIN (BLOCK_SIZE, length - input_len);
len += g_base64_encode_step (data + input_len, block_size,
len += g_base64_encode_step (global_data + input_len, block_size,
line_break, text + len, &state, &save);
input_len += block_size;
}
@ -57,7 +57,7 @@ test_incremental (gboolean line_break,
len -= chunk_len;
}
g_assert_cmpmem (data, length, data2, decoded_len);
g_assert_cmpmem (global_data, length, data2, decoded_len);
g_free (text);
g_free (data2);
@ -87,11 +87,11 @@ test_full (gconstpointer d)
guchar *data2;
gsize len;
text = g_base64_encode (data, length);
text = g_base64_encode (global_data, length);
data2 = g_base64_decode (text, &len);
g_free (text);
g_assert_cmpmem (data, length, data2, len);
g_assert_cmpmem (global_data, length, data2, len);
g_free (data2);
}
@ -494,7 +494,7 @@ main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
for (i = 0; i < DATA_SIZE; i++)
data[i] = (guchar)i;
global_data[i] = (guchar) i;
g_test_add_data_func ("/base64/full/1", GINT_TO_POINTER (DATA_SIZE), test_full);
g_test_add_data_func ("/base64/full/2", GINT_TO_POINTER (1), test_full);

View File

@ -239,7 +239,7 @@ test_wait_until (void)
{
gint64 until;
GMutex lock;
GCond cond;
GCond local_cond;
/* This test will make sure we don't wait too much or too little.
*
@ -249,13 +249,13 @@ test_wait_until (void)
* should not wake up until the specified time has passed.
*/
g_mutex_init (&lock);
g_cond_init (&cond);
g_cond_init (&local_cond);
until = g_get_monotonic_time () + G_TIME_SPAN_SECOND;
/* Could still have spurious wakeups, so we must loop... */
g_mutex_lock (&lock);
while (g_cond_wait_until (&cond, &lock, until))
while (g_cond_wait_until (&local_cond, &lock, until))
;
g_mutex_unlock (&lock);
@ -265,11 +265,11 @@ test_wait_until (void)
/* Make sure it returns FALSE on timeout */
until = g_get_monotonic_time () + G_TIME_SPAN_SECOND / 50;
g_mutex_lock (&lock);
g_assert (g_cond_wait_until (&cond, &lock, until) == FALSE);
g_assert (g_cond_wait_until (&local_cond, &lock, until) == FALSE);
g_mutex_unlock (&lock);
g_mutex_clear (&lock);
g_cond_clear (&cond);
g_cond_clear (&local_cond);
}
#ifdef __linux__