mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
Fix a lot of clang complaints
Mostly dead assignments.
This commit is contained in:
parent
04d632ccf5
commit
53fc10d269
@ -474,12 +474,10 @@ g_buffered_output_stream_flush (GOutputStream *stream,
|
||||
GError **error)
|
||||
{
|
||||
GBufferedOutputStream *bstream;
|
||||
GBufferedOutputStreamPrivate *priv;
|
||||
GOutputStream *base_stream;
|
||||
gboolean res;
|
||||
|
||||
bstream = G_BUFFERED_OUTPUT_STREAM (stream);
|
||||
priv = bstream->priv;
|
||||
base_stream = G_FILTER_OUTPUT_STREAM (stream)->base_stream;
|
||||
|
||||
res = flush_buffer (bstream, cancellable, error);
|
||||
@ -498,23 +496,20 @@ g_buffered_output_stream_close (GOutputStream *stream,
|
||||
GError **error)
|
||||
{
|
||||
GBufferedOutputStream *bstream;
|
||||
GBufferedOutputStreamPrivate *priv;
|
||||
GOutputStream *base_stream;
|
||||
gboolean res;
|
||||
|
||||
bstream = G_BUFFERED_OUTPUT_STREAM (stream);
|
||||
priv = bstream->priv;
|
||||
base_stream = G_FILTER_OUTPUT_STREAM (bstream)->base_stream;
|
||||
|
||||
res = flush_buffer (bstream, cancellable, error);
|
||||
|
||||
if (g_filter_output_stream_get_close_base_stream (G_FILTER_OUTPUT_STREAM (stream)))
|
||||
{
|
||||
/* report the first error but still close the stream */
|
||||
if (res)
|
||||
res = g_output_stream_close (base_stream, cancellable, error);
|
||||
res = g_output_stream_close (base_stream, cancellable, error);
|
||||
else
|
||||
g_output_stream_close (base_stream, cancellable, NULL);
|
||||
g_output_stream_close (base_stream, cancellable, NULL);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -815,21 +815,16 @@ scan_for_chars (GDataInputStream *stream,
|
||||
const char *stop_chars)
|
||||
{
|
||||
GBufferedInputStream *bstream;
|
||||
GDataInputStreamPrivate *priv;
|
||||
const char *buffer;
|
||||
gsize start, end, peeked;
|
||||
int i;
|
||||
gssize found_pos;
|
||||
gsize available, checked;
|
||||
const char *stop_char;
|
||||
|
||||
priv = stream->priv;
|
||||
|
||||
bstream = G_BUFFERED_INPUT_STREAM (stream);
|
||||
|
||||
checked = *checked_out;
|
||||
found_pos = -1;
|
||||
|
||||
|
||||
start = checked;
|
||||
buffer = (const char *)g_buffered_input_stream_peek_buffer (bstream, &available) + start;
|
||||
end = available;
|
||||
|
@ -690,16 +690,13 @@ is_valid (char c, const char *reserved_chars_allowed)
|
||||
}
|
||||
|
||||
static void
|
||||
g_string_append_encoded (GString *string,
|
||||
g_string_append_encoded (GString *string,
|
||||
const char *encoded,
|
||||
const char *reserved_chars_allowed)
|
||||
{
|
||||
unsigned char c;
|
||||
const char *end;
|
||||
static const gchar hex[16] = "0123456789ABCDEF";
|
||||
|
||||
end = encoded + strlen (encoded);
|
||||
|
||||
while ((c = *encoded) != 0)
|
||||
{
|
||||
if (is_valid (c, reserved_chars_allowed))
|
||||
|
@ -91,10 +91,6 @@ static gboolean g_input_stream_real_close_finish (GInputStream *stream,
|
||||
static void
|
||||
g_input_stream_finalize (GObject *object)
|
||||
{
|
||||
GInputStream *stream;
|
||||
|
||||
stream = G_INPUT_STREAM (object);
|
||||
|
||||
G_OBJECT_CLASS (g_input_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -352,8 +348,6 @@ g_input_stream_real_skip (GInputStream *stream,
|
||||
char buffer[8192];
|
||||
GError *my_error;
|
||||
|
||||
class = G_INPUT_STREAM_GET_CLASS (stream);
|
||||
|
||||
if (G_IS_SEEKABLE (stream) && g_seekable_can_seek (G_SEEKABLE (stream)))
|
||||
{
|
||||
if (g_seekable_seek (G_SEEKABLE (stream),
|
||||
@ -367,14 +361,14 @@ g_input_stream_real_skip (GInputStream *stream,
|
||||
/* If not seekable, or seek failed, fall back to reading data: */
|
||||
|
||||
class = G_INPUT_STREAM_GET_CLASS (stream);
|
||||
|
||||
|
||||
read_bytes = 0;
|
||||
while (1)
|
||||
{
|
||||
my_error = NULL;
|
||||
|
||||
ret = class->read_fn (stream, buffer, MIN (sizeof (buffer), count),
|
||||
cancellable, &my_error);
|
||||
cancellable, &my_error);
|
||||
if (ret == -1)
|
||||
{
|
||||
if (read_bytes > 0 &&
|
||||
@ -384,16 +378,16 @@ g_input_stream_real_skip (GInputStream *stream,
|
||||
g_error_free (my_error);
|
||||
return read_bytes;
|
||||
}
|
||||
|
||||
|
||||
g_propagate_error (error, my_error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
count -= ret;
|
||||
read_bytes += ret;
|
||||
|
||||
|
||||
if (ret == 0 || count == 0)
|
||||
return read_bytes;
|
||||
return read_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,10 +97,6 @@ static gboolean g_io_stream_real_close_finish (GIOStream *stream,
|
||||
static void
|
||||
g_io_stream_finalize (GObject *object)
|
||||
{
|
||||
GIOStream *stream;
|
||||
|
||||
stream = G_IO_STREAM (object);
|
||||
|
||||
G_OBJECT_CLASS (g_io_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -1721,12 +1721,11 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
|
||||
char uid_str[32];
|
||||
struct stat global_stat, trash_stat;
|
||||
gboolean res;
|
||||
int statres;
|
||||
|
||||
|
||||
if (g_once_init_enter (&home_dev_set))
|
||||
{
|
||||
struct stat home_stat;
|
||||
|
||||
|
||||
g_stat (g_get_home_dir (), &home_stat);
|
||||
home_dev = home_stat.st_dev;
|
||||
g_once_init_leave (&home_dev_set, 1);
|
||||
@ -1740,9 +1739,8 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
|
||||
if (topdir == NULL)
|
||||
return FALSE;
|
||||
|
||||
globaldir = g_build_filename (topdir, ".Trash", NULL);
|
||||
statres = g_lstat (globaldir, &global_stat);
|
||||
if (g_lstat (globaldir, &global_stat) == 0 &&
|
||||
globaldir = g_build_filename (topdir, ".Trash", NULL);
|
||||
if (g_lstat (globaldir, &global_stat) == 0 &&
|
||||
S_ISDIR (global_stat.st_mode) &&
|
||||
(global_stat.st_mode & S_ISVTX) != 0)
|
||||
{
|
||||
@ -1760,7 +1758,7 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
|
||||
/* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
|
||||
uid = geteuid ();
|
||||
g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid);
|
||||
|
||||
|
||||
tmpname = g_strdup_printf (".Trash-%s", uid_str);
|
||||
trashdir = g_build_filename (topdir, tmpname, NULL);
|
||||
g_free (tmpname);
|
||||
@ -1769,17 +1767,15 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
|
||||
{
|
||||
g_free (topdir);
|
||||
g_free (trashdir);
|
||||
return
|
||||
S_ISDIR (trash_stat.st_mode) &&
|
||||
trash_stat.st_uid == uid;
|
||||
return S_ISDIR (trash_stat.st_mode) &&
|
||||
trash_stat.st_uid == uid;
|
||||
}
|
||||
g_free (trashdir);
|
||||
|
||||
/* User specific trash didn't exist, can we create it? */
|
||||
res = g_access (topdir, W_OK) == 0;
|
||||
|
||||
g_free (topdir);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,6 @@ static GFileInfo *g_local_file_input_stream_query_info (GFileInputStream *strea
|
||||
static void
|
||||
g_local_file_input_stream_finalize (GObject *object)
|
||||
{
|
||||
GLocalFileInputStream *file;
|
||||
|
||||
file = G_LOCAL_FILE_INPUT_STREAM (object);
|
||||
|
||||
G_OBJECT_CLASS (g_local_file_input_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,6 @@ static gboolean g_output_stream_real_close_finish (GOutputStream *s
|
||||
static void
|
||||
g_output_stream_finalize (GObject *object)
|
||||
{
|
||||
GOutputStream *stream;
|
||||
|
||||
stream = G_OUTPUT_STREAM (object);
|
||||
|
||||
G_OBJECT_CLASS (g_output_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@ -344,13 +340,14 @@ g_output_stream_flush (GOutputStream *stream,
|
||||
* @stream: a #GOutputStream.
|
||||
* @source: a #GInputStream.
|
||||
* @flags: a set of #GOutputStreamSpliceFlags.
|
||||
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
||||
* @error: a #GError location to store the error occuring, or %NULL to
|
||||
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
||||
* @error: a #GError location to store the error occuring, or %NULL to
|
||||
* ignore.
|
||||
*
|
||||
* Splices an input stream into an output stream.
|
||||
*
|
||||
* Returns: a #gssize containing the size of the data spliced.
|
||||
* Returns: a #gssize containing the size of the data spliced, or
|
||||
* -1 if an error occurred.
|
||||
**/
|
||||
gssize
|
||||
g_output_stream_splice (GOutputStream *stream,
|
||||
@ -360,7 +357,7 @@ g_output_stream_splice (GOutputStream *stream,
|
||||
GError **error)
|
||||
{
|
||||
GOutputStreamClass *class;
|
||||
gboolean res;
|
||||
gssize bytes_copied;
|
||||
|
||||
g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), -1);
|
||||
g_return_val_if_fail (G_IS_INPUT_STREAM (source), -1);
|
||||
@ -374,21 +371,20 @@ g_output_stream_splice (GOutputStream *stream,
|
||||
|
||||
if (!g_output_stream_set_pending (stream, error))
|
||||
return -1;
|
||||
|
||||
|
||||
class = G_OUTPUT_STREAM_GET_CLASS (stream);
|
||||
|
||||
res = TRUE;
|
||||
if (cancellable)
|
||||
g_cancellable_push_current (cancellable);
|
||||
|
||||
res = class->splice (stream, source, flags, cancellable, error);
|
||||
|
||||
|
||||
bytes_copied = class->splice (stream, source, flags, cancellable, error);
|
||||
|
||||
if (cancellable)
|
||||
g_cancellable_pop_current (cancellable);
|
||||
|
||||
|
||||
g_output_stream_clear_pending (stream);
|
||||
|
||||
return res;
|
||||
return bytes_copied;
|
||||
}
|
||||
|
||||
static gssize
|
||||
@ -405,16 +401,16 @@ g_output_stream_real_splice (GOutputStream *stream,
|
||||
gboolean res;
|
||||
|
||||
bytes_copied = 0;
|
||||
if (class->write_fn == NULL)
|
||||
if (class->write_fn == NULL)
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Output stream doesn't implement write"));
|
||||
res = FALSE;
|
||||
goto notsupported;
|
||||
}
|
||||
|
||||
|
||||
res = TRUE;
|
||||
do
|
||||
do
|
||||
{
|
||||
n_read = g_input_stream_read (source, buffer, sizeof (buffer), cancellable, error);
|
||||
if (n_read == -1)
|
||||
@ -422,7 +418,7 @@ g_output_stream_real_splice (GOutputStream *stream,
|
||||
res = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (n_read == 0)
|
||||
break;
|
||||
|
||||
|
@ -116,10 +116,6 @@ static gboolean g_unix_input_stream_close_finish (GInputStream *stream,
|
||||
static void
|
||||
g_unix_input_stream_finalize (GObject *object)
|
||||
{
|
||||
GUnixInputStream *stream;
|
||||
|
||||
stream = G_UNIX_INPUT_STREAM (object);
|
||||
|
||||
G_OBJECT_CLASS (g_unix_input_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -108,10 +108,6 @@ static gboolean g_unix_output_stream_close_finish (GOutputStream *stream,
|
||||
static void
|
||||
g_unix_output_stream_finalize (GObject *object)
|
||||
{
|
||||
GUnixOutputStream *stream;
|
||||
|
||||
stream = G_UNIX_OUTPUT_STREAM (object);
|
||||
|
||||
G_OBJECT_CLASS (g_unix_output_stream_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
@ -1418,8 +1418,7 @@ g_build_path_va (const gchar *separator,
|
||||
|
||||
if (separator_len)
|
||||
{
|
||||
while (start &&
|
||||
strncmp (start, separator, separator_len) == 0)
|
||||
while (strncmp (start, separator, separator_len) == 0)
|
||||
start += separator_len;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,6 @@ g_key_file_load_from_fd (GKeyFile *key_file,
|
||||
}
|
||||
key_file->flags = flags;
|
||||
|
||||
bytes_read = 0;
|
||||
do
|
||||
{
|
||||
bytes_read = read (fd, read_buf, 4096);
|
||||
@ -432,7 +431,7 @@ g_key_file_load_from_fd (GKeyFile *key_file,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_key_file_parse_data (key_file,
|
||||
g_key_file_parse_data (key_file,
|
||||
read_buf, bytes_read,
|
||||
&key_file_error);
|
||||
}
|
||||
|
@ -498,7 +498,6 @@ gboolean
|
||||
g_match_info_next (GMatchInfo *match_info,
|
||||
GError **error)
|
||||
{
|
||||
gint opts;
|
||||
gint prev_match_start;
|
||||
gint prev_match_end;
|
||||
|
||||
@ -506,8 +505,6 @@ g_match_info_next (GMatchInfo *match_info,
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (match_info->pos >= 0, FALSE);
|
||||
|
||||
opts = match_info->regex->match_opts | match_info->match_opts;
|
||||
|
||||
prev_match_start = match_info->offsets[0];
|
||||
prev_match_end = match_info->offsets[1];
|
||||
|
||||
@ -516,8 +513,7 @@ g_match_info_next (GMatchInfo *match_info,
|
||||
match_info->string,
|
||||
match_info->string_len,
|
||||
match_info->pos,
|
||||
match_info->regex->match_opts |
|
||||
match_info->match_opts,
|
||||
match_info->regex->match_opts | match_info->match_opts,
|
||||
match_info->offsets,
|
||||
match_info->n_offsets);
|
||||
if (IS_PCRE_ERROR (match_info->matches))
|
||||
|
Loading…
Reference in New Issue
Block a user