From: Paolo Bonzini Subject: Re: [PATCH kvm-unit-tests 17/18] arm: do not allocate virtio buffers from the stack Date: Sat, 28 Oct 2017 00:44:52 +0200 Message-ID: <7993c587-8516-1204-7a78-8b485de4f577@redhat.com> References: <20171024152145.28456-1-pbonzini@redhat.com> <20171024152145.28456-18-pbonzini@redhat.com> <20171025084853.ujinai6hjbseukpr@kamzik.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, david@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33016 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbdJ0Wo5 (ORCPT ); Fri, 27 Oct 2017 18:44:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D4844ACAC for ; Fri, 27 Oct 2017 22:44:57 +0000 (UTC) In-Reply-To: <20171025084853.ujinai6hjbseukpr@kamzik.brq.redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: 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 >> >>