mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
Merge branch '1767-scan-build-fixes' into 'master'
Various small scan-build fixes See merge request GNOME/glib!1088
This commit is contained in:
@@ -542,13 +542,12 @@ g_credentials_set_unix_user (GCredentials *credentials,
|
|||||||
uid_t uid,
|
uid_t uid,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), FALSE);
|
g_return_val_if_fail (G_IS_CREDENTIALS (credentials), FALSE);
|
||||||
g_return_val_if_fail (uid != -1, FALSE);
|
g_return_val_if_fail (uid != -1, FALSE);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
ret = FALSE;
|
|
||||||
#if G_CREDENTIALS_USE_LINUX_UCRED
|
#if G_CREDENTIALS_USE_LINUX_UCRED
|
||||||
credentials->native.uid = uid;
|
credentials->native.uid = uid;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
@@ -170,6 +170,7 @@ name_new (GDBusDaemon *daemon, const char *str)
|
|||||||
static Name *
|
static Name *
|
||||||
name_ref (Name *name)
|
name_ref (Name *name)
|
||||||
{
|
{
|
||||||
|
g_assert (name->refcount > 0);
|
||||||
name->refcount++;
|
name->refcount++;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -177,6 +178,7 @@ name_ref (Name *name)
|
|||||||
static void
|
static void
|
||||||
name_unref (Name *name)
|
name_unref (Name *name)
|
||||||
{
|
{
|
||||||
|
g_assert (name->refcount > 0);
|
||||||
if (--name->refcount == 0)
|
if (--name->refcount == 0)
|
||||||
{
|
{
|
||||||
g_hash_table_remove (name->daemon->names, name->name);
|
g_hash_table_remove (name->daemon->names, name->name);
|
||||||
@@ -1463,10 +1465,11 @@ filter_function (GDBusConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
Client *client = user_data;
|
Client *client = user_data;
|
||||||
const char *types[] = {"invalid", "method_call", "method_return", "error", "signal" };
|
|
||||||
|
|
||||||
if (0)
|
if (0)
|
||||||
g_printerr ("%s%s %s %d(%d) sender: %s destination: %s %s %s.%s\n",
|
{
|
||||||
|
const char *types[] = {"invalid", "method_call", "method_return", "error", "signal" };
|
||||||
|
g_printerr ("%s%s %s %d(%d) sender: %s destination: %s %s %s.%s\n",
|
||||||
client->id,
|
client->id,
|
||||||
incoming? "->" : "<-",
|
incoming? "->" : "<-",
|
||||||
types[g_dbus_message_get_message_type (message)],
|
types[g_dbus_message_get_message_type (message)],
|
||||||
@@ -1477,6 +1480,7 @@ filter_function (GDBusConnection *connection,
|
|||||||
g_dbus_message_get_path (message),
|
g_dbus_message_get_path (message),
|
||||||
g_dbus_message_get_interface (message),
|
g_dbus_message_get_interface (message),
|
||||||
g_dbus_message_get_member (message));
|
g_dbus_message_get_member (message));
|
||||||
|
}
|
||||||
|
|
||||||
if (incoming)
|
if (incoming)
|
||||||
{
|
{
|
||||||
|
@@ -25,7 +25,9 @@
|
|||||||
#error "config.h must be included prior to gio_trace.h"
|
#error "config.h must be included prior to gio_trace.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DTRACE
|
/* Ignore probes when doing static analysis, as they do weird things which
|
||||||
|
* confuses the analyser. */
|
||||||
|
#if defined(HAVE_DTRACE) && !defined(__clang_analyzer__)
|
||||||
|
|
||||||
/* include the generated probes header and put markers in code */
|
/* include the generated probes header and put markers in code */
|
||||||
#include "gio_probes.h"
|
#include "gio_probes.h"
|
||||||
|
@@ -1344,6 +1344,7 @@ sha512_sum_close (Sha512sum *sha512)
|
|||||||
memset (pad + pad_len, 0x00, zeros / 8);
|
memset (pad + pad_len, 0x00, zeros / 8);
|
||||||
pad_len += zeros / 8;
|
pad_len += zeros / 8;
|
||||||
zeros = zeros % 8;
|
zeros = zeros % 8;
|
||||||
|
(void) zeros; /* don’t care about the dead store */
|
||||||
|
|
||||||
/* put message bit length at the end of padding */
|
/* put message bit length at the end of padding */
|
||||||
PUT_UINT64 (sha512->data_len[1], pad, pad_len);
|
PUT_UINT64 (sha512->data_len[1], pad, pad_len);
|
||||||
|
@@ -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);
|
pair->value = g_key_file_parse_comment_as_value (key_file, comment);
|
||||||
|
|
||||||
key_node = g_list_insert (key_node, pair, 1);
|
key_node = g_list_insert (key_node, pair, 1);
|
||||||
|
(void) key_node;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,9 @@
|
|||||||
#error "config.h must be included prior to glib_trace.h"
|
#error "config.h must be included prior to glib_trace.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DTRACE
|
/* Ignore probes when doing static analysis, as they do weird things which
|
||||||
|
* confuses the analyser. */
|
||||||
|
#if defined(HAVE_DTRACE) && !defined(__clang_analyzer__)
|
||||||
|
|
||||||
/* include the generated probes header and put markers in code */
|
/* include the generated probes header and put markers in code */
|
||||||
#include "glib_probes.h"
|
#include "glib_probes.h"
|
||||||
|
@@ -1040,6 +1040,7 @@ find_source_list_for_priority (GMainContext *context,
|
|||||||
* context->source_lists without having to walk the list again.
|
* context->source_lists without having to walk the list again.
|
||||||
*/
|
*/
|
||||||
last = g_list_append (last, source_list);
|
last = g_list_append (last, source_list);
|
||||||
|
(void) last;
|
||||||
}
|
}
|
||||||
return source_list;
|
return source_list;
|
||||||
}
|
}
|
||||||
|
@@ -2917,7 +2917,6 @@ g_markup_collect_attributes (const gchar *element_name,
|
|||||||
failure:
|
failure:
|
||||||
/* replay the above to free allocations */
|
/* replay the above to free allocations */
|
||||||
type = first_type;
|
type = first_type;
|
||||||
attr = first_attr;
|
|
||||||
|
|
||||||
va_start (ap, first_attr);
|
va_start (ap, first_attr);
|
||||||
while (type != G_MARKUP_COLLECT_INVALID)
|
while (type != G_MARKUP_COLLECT_INVALID)
|
||||||
@@ -2952,7 +2951,10 @@ failure:
|
|||||||
|
|
||||||
type = va_arg (ap, GMarkupCollectType);
|
type = va_arg (ap, GMarkupCollectType);
|
||||||
if (type != G_MARKUP_COLLECT_INVALID)
|
if (type != G_MARKUP_COLLECT_INVALID)
|
||||||
attr = va_arg (ap, const char *);
|
{
|
||||||
|
attr = va_arg (ap, const char *);
|
||||||
|
(void) attr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
|
@@ -1313,7 +1313,7 @@ g_logv (const gchar *log_domain,
|
|||||||
{
|
{
|
||||||
GLogLevelFlags test_level;
|
GLogLevelFlags test_level;
|
||||||
|
|
||||||
test_level = 1 << i;
|
test_level = 1L << i;
|
||||||
if (log_level & test_level)
|
if (log_level & test_level)
|
||||||
{
|
{
|
||||||
GLogDomain *domain;
|
GLogDomain *domain;
|
||||||
|
@@ -502,7 +502,7 @@ g_rand_int_range (GRand *rand,
|
|||||||
gint32 end)
|
gint32 end)
|
||||||
{
|
{
|
||||||
guint32 dist = end - begin;
|
guint32 dist = end - begin;
|
||||||
guint32 random;
|
guint32 random = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (rand != NULL, begin);
|
g_return_val_if_fail (rand != NULL, begin);
|
||||||
g_return_val_if_fail (end > begin, begin);
|
g_return_val_if_fail (end > begin, begin);
|
||||||
@@ -563,7 +563,6 @@ g_rand_int_range (GRand *rand,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
random = 0; /* Quiet GCC */
|
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -435,8 +435,6 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
(outpipe >= 0 ||
|
(outpipe >= 0 ||
|
||||||
errpipe >= 0))
|
errpipe >= 0))
|
||||||
{
|
{
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
FD_ZERO (&fds);
|
FD_ZERO (&fds);
|
||||||
if (outpipe >= 0)
|
if (outpipe >= 0)
|
||||||
FD_SET (outpipe, &fds);
|
FD_SET (outpipe, &fds);
|
||||||
|
@@ -3694,6 +3694,9 @@ g_test_trap_assertions (const char *domain,
|
|||||||
g_assertion_message (domain, file, line, func, msg);
|
g_assertion_message (domain, file, line, func, msg);
|
||||||
g_free (msg);
|
g_free (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) logged_child_output; /* shut up scan-build about the final unread assignment */
|
||||||
|
|
||||||
g_free (process_id);
|
g_free (process_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -443,6 +443,7 @@ _g_utf8_normalize_wc (const gchar *str,
|
|||||||
{
|
{
|
||||||
g_unicode_canonical_ordering (wc_buffer + last_start, n_wc - last_start);
|
g_unicode_canonical_ordering (wc_buffer + last_start, n_wc - last_start);
|
||||||
last_start = n_wc;
|
last_start = n_wc;
|
||||||
|
(void) last_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
wc_buffer[n_wc] = 0;
|
wc_buffer[n_wc] = 0;
|
||||||
|
@@ -2527,6 +2527,8 @@ g_variant_new_parsed_va (const gchar *format,
|
|||||||
if (*stream.stream)
|
if (*stream.stream)
|
||||||
g_error ("g_variant_new_parsed: trailing text after value");
|
g_error ("g_variant_new_parsed: trailing text after value");
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(HasNonVoidCleanup, non_void_cleanup)
|
|||||||
static void
|
static void
|
||||||
test_autofree (void)
|
test_autofree (void)
|
||||||
{
|
{
|
||||||
|
#ifdef __clang_analyzer__
|
||||||
|
g_test_skip ("autofree tests aren’t understood by the clang analyser");
|
||||||
|
#else
|
||||||
g_autofree gchar *p = NULL;
|
g_autofree gchar *p = NULL;
|
||||||
g_autofree gchar *p2 = NULL;
|
g_autofree gchar *p2 = NULL;
|
||||||
g_autofree gchar *alwaysnull = NULL;
|
g_autofree gchar *alwaysnull = NULL;
|
||||||
@@ -35,6 +38,7 @@ test_autofree (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_assert_null (alwaysnull);
|
g_assert_null (alwaysnull);
|
||||||
|
#endif /* __clang_analyzer__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -592,6 +596,9 @@ test_autolist (void)
|
|||||||
|
|
||||||
l = g_list_prepend (l, b1);
|
l = g_list_prepend (l, b1);
|
||||||
l = g_list_prepend (l, b3);
|
l = g_list_prepend (l, b3);
|
||||||
|
|
||||||
|
/* Squash warnings about dead stores */
|
||||||
|
(void) l;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only assert if autoptr works */
|
/* Only assert if autoptr works */
|
||||||
|
@@ -175,6 +175,7 @@ test_misc (void)
|
|||||||
&error);
|
&error);
|
||||||
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_INVALID_VALUE);
|
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_INVALID_VALUE);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
g_assert_false (res);
|
||||||
|
|
||||||
g_bookmark_file_set_mime_type (bookmark,
|
g_bookmark_file_set_mime_type (bookmark,
|
||||||
"file:///tmp/schedule1.ps",
|
"file:///tmp/schedule1.ps",
|
||||||
|
@@ -346,8 +346,7 @@ g_boxed_copy (GType boxed_type,
|
|||||||
g_return_val_if_fail (src_boxed != NULL, NULL);
|
g_return_val_if_fail (src_boxed != NULL, NULL);
|
||||||
|
|
||||||
value_table = g_type_value_table_peek (boxed_type);
|
value_table = g_type_value_table_peek (boxed_type);
|
||||||
if (!value_table)
|
g_assert (value_table != NULL);
|
||||||
g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL);
|
|
||||||
|
|
||||||
/* check if our proxying implementation is used, we can short-cut here */
|
/* check if our proxying implementation is used, we can short-cut here */
|
||||||
if (value_table->value_copy == boxed_proxy_value_copy)
|
if (value_table->value_copy == boxed_proxy_value_copy)
|
||||||
@@ -404,8 +403,7 @@ g_boxed_free (GType boxed_type,
|
|||||||
g_return_if_fail (boxed != NULL);
|
g_return_if_fail (boxed != NULL);
|
||||||
|
|
||||||
value_table = g_type_value_table_peek (boxed_type);
|
value_table = g_type_value_table_peek (boxed_type);
|
||||||
if (!value_table)
|
g_assert (value_table != NULL);
|
||||||
g_return_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type));
|
|
||||||
|
|
||||||
/* check if our proxying implementation is used, we can short-cut here */
|
/* check if our proxying implementation is used, we can short-cut here */
|
||||||
if (value_table->value_free == boxed_proxy_value_free)
|
if (value_table->value_free == boxed_proxy_value_free)
|
||||||
|
@@ -25,7 +25,9 @@
|
|||||||
#error "config.h must be included prior to gobject_trace.h"
|
#error "config.h must be included prior to gobject_trace.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DTRACE
|
/* Ignore probes when doing static analysis, as they do weird things which
|
||||||
|
* confuses the analyser. */
|
||||||
|
#if defined(HAVE_DTRACE) && !defined(__clang_analyzer__)
|
||||||
|
|
||||||
/* include the generated probes header and put markers in code */
|
/* include the generated probes header and put markers in code */
|
||||||
#include "gobject_probes.h"
|
#include "gobject_probes.h"
|
||||||
|
@@ -113,6 +113,9 @@ test_autolist (void)
|
|||||||
|
|
||||||
l = g_list_prepend (l, tac1);
|
l = g_list_prepend (l, tac1);
|
||||||
l = g_list_prepend (l, tac2);
|
l = g_list_prepend (l, tac2);
|
||||||
|
|
||||||
|
/* Squash warnings about dead stores */
|
||||||
|
(void) l;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only assert if autoptr works */
|
/* Only assert if autoptr works */
|
||||||
|
Reference in New Issue
Block a user