[PATCH 05/10] hush: refactor file_get()
Sascha Hauer
s.hauer at pengutronix.de
Tue Nov 12 08:52:14 EST 2013
Save indentation level by returning early.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/hush.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/common/hush.c b/common/hush.c
index 7a077ba..f0f2eda 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -471,21 +471,23 @@ static int file_get(struct in_str *i)
int ch;
ch = 0;
+
/* If there is data waiting, eat it up */
- if (i->p && *i->p) {
+ if (i->p && *i->p)
+ return *i->p++;
+
+ /* need to double check i->file because we might be doing something
+ * more complicated by now, like sourcing or substituting. */
+ while (!i->p || strlen(i->p) == 0 )
+ get_user_input(i);
+
+ i->promptmode = 2;
+
+ if (i->p && *i->p)
ch = *i->p++;
- } else {
- /* need to double check i->file because we might be doing something
- * more complicated by now, like sourcing or substituting. */
- while (!i->p || strlen(i->p) == 0 ) {
- get_user_input(i);
- }
- i->promptmode = 2;
- if (i->p && *i->p) {
- ch = *i->p++;
- }
- debug("%s: got a %d\n", __func__, ch);
- }
+
+ debug("%s: got a %d\n", __func__, ch);
+
return ch;
}
--
1.8.4.2
More information about the barebox
mailing list