From patchwork Tue Dec 6 03:40:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Evans X-Patchwork-Id: 129509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C4D0E1007D6 for ; Tue, 6 Dec 2011 14:40:05 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932893Ab1LFDj5 (ORCPT ); Mon, 5 Dec 2011 22:39:57 -0500 Received: from ozlabs.org ([203.10.76.45]:42886 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932871Ab1LFDjz (ORCPT ); Mon, 5 Dec 2011 22:39:55 -0500 Received: from [10.61.2.183] (ibmaus65.lnk.telstra.net [165.228.126.9]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id EDD3E1007D5; Tue, 6 Dec 2011 14:39:53 +1100 (EST) Message-ID: <4EDD8EBC.5040205@ozlabs.org> Date: Tue, 06 Dec 2011 14:40:44 +1100 From: Matt Evans User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 MIME-Version: 1.0 To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Subject: [PATCH 14/28] kvm tools: Fix term_getc(), term_getc_iov() endian bugs References: In-Reply-To: Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org term_getc()'s int c has one byte written into it (at its lowest address) by read_in_full(). This is expected to be the least significant byte, but that isn't the case on BE! Use correct type, unsigned char. A similar issue exists in term_getc_iov(), which needs to write a char to the iov rather than an int. Signed-off-by: Matt Evans --- tools/kvm/term.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tools/kvm/term.c b/tools/kvm/term.c index fb5d71c..440884e 100644 --- a/tools/kvm/term.c +++ b/tools/kvm/term.c @@ -30,11 +30,10 @@ int term_fds[4][2]; int term_getc(int who, int term) { - int c; + unsigned char c; if (who != active_console) return -1; - if (read_in_full(term_fds[term][TERM_FD_IN], &c, 1) < 0) return -1; @@ -84,7 +83,7 @@ int term_getc_iov(int who, struct iovec *iov, int iovcnt, int term) if (c < 0) return 0; - *((int *)iov[TERM_FD_IN].iov_base) = c; + *((char *)iov[TERM_FD_IN].iov_base) = (char)c; return sizeof(char); }