Discussion:
[PATCH] fix gcc-4.6 warnings
Johannes Weißl
2011-02-07 13:06:47 UTC
Permalink
e.g. warning: variable 'rc' set but not used [-Wunused-but-set-variable]
---
aac.c | 3 +--
alsa.c | 38 +++++++++++++++++---------------------
window.c | 3 ---
3 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/aac.c b/aac.c
index 5e4f43c..ec723b8 100644
--- a/aac.c
+++ b/aac.c
@@ -386,7 +386,6 @@ static int aac_duration(struct input_plugin_data *ip_data)
NeAACDecFrameInfo frame_info;
int samples = 0, bytes = 0, frames = 0;
off_t file_size;
- char *sample_buf;

file_size = lseek(ip_data->fd, 0, SEEK_END);
if (file_size == -1)
@@ -397,7 +396,7 @@ static int aac_duration(struct input_plugin_data *ip_data)
if (buffer_fill_frame(ip_data) <= 0)
break;

- sample_buf = NeAACDecDecode(priv->decoder, &frame_info,
+ NeAACDecDecode(priv->decoder, &frame_info,
buffer_data(ip_data), buffer_length(ip_data));
if (frame_info.error == 0 && frame_info.samples > 0) {
samples += frame_info.samples;
diff --git a/alsa.c b/alsa.c
index 3ec4651..a803196 100644
--- a/alsa.c
+++ b/alsa.c
@@ -81,6 +81,8 @@ static char *alsa_dsp_device = NULL;

static int alsa_error_to_op_error(int err)
{
+ if (!err)
+ return OP_ERROR_SUCCESS;
err = -err;
if (err < SND_ERROR_BEGIN) {
errno = err;
@@ -109,7 +111,7 @@ static int op_alsa_init(void)
errno = ENOMEM;
return -OP_ERROR_ERRNO;
}
- return 0;
+ return OP_ERROR_SUCCESS;
}

static int op_alsa_exit(void)
@@ -117,7 +119,7 @@ static int op_alsa_exit(void)
snd_pcm_status_free(status);
free(alsa_dsp_device);
alsa_dsp_device = NULL;
- return 0;
+ return OP_ERROR_SUCCESS;
}

/* randomize hw params */
@@ -193,7 +195,7 @@ static int op_alsa_open(sample_format_t sf)
rc = snd_pcm_prepare(alsa_handle);
if (rc < 0)
goto close_error;
- return 0;
+ return OP_ERROR_SUCCESS;
close_error:
snd_pcm_close(alsa_handle);
error:
@@ -211,7 +213,7 @@ static int op_alsa_close(void)

rc = snd_pcm_close(alsa_handle);
debug_ret("snd_pcm_close", rc);
- return 0;
+ return alsa_error_to_op_error(rc);
}

static int op_alsa_drop(void)
@@ -229,7 +231,7 @@ static int op_alsa_drop(void)
*
* so if old state was PAUSED we can't UNPAUSE (see op_alsa_unpause)
*/
- return 0;
+ return alsa_error_to_op_error(rc);
}

static int op_alsa_write(const char *buffer, int count)
@@ -283,11 +285,9 @@ static int op_alsa_buffer_space(void)

static int op_alsa_pause(void)
{
+ int rc = 0;
if (alsa_can_pause) {
- snd_pcm_state_t state;
- int rc;
-
- state = snd_pcm_state(alsa_handle);
+ snd_pcm_state_t state = snd_pcm_state(alsa_handle);
if (state == SND_PCM_STATE_PREPARED) {
// state is PREPARED -> no need to pause
} else if (state == SND_PCM_STATE_RUNNING) {
@@ -301,23 +301,20 @@ static int op_alsa_pause(void)
debug_ret("snd_pcm_pause", rc);
} else {
d_print("error: state is not RUNNING or PREPARED\n");
+ rc = -OP_ERROR_INTERNAL;
}
} else {
- int rc;
-
rc = snd_pcm_drop(alsa_handle);
debug_ret("snd_pcm_drop", rc);
}
- return 0;
+ return alsa_error_to_op_error(rc);
}

static int op_alsa_unpause(void)
{
+ int rc = 0;
if (alsa_can_pause) {
- snd_pcm_state_t state;
- int rc;
-
- state = snd_pcm_state(alsa_handle);
+ snd_pcm_state_t state = snd_pcm_state(alsa_handle);
if (state == SND_PCM_STATE_PREPARED) {
// state is PREPARED -> no need to unpause
} else if (state == SND_PCM_STATE_PAUSED) {
@@ -331,14 +328,13 @@ static int op_alsa_unpause(void)
debug_ret("snd_pcm_pause", rc);
} else {
d_print("error: state is not PAUSED nor PREPARED\n");
+ rc = -OP_ERROR_INTERNAL;
}
} else {
- int rc;
-
rc = snd_pcm_prepare(alsa_handle);
debug_ret("snd_pcm_prepare", rc);
}
- return 0;
+ return alsa_error_to_op_error(rc);
}

static int op_alsa_set_option(int key, const char *val)
@@ -351,7 +347,7 @@ static int op_alsa_set_option(int key, const char *val)
default:
return -OP_ERROR_NOT_OPTION;
}
- return 0;
+ return OP_ERROR_SUCCESS;
}

static int op_alsa_get_option(int key, char **val)
@@ -364,7 +360,7 @@ static int op_alsa_get_option(int key, char **val)
default:
return -OP_ERROR_NOT_OPTION;
}
- return 0;
+ return OP_ERROR_SUCCESS;
}

const struct output_plugin_ops op_pcm_ops = {
diff --git a/window.c b/window.c
index d40de85..bb179ad 100644
--- a/window.c
+++ b/window.c
@@ -75,12 +75,9 @@ void window_set_contents(struct window *win, void *head)

void window_set_nr_rows(struct window *win, int nr_rows)
{
- struct iter old_sel;
-
if (nr_rows < 1)
return;
win->nr_rows = nr_rows;
- old_sel = win->sel;
window_changed(win);
win->changed = 1;
}
--
1.7.2.3
Gregory Petrosyan
2011-02-10 15:51:34 UTC
Permalink
Post by Johannes Weißl
e.g. warning: variable 'rc' set but not used [-Wunused-but-set-variable]
Merged to master, thanks!

                Gregory

Loading...