From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvBTT-0002AX-9n for qemu-devel@nongnu.org; Wed, 08 Feb 2012 12:38:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvBTN-00010m-A8 for qemu-devel@nongnu.org; Wed, 08 Feb 2012 12:38:31 -0500 Received: from mail-pz0-f45.google.com ([209.85.210.45]:63221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvBTN-0000z1-2c for qemu-devel@nongnu.org; Wed, 08 Feb 2012 12:38:25 -0500 Received: by mail-pz0-f45.google.com with SMTP id p14so796238dad.4 for ; Wed, 08 Feb 2012 09:38:24 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 8 Feb 2012 18:37:33 +0100 Message-Id: <1328722656-22856-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1328722656-22856-1-git-send-email-pbonzini@redhat.com> References: <1328722656-22856-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 2/5] raw-posix: put Linux fd fields into a union List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, armbru@redhat.com We will add CDROM-specific fields in the next patch, reuse the space in the struct. Signed-off-by: Paolo Bonzini --- block/raw-posix.c | 38 +++++++++++++++++++++----------------- 1 files changed, 21 insertions(+), 17 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 2a5b6fa..d9b03a1 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -119,11 +119,15 @@ typedef struct BDRVRawState { int type; int open_flags; #if defined(__linux__) - /* linux floppy specific */ - int64_t fd_open_time; - int64_t fd_error_time; - int fd_got_error; - int fd_media_changed; + union { + struct { + /* linux floppy specific */ + int64_t open_time; + int64_t error_time; + int got_error; + int media_changed; + } fdd; + }; #endif #ifdef CONFIG_LINUX_AIO int use_aio; @@ -779,7 +783,7 @@ static int fd_open(BlockDriverState *bs) return 0; last_media_present = (s->fd >= 0); if (s->fd >= 0 && - (get_clock() - s->fd_open_time) >= FD_OPEN_TIMEOUT) { + (get_clock() - s->fdd.open_time) >= FD_OPEN_TIMEOUT) { close(s->fd); s->fd = -1; #ifdef DEBUG_FLOPPY @@ -787,8 +791,8 @@ static int fd_open(BlockDriverState *bs) #endif } if (s->fd < 0) { - if (s->fd_got_error && - (get_clock() - s->fd_error_time) < FD_OPEN_TIMEOUT) { + if (s->fdd.got_error && + (get_clock() - s->fdd.error_time) < FD_OPEN_TIMEOUT) { #ifdef DEBUG_FLOPPY printf("No floppy (open delayed)\n"); #endif @@ -796,10 +800,10 @@ static int fd_open(BlockDriverState *bs) } s->fd = open(bs->filename, s->open_flags & ~O_NONBLOCK); if (s->fd < 0) { - s->fd_error_time = get_clock(); - s->fd_got_error = 1; + s->fdd.error_time = get_clock(); + s->fdd.got_error = 1; if (last_media_present) - s->fd_media_changed = 1; + s->fdd.media_changed = 1; #ifdef DEBUG_FLOPPY printf("No floppy\n"); #endif @@ -810,9 +814,9 @@ static int fd_open(BlockDriverState *bs) #endif } if (!last_media_present) - s->fd_media_changed = 1; - s->fd_open_time = get_clock(); - s->fd_got_error = 0; + s->fdd.media_changed = 1; + s->fdd.open_time = get_clock(); + s->fdd.got_error = 0; return 0; } @@ -931,7 +935,7 @@ static int floppy_open(BlockDriverState *bs, const char *filename, int flags) /* close fd so that we can reopen it as needed */ close(s->fd); s->fd = -1; - s->fd_media_changed = 1; + s->fdd.media_changed = 1; return 0; } @@ -980,8 +984,8 @@ static int floppy_media_changed(BlockDriverState *bs) * It does not work if the floppy is changed without trying to read it. */ fd_open(bs); - ret = s->fd_media_changed; - s->fd_media_changed = 0; + ret = s->fdd.media_changed; + s->fdd.media_changed = 0; #ifdef DEBUG_FLOPPY printf("Floppy changed=%d\n", ret); #endif -- 1.7.7.6