From: Olivier Matz Date: Fri, 24 Dec 2010 12:56:16 +0000 (+0100) Subject: cmdline (merge-intel): fix warnings when compiing with -D_FORTIFY_SOURCE=2 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2e949478bc20b52358b9093a8d3ae88d186fb8fc;p=libcmdline.git cmdline (merge-intel): fix warnings when compiing with -D_FORTIFY_SOURCE=2 Signed-off-by: Olivier Matz --- diff --git a/src/lib/cmdline.c b/src/lib/cmdline.c index 6d37885..e6662bd 100644 --- a/src/lib/cmdline.c +++ b/src/lib/cmdline.c @@ -97,13 +97,16 @@ cmdline_complete_buffer(struct rdline *rdl, const char *buf, return cmdline_complete(cl, buf, state, dstbuf, dstsize); } -void +int cmdline_write_char(struct rdline *rdl, char c) { + int ret = -1; struct cmdline *cl = rdl->opaque; - if (cl->s_out >= 0) { - write(cl->s_out, &c, 1); - } + + if (cl->s_out >= 0) + ret = write(cl->s_out, &c, 1); + + return ret; } @@ -222,10 +225,10 @@ cmdline_interact(struct cmdline *cl) c = -1; while (1) { - read(cl->s_in, &c, 1); - if (cmdline_in(cl, &c, 1) < 0) { + if (read(cl->s_in, &c, 1) < 0) + break; + if (cmdline_in(cl, &c, 1) < 0) break; - } } cmdline_free(cl); } diff --git a/src/lib/cmdline.h b/src/lib/cmdline.h index 60a3bbb..d8a7384 100644 --- a/src/lib/cmdline.h +++ b/src/lib/cmdline.h @@ -80,7 +80,7 @@ void cmdline_set_prompt(struct cmdline *cl, const char *prompt); void cmdline_free(struct cmdline *cl); void cmdline_printf(const struct cmdline *cl, const char *fmt, ...); int cmdline_in(struct cmdline *cl, const char *buf, int size); -void cmdline_write_char(struct rdline *rdl, char c); +int cmdline_write_char(struct rdline *rdl, char c); void cmdline_interact(struct cmdline *cl); void cmdline_quit(struct cmdline *cl);