From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: [PATCH] Remove three magic numbers Date: Mon, 30 Jul 2007 16:41:57 +1000 Message-ID: <1185777717.12151.160.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-devel Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org There are several places where hardcoded numbers are used in place of the easily-available constant, which is poor form. Signed-off-by: Rusty Russell diff -r 8bb74738cd07 drivers/kvm/kvm_main.c --- a/drivers/kvm/kvm_main.c Mon Jul 30 15:54:02 2007 +1000 +++ b/drivers/kvm/kvm_main.c Mon Jul 30 15:54:09 2007 +1000 @@ -2284,7 +2284,7 @@ static int kvm_vcpu_ioctl_interrupt(stru static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) { - if (irq->irq < 0 || irq->irq >= 256) + if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS) return -EINVAL; vcpu_load(vcpu); push_irq(vcpu, irq->irq); diff -r ca711ab5ba1a drivers/kvm/svm.c --- a/drivers/kvm/svm.c Fri Jul 27 17:20:01 2007 +1000 +++ b/drivers/kvm/svm.c Fri Jul 27 17:20:27 2007 +1000 @@ -241,7 +241,7 @@ static void skip_emulated_instruction(st pr_debug("%s: NOP\n", __FUNCTION__); return; } - if (svm->next_rip - svm->vmcb->save.rip > 15) { + if (svm->next_rip - svm->vmcb->save.rip > MAX_INST_SIZE) { printk(KERN_ERR "%s: ip 0x%llx next 0x%llx\n", __FUNCTION__, svm->vmcb->save.rip, diff -r 0b74682d8925 drivers/kvm/kvm_main.c --- a/drivers/kvm/kvm_main.c Mon Jul 23 16:12:09 2007 +1000 +++ b/drivers/kvm/kvm_main.c Mon Jul 23 16:16:36 2007 +1000 @@ -354,7 +354,7 @@ static void free_pio_guest_pages(struct { int i; - for (i = 0; i < 2; ++i) + for (i = 0; i < ARRAY_SIZE(vcpu->pio.guest_pages); ++i) if (vcpu->pio.guest_pages[i]) { __free_page(vcpu->pio.guest_pages[i]); vcpu->pio.guest_pages[i] = NULL; ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/