* [PATCH] Remove three magic numbers
@ 2007-07-30 6:41 Rusty Russell
[not found] ` <1185777717.12151.160.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Rusty Russell @ 2007-07-30 6:41 UTC (permalink / raw)
To: kvm-devel
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 <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-30 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-30 6:41 [PATCH] Remove three magic numbers Rusty Russell
[not found] ` <1185777717.12151.160.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-30 9:15 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox