The number of bytes written may be less than the count bytes specified by write(2) call. Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx> --- tools/chcli.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/chcli.c b/tools/chcli.c index 51ec697..2c9ac23 100644 --- a/tools/chcli.c +++ b/tools/chcli.c @@ -595,6 +595,7 @@ static int cmd_get(void) while (get_len > 0) { size_t need_len; + ssize_t rc; need_len = MIN(GET_BUFSZ, get_len); @@ -603,14 +604,15 @@ static int cmd_get(void) return 1; } - if (write(wfd, get_buf, need_len) != need_len) { + rc = write(wfd, get_buf, need_len); + if (rc < 0) { fprintf(stderr, "GET write to output failed: %s\n", strerror(errno)); unlink(output_fn); return 1; } - get_len -= need_len; + get_len -= rc; } if (wfd != STDOUT_FILENO) -- 1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe hail-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html