aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-11-25 07:51:33 +0100
committerMax Kellermann <max@duempel.org>2014-11-25 07:51:33 +0100
commitb19e5720cc47a66cc59e55a81dc08de4e521bc39 (patch)
tree4fb9099872854f29384fcde95152f459a50dcb72
parent951bad46e0638bd13c750fa92260dd9ccf424298 (diff)
downloadmpd-b19e5720cc47a66cc59e55a81dc08de4e521bc39.tar.gz
mpd-b19e5720cc47a66cc59e55a81dc08de4e521bc39.tar.xz
mpd-b19e5720cc47a66cc59e55a81dc08de4e521bc39.zip
test/run_input: make variables more local
-rw-r--r--test/run_input.cxx20
1 files changed, 8 insertions, 12 deletions
diff --git a/test/run_input.cxx b/test/run_input.cxx
index de5bd9632..6864a5d64 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -54,11 +54,6 @@ tag_save(FILE *file, const Tag &tag)
static int
dump_input_stream(InputStream *is)
{
- Error error;
- char buffer[4096];
- size_t num_read;
- ssize_t num_written;
-
is->Lock();
/* print meta data */
@@ -76,7 +71,9 @@ dump_input_stream(InputStream *is)
delete tag;
}
- num_read = is->Read(buffer, sizeof(buffer), error);
+ Error error;
+ char buffer[4096];
+ size_t num_read = is->Read(buffer, sizeof(buffer), error);
if (num_read == 0) {
if (error.IsDefined())
LogError(error);
@@ -84,11 +81,12 @@ dump_input_stream(InputStream *is)
break;
}
- num_written = write(1, buffer, num_read);
+ ssize_t num_written = write(1, buffer, num_read);
if (num_written <= 0)
break;
}
+ Error error;
if (!is->Check(error)) {
LogError(error);
is->Unlock();
@@ -102,10 +100,6 @@ dump_input_stream(InputStream *is)
int main(int argc, char **argv)
{
- Error error;
- InputStream *is;
- int ret;
-
if (argc != 2) {
fprintf(stderr, "Usage: run_input URI\n");
return EXIT_FAILURE;
@@ -129,6 +123,7 @@ int main(int argc, char **argv)
archive_plugin_init_all();
#endif
+ Error error;
if (!input_stream_global_init(error)) {
LogError(error);
return 2;
@@ -139,7 +134,8 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- is = InputStream::OpenReady(argv[1], mutex, cond, error);
+ InputStream *is = InputStream::OpenReady(argv[1], mutex, cond, error);
+ int ret;
if (is != NULL) {
ret = dump_input_stream(is);
delete is;