From patchwork Mon Jun 20 11:58:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9187279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 682C960756 for ; Mon, 20 Jun 2016 12:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51F1A2237D for ; Mon, 20 Jun 2016 12:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 469CE2766D; Mon, 20 Jun 2016 12:00:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B822D2237D for ; Mon, 20 Jun 2016 12:00:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bExqj-0001Cz-9g; Mon, 20 Jun 2016 11:58:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bExqi-0001Cg-2A for xen-devel@lists.xenproject.org; Mon, 20 Jun 2016 11:58:40 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id B0/6A-03780-F6AD7675; Mon, 20 Jun 2016 11:58:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsXS6fjDSzfvVnq 4wddOeYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePH4yOsBde0Knq+32NtYDwn08XIySEkkCex a14LG4jNK2Ansfz0MUYQW0LAUGLf/FVgcRYBVYknU5czgdhsAuoSbc+2s3YxcnCICBhInDuaB GIyC+hLbFvHAlIhLOAl0dBzkA1iup3Exv0TwDo5BewlphxewwZSzisgKPF3hzBImBmo5MW/M2 wTGHlmIWRmIclA2FoSD3/dYoGwtSWWLXzNPAtsr7TE8n8cEGEbie51z5hRlYDY7hIbF21lW8D IsYpRvTi1qCy1SNdCL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMjMFAZgGAH44V2 50OMkhxMSqK8NsXp4UJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeBWvA+UEi1LTUyvSMnOAMQOTl uDgURLhlQdJ8xYXJOYWZ6ZDpE4xKkqJ8168BpQQAElklObBtcHi9BKjrJQwLyPQIUI8BalFuZ klqPKvGMU5GJWEebVBxvNk5pXATX8FtJgJaPGyfrDFJYkIKakGxnCzT5JRy+I4+3bFbWB9e2g BZ9rS+ApD4ztvTz9Ji7jRHtfWp8gx97vBnfTs24Ubmo8aRxW+53jnukT3h6jkbe0/ahcevnHW 93Ez/hr3kLv6vN3KDSoLTfJurRXrur9x59MFf38+6vjuoSO0d5/TuWeFURapSz8tSrRw2RAv1 Lqc61d6J9Ohx0osxRmJhlrMRcWJAPGOUMrOAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1466423916!46300899!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56579 invoked from network); 20 Jun 2016 11:58:38 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Jun 2016 11:58:38 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 20 Jun 2016 05:58:35 -0600 Message-Id: <5767F68A02000078000F6AD1@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Mon, 20 Jun 2016 05:58:34 -0600 From: "Jan Beulich" To: "xen-devel" References: <5767F35B02000078000F6A88@prv-mh.provo.novell.com> In-Reply-To: <5767F35B02000078000F6A88@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH 3/4] x86emul: drop pointless and add useful default cases X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP There's no point in having default cases when all possible values have respective case statements, or when there's just a "break" statement. Otoh the two main switch() statements better get default cases added, just to cover the case of someone altering one of the two lookup arrays without suitably changing these switch statements. Signed-off-by: Jan Beulich x86emul: drop pointless and add useful default cases There's no point in having default cases when all possible values have respective case statements, or when there's just a "break" statement. Otoh the two main switch() statements better get default cases added, just to cover the case of someone altering one of the two lookup arrays without suitably changing these switch statements. Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1379,7 +1379,6 @@ decode_segment(uint8_t modrm_reg) case 3: return x86_seg_ds; case 4: return x86_seg_fs; case 5: return x86_seg_gs; - default: break; } return decode_segment_failed; } @@ -2996,8 +2995,6 @@ x86_emulate( case 7: /* fdivr */ emulate_fpu_insn_memsrc("fdivrs", src.val); break; - default: - goto cannot_emulate; } } break; @@ -3128,8 +3125,6 @@ x86_emulate( case 7: /* fidivr m32i */ emulate_fpu_insn_memsrc("fidivrl", src.val); break; - default: - goto cannot_emulate; } } break; @@ -3352,8 +3347,6 @@ x86_emulate( case 7: /* fidivr m16i */ emulate_fpu_insn_memsrc("fidivrs", src.val); break; - default: - goto cannot_emulate; } } break; @@ -3431,8 +3424,6 @@ x86_emulate( dst.type = OP_MEM; emulate_fpu_insn_memdst("fistpll", dst.val); break; - default: - goto cannot_emulate; } } break; @@ -3750,8 +3741,6 @@ x86_emulate( } break; } - default: - goto cannot_emulate; } break; @@ -3845,10 +3834,11 @@ x86_emulate( goto push; case 7: generate_exception_if(1, EXC_UD, -1); - default: - goto cannot_emulate; } break; + + default: + BUG(); } writeback: @@ -4815,6 +4805,9 @@ x86_emulate( break; } break; + + default: + BUG(); } goto writeback; --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1379,7 +1379,6 @@ decode_segment(uint8_t modrm_reg) case 3: return x86_seg_ds; case 4: return x86_seg_fs; case 5: return x86_seg_gs; - default: break; } return decode_segment_failed; } @@ -2996,8 +2995,6 @@ x86_emulate( case 7: /* fdivr */ emulate_fpu_insn_memsrc("fdivrs", src.val); break; - default: - goto cannot_emulate; } } break; @@ -3128,8 +3125,6 @@ x86_emulate( case 7: /* fidivr m32i */ emulate_fpu_insn_memsrc("fidivrl", src.val); break; - default: - goto cannot_emulate; } } break; @@ -3352,8 +3347,6 @@ x86_emulate( case 7: /* fidivr m16i */ emulate_fpu_insn_memsrc("fidivrs", src.val); break; - default: - goto cannot_emulate; } } break; @@ -3431,8 +3424,6 @@ x86_emulate( dst.type = OP_MEM; emulate_fpu_insn_memdst("fistpll", dst.val); break; - default: - goto cannot_emulate; } } break; @@ -3750,8 +3741,6 @@ x86_emulate( } break; } - default: - goto cannot_emulate; } break; @@ -3845,10 +3834,11 @@ x86_emulate( goto push; case 7: generate_exception_if(1, EXC_UD, -1); - default: - goto cannot_emulate; } break; + + default: + BUG(); } writeback: @@ -4815,6 +4805,9 @@ x86_emulate( break; } break; + + default: + BUG(); } goto writeback;