Merge branch 'scan-build-fixes' into 'main'

Fix various scan-build warnings

See merge request GNOME/glib!2628
This commit is contained in:
Sebastian Dröge 2022-04-28 11:07:34 +00:00
commit 4f48d4e1bb
8 changed files with 12 additions and 12 deletions

View File

@ -1651,14 +1651,12 @@ file_is_hidden (const gchar *path,
if (!g_hash_table_lookup_extended (hidden_cache, dirname,
NULL, (gpointer *) &data))
{
gchar *mydirname;
data = g_new0 (HiddenCacheData, 1);
data->hidden_files = table = read_hidden_file (dirname);
data->timestamp_secs = g_get_monotonic_time () / G_USEC_PER_SEC;
g_hash_table_insert (hidden_cache,
mydirname = g_strdup (dirname),
g_strdup (dirname),
data);
if (!hidden_cache_source)

View File

@ -463,6 +463,8 @@ g_socket_details_from_fd (GSocket *socket)
int value, family;
int errsv;
memset (&address, 0, sizeof (address));
fd = socket->priv->fd;
if (!g_socket_get_option (socket, SOL_SOCKET, SO_TYPE, &value, NULL))
{

View File

@ -143,7 +143,6 @@ ensure_gdbus_testserver_up (GDBusConnection *connection,
g_main_context_iteration (context, TRUE);
g_bus_unwatch_name (watch_id);
watch_id = 0;
while (!data.unwatch_complete)
g_main_context_iteration (context, TRUE);

View File

@ -2279,19 +2279,19 @@ g_date_time_get_day_of_month (GDateTime *datetime)
{
gint day_of_year,
i;
const guint16 *days;
guint is_leap;
guint16 last = 0;
g_return_val_if_fail (datetime != NULL, 0);
days = days_in_year[GREGORIAN_LEAP (g_date_time_get_year (datetime)) ? 1 : 0];
is_leap = GREGORIAN_LEAP (g_date_time_get_year (datetime)) ? 1 : 0;
g_date_time_get_week_number (datetime, NULL, NULL, &day_of_year);
for (i = 1; i <= 12; i++)
{
if (days [i] >= day_of_year)
if (days_in_year[is_leap][i] >= day_of_year)
return day_of_year - last;
last = days [i];
last = days_in_year[is_leap][i];
}
g_warn_if_reached ();

View File

@ -4147,7 +4147,7 @@ g_main_context_iterate (GMainContext *context,
gboolean dispatch,
GThread *self)
{
gint max_priority;
gint max_priority = 0;
gint timeout;
gboolean some_ready;
gint nfds, allocated_nfds;

View File

@ -2238,6 +2238,7 @@ g_log_writer_is_journald (gint output_fd)
/* Namespaced journals start with `/run/systemd/journal.${name}/` (see
* `RuntimeDirectory=systemd/journal.%i` in `systemd-journald@.service`. The
* default journal starts with `/run/systemd/journal/`. */
memset (&addr, 0, sizeof (addr));
addr_len = sizeof(addr);
err = getpeername (output_fd, &addr.sa, &addr_len);
if (err == 0 && addr.storage.ss_family == AF_UNIX)

View File

@ -1856,6 +1856,7 @@ test_read_link (void)
g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"*assertion*!= NULL*");
newpath = g_file_read_link (NULL, &error);
g_assert_null (newpath);
g_test_assert_expected_messages ();
}

View File

@ -140,12 +140,11 @@ test_thread4 (void)
struct rlimit ol, nl;
GThread *thread;
GError *error;
gint ret;
getrlimit (RLIMIT_NPROC, &nl);
nl.rlim_cur = 1;
if ((ret = prlimit (getpid (), RLIMIT_NPROC, &nl, &ol)) != 0)
if (prlimit (getpid (), RLIMIT_NPROC, &nl, &ol) != 0)
g_error ("prlimit failed: %s", g_strerror (errno));
error = NULL;
@ -171,7 +170,7 @@ test_thread4 (void)
g_error_free (error);
}
if ((ret = prlimit (getpid (), RLIMIT_NPROC, &ol, NULL)) != 0)
if (prlimit (getpid (), RLIMIT_NPROC, &ol, NULL) != 0)
g_error ("resetting RLIMIT_NPROC failed: %s", g_strerror (errno));
#endif
}