aboutsummaryrefslogtreecommitdiffstats
path: root/android/async-console.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-03-17 14:57:51 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-04-11 18:08:11 +0200
commitf9e333ade2529f257ced6bcff8e5824cb07eacf9 (patch)
treec3ea65717a284ae744764b4ecf8c5b745ea3415d /android/async-console.c
parent2086c639648ccecc9081705a279249ce939d818b (diff)
downloadexternal_qemu-f9e333ade2529f257ced6bcff8e5824cb07eacf9.zip
external_qemu-f9e333ade2529f257ced6bcff8e5824cb07eacf9.tar.gz
external_qemu-f9e333ade2529f257ced6bcff8e5824cb07eacf9.tar.bz2
Simplify async utils by removing extra LoopIo parameter.
This patch removes the LoopIo parameter from asyncReader_run() by storing the initial pointer passed to asyncReader_init() inside the object itself. Same treatment is performed for: - AsyncReader - AsyncWriter - AsyncLineReader - AsyncConnector - AsyncConsoleConnect Change-Id: Ic74b817e4c326230ca1d38b3a5d8c4790c4f90c1
Diffstat (limited to 'android/async-console.c')
-rw-r--r--android/async-console.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/android/async-console.c b/android/async-console.c
index f486df0..523c2b2 100644
--- a/android/async-console.c
+++ b/android/async-console.c
@@ -45,10 +45,10 @@ enum {
/* A helper function to prepare the line reader and switch to a new state */
static AsyncStatus
-_acc_prepareLineReader(AsyncConsoleConnector* acc, LoopIo* io, int newState)
+_acc_prepareLineReader(AsyncConsoleConnector* acc, int newState)
{
acc->state = newState;
- asyncLineReader_init(acc->lreader, acc->lbuff, sizeof(acc->lbuff), io);
+ asyncLineReader_init(acc->lreader, acc->lbuff, sizeof(acc->lbuff), acc->io);
return ASYNC_NEED_MORE;
}
@@ -59,13 +59,13 @@ asyncConsoleConnector_connect(AsyncConsoleConnector* acc,
{
acc->state = STATE_INITIAL;
acc->address = address[0];
- return asyncConsoleConnector_run(acc, io);
+ acc->io = io;
+ return asyncConsoleConnector_run(acc);
}
AsyncStatus
-asyncConsoleConnector_run(AsyncConsoleConnector* acc,
- LoopIo* io)
+asyncConsoleConnector_run(AsyncConsoleConnector* acc)
{
AsyncStatus status = ASYNC_NEED_MORE;
@@ -78,29 +78,29 @@ asyncConsoleConnector_run(AsyncConsoleConnector* acc,
case STATE_INITIAL: /* initial connection attempt */
acc->state = STATE_CONNECTING;
- status = asyncConnector_init(acc->connector, &acc->address, io);
+ status = asyncConnector_init(acc->connector, &acc->address, acc->io);
if (status == ASYNC_ERROR)
goto SET_ERROR;
if (status == ASYNC_COMPLETE) { /* immediate connection */
- _acc_prepareLineReader(acc, io, STATE_READ_BANNER_1);
+ _acc_prepareLineReader(acc, STATE_READ_BANNER_1);
continue;
}
break;
case STATE_CONNECTING: /* still trying to connect */
- status = asyncConnector_run(acc->connector, io);
+ status = asyncConnector_run(acc->connector);
if (status == ASYNC_ERROR)
goto SET_ERROR;
if (status == ASYNC_COMPLETE) {
- _acc_prepareLineReader(acc, io, STATE_READ_BANNER_1);
+ _acc_prepareLineReader(acc, STATE_READ_BANNER_1);
continue;
}
break;
case STATE_READ_BANNER_1: /* reading the first banner line */
- status = asyncLineReader_read(acc->lreader, io);
+ status = asyncLineReader_read(acc->lreader);
if (status == ASYNC_ERROR)
goto SET_ERROR;
@@ -112,13 +112,13 @@ asyncConsoleConnector_run(AsyncConsoleConnector* acc,
goto BAD_BANNER;
}
/* ok, fine, prepare for the next banner line then */
- _acc_prepareLineReader(acc, io, STATE_READ_BANNER_2);
+ _acc_prepareLineReader(acc, STATE_READ_BANNER_2);
continue;
}
break;
case STATE_READ_BANNER_2: /* reading the second banner line */
- status = asyncLineReader_read(acc->lreader, io);
+ status = asyncLineReader_read(acc->lreader);
if (status == ASYNC_ERROR)
goto SET_ERROR;