From f9e333ade2529f257ced6bcff8e5824cb07eacf9 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 17 Mar 2011 14:57:51 +0100 Subject: 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 --- android/async-console.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'android/async-console.c') 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; -- cgit v1.1