Re: [PATCH kvm-unit-tests 17/18] arm: do not allocate virtio buffers from the stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/10/2017 10:48, Andrew Jones wrote:
> I'd rather we continue to exit gracefully from chr_testdev_exit(),
> allowing callers to unconditionally call it, and then do their own
> "shouldn't have happened" printing, or fallback to another way to
> exit. That way when a unit test is run without the chr-testdev
> provided, exit() can still work, just differently. Granted we only
> have halt() for that fallback right now, but I've exploited the fact
> that chr_testdev_exit() will just return, without the chr-testdev
> device present, several times in temporary hacks.

Sure, that's certainly okay.  The patch is even simpler, and I should 
really have sent this one first:

diff --git a/lib/chr-testdev.c b/lib/chr-testdev.c
index c19424f..1450826 100644
--- a/lib/chr-testdev.c
+++ b/lib/chr-testdev.c
@@ -30,16 +30,15 @@ static void __testdev_send(char *buf, unsigned int len)
 void chr_testdev_exit(int code)
 {
 	unsigned int len;
-	char buf[8];
-
-	snprintf(buf, sizeof(buf), "%dq", code);
-	len = strlen(buf);
+	static char buf[8];
 
 	spin_lock(&lock);
-
 	if (!vcon)
 		goto out;
 
+	snprintf(buf, sizeof(buf), "%dq", code);
+	len = strlen(buf);
+
 	__testdev_send(buf, len);
 
 out:


Paolo

> 
> Thanks,
> drew
> 
> 
>>  }
>>  
>>  void chr_testdev_init(void)
>> -- 
>> 2.14.2
>>
>>




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux