glib: Various minor scan-build fixes

These squash various warnings from `scan-build`. None of them are
legitimate bugs, but some of them do improve code readability a bit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1767
This commit is contained in:
Philip Withnall 2019-05-01 12:53:56 +01:00
parent 7a33239bab
commit 18a232be89
12 changed files with 17 additions and 9 deletions

View File

@ -542,13 +542,12 @@ g_credentials_set_unix_user (GCredentials *credentials,
uid_t uid,
GError **error)
{
gboolean ret;
gboolean ret = FALSE;
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), FALSE);
g_return_val_if_fail (uid != -1, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
ret = FALSE;
#if G_CREDENTIALS_USE_LINUX_UCRED
credentials->native.uid = uid;
ret = TRUE;

View File

@ -1344,6 +1344,7 @@ sha512_sum_close (Sha512sum *sha512)
memset (pad + pad_len, 0x00, zeros / 8);
pad_len += zeros / 8;
zeros = zeros % 8;
(void) zeros; /* dont care about the dead store */
/* put message bit length at the end of padding */
PUT_UINT64 (sha512->data_len[1], pad, pad_len);

View File

@ -3317,6 +3317,7 @@ g_key_file_set_key_comment (GKeyFile *key_file,
pair->value = g_key_file_parse_comment_as_value (key_file, comment);
key_node = g_list_insert (key_node, pair, 1);
(void) key_node;
return TRUE;
}

View File

@ -1040,6 +1040,7 @@ find_source_list_for_priority (GMainContext *context,
* context->source_lists without having to walk the list again.
*/
last = g_list_append (last, source_list);
(void) last;
}
return source_list;
}

View File

@ -2917,7 +2917,6 @@ g_markup_collect_attributes (const gchar *element_name,
failure:
/* replay the above to free allocations */
type = first_type;
attr = first_attr;
va_start (ap, first_attr);
while (type != G_MARKUP_COLLECT_INVALID)
@ -2952,7 +2951,10 @@ failure:
type = va_arg (ap, GMarkupCollectType);
if (type != G_MARKUP_COLLECT_INVALID)
attr = va_arg (ap, const char *);
{
attr = va_arg (ap, const char *);
(void) attr;
}
}
va_end (ap);

View File

@ -1313,7 +1313,7 @@ g_logv (const gchar *log_domain,
{
GLogLevelFlags test_level;
test_level = 1 << i;
test_level = 1L << i;
if (log_level & test_level)
{
GLogDomain *domain;

View File

@ -502,7 +502,7 @@ g_rand_int_range (GRand *rand,
gint32 end)
{
guint32 dist = end - begin;
guint32 random;
guint32 random = 0;
g_return_val_if_fail (rand != NULL, begin);
g_return_val_if_fail (end > begin, begin);
@ -563,7 +563,6 @@ g_rand_int_range (GRand *rand,
}
break;
default:
random = 0; /* Quiet GCC */
g_assert_not_reached ();
}

View File

@ -435,8 +435,6 @@ g_spawn_sync (const gchar *working_directory,
(outpipe >= 0 ||
errpipe >= 0))
{
ret = 0;
FD_ZERO (&fds);
if (outpipe >= 0)
FD_SET (outpipe, &fds);

View File

@ -3694,6 +3694,9 @@ g_test_trap_assertions (const char *domain,
g_assertion_message (domain, file, line, func, msg);
g_free (msg);
}
(void) logged_child_output; /* shut up scan-build about the final unread assignment */
g_free (process_id);
}

View File

@ -443,6 +443,7 @@ _g_utf8_normalize_wc (const gchar *str,
{
g_unicode_canonical_ordering (wc_buffer + last_start, n_wc - last_start);
last_start = n_wc;
(void) last_start;
}
wc_buffer[n_wc] = 0;

View File

@ -2527,6 +2527,8 @@ g_variant_new_parsed_va (const gchar *format,
if (*stream.stream)
g_error ("g_variant_new_parsed: trailing text after value");
g_clear_error (&error);
return result;
}

View File

@ -175,6 +175,7 @@ test_misc (void)
&error);
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_INVALID_VALUE);
g_clear_error (&error);
g_assert_false (res);
g_bookmark_file_set_mime_type (bookmark,
"file:///tmp/schedule1.ps",