Fix a lot of clang complaints

Mostly dead assignments.
This commit is contained in:
Matthias Clasen 2009-09-09 00:18:23 -04:00
parent 04d632ccf5
commit 53fc10d269
13 changed files with 35 additions and 84 deletions

View File

@ -474,12 +474,10 @@ g_buffered_output_stream_flush (GOutputStream *stream,
GError **error) GError **error)
{ {
GBufferedOutputStream *bstream; GBufferedOutputStream *bstream;
GBufferedOutputStreamPrivate *priv;
GOutputStream *base_stream; GOutputStream *base_stream;
gboolean res; gboolean res;
bstream = G_BUFFERED_OUTPUT_STREAM (stream); bstream = G_BUFFERED_OUTPUT_STREAM (stream);
priv = bstream->priv;
base_stream = G_FILTER_OUTPUT_STREAM (stream)->base_stream; base_stream = G_FILTER_OUTPUT_STREAM (stream)->base_stream;
res = flush_buffer (bstream, cancellable, error); res = flush_buffer (bstream, cancellable, error);
@ -498,23 +496,20 @@ g_buffered_output_stream_close (GOutputStream *stream,
GError **error) GError **error)
{ {
GBufferedOutputStream *bstream; GBufferedOutputStream *bstream;
GBufferedOutputStreamPrivate *priv;
GOutputStream *base_stream; GOutputStream *base_stream;
gboolean res; gboolean res;
bstream = G_BUFFERED_OUTPUT_STREAM (stream); bstream = G_BUFFERED_OUTPUT_STREAM (stream);
priv = bstream->priv;
base_stream = G_FILTER_OUTPUT_STREAM (bstream)->base_stream; base_stream = G_FILTER_OUTPUT_STREAM (bstream)->base_stream;
res = flush_buffer (bstream, cancellable, error); res = flush_buffer (bstream, cancellable, error);
if (g_filter_output_stream_get_close_base_stream (G_FILTER_OUTPUT_STREAM (stream))) if (g_filter_output_stream_get_close_base_stream (G_FILTER_OUTPUT_STREAM (stream)))
{ {
/* report the first error but still close the stream */ /* report the first error but still close the stream */
if (res) if (res)
res = g_output_stream_close (base_stream, cancellable, error); res = g_output_stream_close (base_stream, cancellable, error);
else else
g_output_stream_close (base_stream, cancellable, NULL); g_output_stream_close (base_stream, cancellable, NULL);
} }
return res; return res;

View File

@ -815,21 +815,16 @@ scan_for_chars (GDataInputStream *stream,
const char *stop_chars) const char *stop_chars)
{ {
GBufferedInputStream *bstream; GBufferedInputStream *bstream;
GDataInputStreamPrivate *priv;
const char *buffer; const char *buffer;
gsize start, end, peeked; gsize start, end, peeked;
int i; int i;
gssize found_pos;
gsize available, checked; gsize available, checked;
const char *stop_char; const char *stop_char;
priv = stream->priv;
bstream = G_BUFFERED_INPUT_STREAM (stream); bstream = G_BUFFERED_INPUT_STREAM (stream);
checked = *checked_out; checked = *checked_out;
found_pos = -1;
start = checked; start = checked;
buffer = (const char *)g_buffered_input_stream_peek_buffer (bstream, &available) + start; buffer = (const char *)g_buffered_input_stream_peek_buffer (bstream, &available) + start;
end = available; end = available;

View File

@ -690,16 +690,13 @@ is_valid (char c, const char *reserved_chars_allowed)
} }
static void static void
g_string_append_encoded (GString *string, g_string_append_encoded (GString *string,
const char *encoded, const char *encoded,
const char *reserved_chars_allowed) const char *reserved_chars_allowed)
{ {
unsigned char c; unsigned char c;
const char *end;
static const gchar hex[16] = "0123456789ABCDEF"; static const gchar hex[16] = "0123456789ABCDEF";
end = encoded + strlen (encoded);
while ((c = *encoded) != 0) while ((c = *encoded) != 0)
{ {
if (is_valid (c, reserved_chars_allowed)) if (is_valid (c, reserved_chars_allowed))

View File

@ -91,10 +91,6 @@ static gboolean g_input_stream_real_close_finish (GInputStream *stream,
static void static void
g_input_stream_finalize (GObject *object) g_input_stream_finalize (GObject *object)
{ {
GInputStream *stream;
stream = G_INPUT_STREAM (object);
G_OBJECT_CLASS (g_input_stream_parent_class)->finalize (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]; char buffer[8192];
GError *my_error; GError *my_error;
class = G_INPUT_STREAM_GET_CLASS (stream);
if (G_IS_SEEKABLE (stream) && g_seekable_can_seek (G_SEEKABLE (stream))) if (G_IS_SEEKABLE (stream) && g_seekable_can_seek (G_SEEKABLE (stream)))
{ {
if (g_seekable_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: */ /* If not seekable, or seek failed, fall back to reading data: */
class = G_INPUT_STREAM_GET_CLASS (stream); class = G_INPUT_STREAM_GET_CLASS (stream);
read_bytes = 0; read_bytes = 0;
while (1) while (1)
{ {
my_error = NULL; my_error = NULL;
ret = class->read_fn (stream, buffer, MIN (sizeof (buffer), count), ret = class->read_fn (stream, buffer, MIN (sizeof (buffer), count),
cancellable, &my_error); cancellable, &my_error);
if (ret == -1) if (ret == -1)
{ {
if (read_bytes > 0 && if (read_bytes > 0 &&
@ -384,16 +378,16 @@ g_input_stream_real_skip (GInputStream *stream,
g_error_free (my_error); g_error_free (my_error);
return read_bytes; return read_bytes;
} }
g_propagate_error (error, my_error); g_propagate_error (error, my_error);
return -1; return -1;
} }
count -= ret; count -= ret;
read_bytes += ret; read_bytes += ret;
if (ret == 0 || count == 0) if (ret == 0 || count == 0)
return read_bytes; return read_bytes;
} }
} }

View File

@ -97,10 +97,6 @@ static gboolean g_io_stream_real_close_finish (GIOStream *stream,
static void static void
g_io_stream_finalize (GObject *object) g_io_stream_finalize (GObject *object)
{ {
GIOStream *stream;
stream = G_IO_STREAM (object);
G_OBJECT_CLASS (g_io_stream_parent_class)->finalize (object); G_OBJECT_CLASS (g_io_stream_parent_class)->finalize (object);
} }

View File

@ -1721,12 +1721,11 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
char uid_str[32]; char uid_str[32];
struct stat global_stat, trash_stat; struct stat global_stat, trash_stat;
gboolean res; gboolean res;
int statres;
if (g_once_init_enter (&home_dev_set)) if (g_once_init_enter (&home_dev_set))
{ {
struct stat home_stat; struct stat home_stat;
g_stat (g_get_home_dir (), &home_stat); g_stat (g_get_home_dir (), &home_stat);
home_dev = home_stat.st_dev; home_dev = home_stat.st_dev;
g_once_init_leave (&home_dev_set, 1); 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) if (topdir == NULL)
return FALSE; return FALSE;
globaldir = g_build_filename (topdir, ".Trash", NULL); globaldir = g_build_filename (topdir, ".Trash", NULL);
statres = g_lstat (globaldir, &global_stat); if (g_lstat (globaldir, &global_stat) == 0 &&
if (g_lstat (globaldir, &global_stat) == 0 &&
S_ISDIR (global_stat.st_mode) && S_ISDIR (global_stat.st_mode) &&
(global_stat.st_mode & S_ISVTX) != 0) (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 */ /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
uid = geteuid (); uid = geteuid ();
g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid); g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid);
tmpname = g_strdup_printf (".Trash-%s", uid_str); tmpname = g_strdup_printf (".Trash-%s", uid_str);
trashdir = g_build_filename (topdir, tmpname, NULL); trashdir = g_build_filename (topdir, tmpname, NULL);
g_free (tmpname); 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 (topdir);
g_free (trashdir); g_free (trashdir);
return return S_ISDIR (trash_stat.st_mode) &&
S_ISDIR (trash_stat.st_mode) && trash_stat.st_uid == uid;
trash_stat.st_uid == uid;
} }
g_free (trashdir); g_free (trashdir);
/* User specific trash didn't exist, can we create it? */ /* User specific trash didn't exist, can we create it? */
res = g_access (topdir, W_OK) == 0; res = g_access (topdir, W_OK) == 0;
g_free (topdir); g_free (topdir);
return res; return res;
} }

View File

@ -79,10 +79,6 @@ static GFileInfo *g_local_file_input_stream_query_info (GFileInputStream *strea
static void static void
g_local_file_input_stream_finalize (GObject *object) 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); G_OBJECT_CLASS (g_local_file_input_stream_parent_class)->finalize (object);
} }

View File

@ -99,10 +99,6 @@ static gboolean g_output_stream_real_close_finish (GOutputStream *s
static void static void
g_output_stream_finalize (GObject *object) g_output_stream_finalize (GObject *object)
{ {
GOutputStream *stream;
stream = G_OUTPUT_STREAM (object);
G_OBJECT_CLASS (g_output_stream_parent_class)->finalize (object); G_OBJECT_CLASS (g_output_stream_parent_class)->finalize (object);
} }
@ -344,13 +340,14 @@ g_output_stream_flush (GOutputStream *stream,
* @stream: a #GOutputStream. * @stream: a #GOutputStream.
* @source: a #GInputStream. * @source: a #GInputStream.
* @flags: a set of #GOutputStreamSpliceFlags. * @flags: a set of #GOutputStreamSpliceFlags.
* @cancellable: optional #GCancellable object, %NULL to ignore. * @cancellable: optional #GCancellable object, %NULL to ignore.
* @error: a #GError location to store the error occuring, or %NULL to * @error: a #GError location to store the error occuring, or %NULL to
* ignore. * ignore.
* *
* Splices an input stream into an output stream. * 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 gssize
g_output_stream_splice (GOutputStream *stream, g_output_stream_splice (GOutputStream *stream,
@ -360,7 +357,7 @@ g_output_stream_splice (GOutputStream *stream,
GError **error) GError **error)
{ {
GOutputStreamClass *class; 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_OUTPUT_STREAM (stream), -1);
g_return_val_if_fail (G_IS_INPUT_STREAM (source), -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)) if (!g_output_stream_set_pending (stream, error))
return -1; return -1;
class = G_OUTPUT_STREAM_GET_CLASS (stream); class = G_OUTPUT_STREAM_GET_CLASS (stream);
res = TRUE;
if (cancellable) if (cancellable)
g_cancellable_push_current (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) if (cancellable)
g_cancellable_pop_current (cancellable); g_cancellable_pop_current (cancellable);
g_output_stream_clear_pending (stream); g_output_stream_clear_pending (stream);
return res; return bytes_copied;
} }
static gssize static gssize
@ -405,16 +401,16 @@ g_output_stream_real_splice (GOutputStream *stream,
gboolean res; gboolean res;
bytes_copied = 0; 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, g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Output stream doesn't implement write")); _("Output stream doesn't implement write"));
res = FALSE; res = FALSE;
goto notsupported; goto notsupported;
} }
res = TRUE; res = TRUE;
do do
{ {
n_read = g_input_stream_read (source, buffer, sizeof (buffer), cancellable, error); n_read = g_input_stream_read (source, buffer, sizeof (buffer), cancellable, error);
if (n_read == -1) if (n_read == -1)
@ -422,7 +418,7 @@ g_output_stream_real_splice (GOutputStream *stream,
res = FALSE; res = FALSE;
break; break;
} }
if (n_read == 0) if (n_read == 0)
break; break;

View File

@ -116,10 +116,6 @@ static gboolean g_unix_input_stream_close_finish (GInputStream *stream,
static void static void
g_unix_input_stream_finalize (GObject *object) 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); G_OBJECT_CLASS (g_unix_input_stream_parent_class)->finalize (object);
} }

View File

@ -108,10 +108,6 @@ static gboolean g_unix_output_stream_close_finish (GOutputStream *stream,
static void static void
g_unix_output_stream_finalize (GObject *object) 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); G_OBJECT_CLASS (g_unix_output_stream_parent_class)->finalize (object);
} }

View File

@ -1418,8 +1418,7 @@ g_build_path_va (const gchar *separator,
if (separator_len) if (separator_len)
{ {
while (start && while (strncmp (start, separator, separator_len) == 0)
strncmp (start, separator, separator_len) == 0)
start += separator_len; start += separator_len;
} }

View File

@ -413,7 +413,6 @@ g_key_file_load_from_fd (GKeyFile *key_file,
} }
key_file->flags = flags; key_file->flags = flags;
bytes_read = 0;
do do
{ {
bytes_read = read (fd, read_buf, 4096); bytes_read = read (fd, read_buf, 4096);
@ -432,7 +431,7 @@ g_key_file_load_from_fd (GKeyFile *key_file,
return FALSE; return FALSE;
} }
g_key_file_parse_data (key_file, g_key_file_parse_data (key_file,
read_buf, bytes_read, read_buf, bytes_read,
&key_file_error); &key_file_error);
} }

View File

@ -498,7 +498,6 @@ gboolean
g_match_info_next (GMatchInfo *match_info, g_match_info_next (GMatchInfo *match_info,
GError **error) GError **error)
{ {
gint opts;
gint prev_match_start; gint prev_match_start;
gint prev_match_end; 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 (error == NULL || *error == NULL, FALSE);
g_return_val_if_fail (match_info->pos >= 0, 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_start = match_info->offsets[0];
prev_match_end = match_info->offsets[1]; prev_match_end = match_info->offsets[1];
@ -516,8 +513,7 @@ g_match_info_next (GMatchInfo *match_info,
match_info->string, match_info->string,
match_info->string_len, match_info->string_len,
match_info->pos, match_info->pos,
match_info->regex->match_opts | match_info->regex->match_opts | match_info->match_opts,
match_info->match_opts,
match_info->offsets, match_info->offsets,
match_info->n_offsets); match_info->n_offsets);
if (IS_PCRE_ERROR (match_info->matches)) if (IS_PCRE_ERROR (match_info->matches))