mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
Avoid setting unused variables (-Wself-assign)
Setting a variable and then assigning it to itself avoids -Wunused-but-set-variable but this specific trick is now caught by -Wself-assign. Instead, actually use the value or don't bother assigning it at all: gdbusauth.c: call g_data_input_stream_read_byte() in void context gdbusauthmechanismsha1.c: value is actually used gdbusmessage.c: use consistent preprocessor-token protection gthreadedresolver.c: skip over bytes in data blob httpd.c: do something useful with the value https://bugzilla.gnome.org/show_bug.cgi?id=745723
This commit is contained in:
parent
5d9ccf162e
commit
190f64a0fb
@ -961,7 +961,6 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
||||
GDataInputStream *dis;
|
||||
GDataOutputStream *dos;
|
||||
GError *local_error;
|
||||
guchar byte;
|
||||
gchar *line;
|
||||
gsize line_length;
|
||||
GDBusAuthMechanism *mech;
|
||||
@ -997,7 +996,7 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
||||
|
||||
g_data_input_stream_set_newline_type (dis, G_DATA_STREAM_NEWLINE_TYPE_CR_LF);
|
||||
|
||||
/* first read the NUL-byte (TODO: read credentials if using a unix domain socket) */
|
||||
/* first read the NUL-byte */
|
||||
#ifdef G_OS_UNIX
|
||||
if (G_IS_UNIX_CONNECTION (auth->priv->stream))
|
||||
{
|
||||
@ -1014,8 +1013,7 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
||||
else
|
||||
{
|
||||
local_error = NULL;
|
||||
byte = g_data_input_stream_read_byte (dis, cancellable, &local_error);
|
||||
byte = byte; /* To avoid -Wunused-but-set-variable */
|
||||
(void)g_data_input_stream_read_byte (dis, cancellable, &local_error);
|
||||
if (local_error != NULL)
|
||||
{
|
||||
g_propagate_error (error, local_error);
|
||||
@ -1024,8 +1022,7 @@ _g_dbus_auth_run_server (GDBusAuth *auth,
|
||||
}
|
||||
#else
|
||||
local_error = NULL;
|
||||
byte = g_data_input_stream_read_byte (dis, cancellable, &local_error);
|
||||
byte = byte; /* To avoid -Wunused-but-set-variable */
|
||||
(void)g_data_input_stream_read_byte (dis, cancellable, &local_error);
|
||||
if (local_error != NULL)
|
||||
{
|
||||
g_propagate_error (error, local_error);
|
||||
|
@ -753,7 +753,6 @@ keyring_generate_entry (const gchar *cookie_context,
|
||||
g_strfreev (tokens);
|
||||
goto out;
|
||||
}
|
||||
line_when = line_when; /* To avoid -Wunused-but-set-variable */
|
||||
|
||||
|
||||
/* D-Bus spec says:
|
||||
|
@ -1440,7 +1440,9 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
{
|
||||
GVariant *ret;
|
||||
GError *local_error;
|
||||
#ifdef DEBUG_SERIALIZER
|
||||
gboolean is_leaf;
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
const gchar *type_string;
|
||||
|
||||
type_string = g_variant_type_peek_string (type);
|
||||
@ -1460,7 +1462,9 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
|
||||
ret = NULL;
|
||||
|
||||
#ifdef DEBUG_SERIALIZER
|
||||
is_leaf = TRUE;
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
local_error = NULL;
|
||||
switch (type_string[0])
|
||||
{
|
||||
@ -1643,8 +1647,8 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
|
||||
array_len = g_memory_buffer_read_uint32 (buf);
|
||||
|
||||
is_leaf = FALSE;
|
||||
#ifdef DEBUG_SERIALIZER
|
||||
is_leaf = FALSE;
|
||||
g_print (": array spans 0x%04x bytes\n", array_len);
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
|
||||
@ -1751,8 +1755,8 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
|
||||
ensure_input_padding (buf, 8);
|
||||
|
||||
is_leaf = FALSE;
|
||||
#ifdef DEBUG_SERIALIZER
|
||||
is_leaf = FALSE;
|
||||
g_print ("\n");
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
|
||||
@ -1786,8 +1790,8 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
{
|
||||
ensure_input_padding (buf, 8);
|
||||
|
||||
is_leaf = FALSE;
|
||||
#ifdef DEBUG_SERIALIZER
|
||||
is_leaf = FALSE;
|
||||
g_print ("\n");
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
|
||||
@ -1821,8 +1825,8 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
}
|
||||
else if (g_variant_type_is_variant (type))
|
||||
{
|
||||
is_leaf = FALSE;
|
||||
#ifdef DEBUG_SERIALIZER
|
||||
is_leaf = FALSE;
|
||||
g_print ("\n");
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
|
||||
@ -1894,8 +1898,6 @@ parse_value_from_blob (GMemoryBuffer *buf,
|
||||
g_free (s);
|
||||
}
|
||||
}
|
||||
#else
|
||||
is_leaf = is_leaf; /* To avoid -Wunused-but-set-variable */
|
||||
#endif /* DEBUG_SERIALIZER */
|
||||
|
||||
/* sink the reference, if floating */
|
||||
|
@ -537,7 +537,6 @@ g_resolver_records_from_res_query (const gchar *rrname,
|
||||
gchar namebuf[1024];
|
||||
guchar *end, *p;
|
||||
guint16 type, qclass, rdlength;
|
||||
guint32 ttl;
|
||||
HEADER *header;
|
||||
GList *records;
|
||||
GVariant *record;
|
||||
@ -587,8 +586,7 @@ g_resolver_records_from_res_query (const gchar *rrname,
|
||||
p += dn_expand (answer, end, p, namebuf, sizeof (namebuf));
|
||||
GETSHORT (type, p);
|
||||
GETSHORT (qclass, p);
|
||||
GETLONG (ttl, p);
|
||||
ttl = ttl; /* To avoid -Wunused-but-set-variable */
|
||||
p += 4; /* ignore the ttl (type=long) value */
|
||||
GETSHORT (rdlength, p);
|
||||
|
||||
if (type != rrtype || qclass != C_IN)
|
||||
|
@ -67,12 +67,19 @@ handler (GThreadedSocketService *service,
|
||||
|
||||
version = NULL;
|
||||
tmp = strchr (escaped, ' ');
|
||||
if (tmp != NULL)
|
||||
if (tmp == NULL)
|
||||
{
|
||||
*tmp = 0;
|
||||
version = tmp + 1;
|
||||
send_error (out, 400, "Bad Request");
|
||||
goto out;
|
||||
}
|
||||
*tmp = 0;
|
||||
|
||||
version = tmp + 1;
|
||||
if (!g_str_has_prefix (version, "HTTP/1."))
|
||||
{
|
||||
send_error(out, 505, "HTTP Version Not Supported");
|
||||
goto out;
|
||||
}
|
||||
version = version; /* To avoid -Wunused-but-set-variable */
|
||||
|
||||
query = strchr (escaped, '?');
|
||||
if (query != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user