From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdPqn-0007vB-Tb for qemu-devel@nongnu.org; Wed, 01 Apr 2015 17:07:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdPqm-00032p-Tj for qemu-devel@nongnu.org; Wed, 01 Apr 2015 17:07:01 -0400 Message-ID: <551C5DE7.70904@redhat.com> Date: Wed, 01 Apr 2015 17:06:47 -0400 From: John Snow MIME-Version: 1.0 References: <1427911244-22565-1-git-send-email-emaste@freebsd.org> In-Reply-To: <1427911244-22565-1-git-send-email-emaste@freebsd.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ed Maste , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org On 04/01/2015 02:00 PM, Ed Maste wrote: > Signed-off-by: Ed Maste > --- > tests/libqtest.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tests/libqtest.c b/tests/libqtest.c > index 12d65bd..54550a8 100644 > --- a/tests/libqtest.c > +++ b/tests/libqtest.c > @@ -453,6 +453,7 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...) > const char *qtest_get_arch(void) > { > const char *qemu = getenv("QTEST_QEMU_BINARY"); > + g_assert(qemu != NULL); > const char *end = strrchr(qemu, '/'); > > return end + strlen("/qemu-system-"); > This one has annoyed me in the past, too. I wonder if it would be even nicer to add an fprintf to give the user a nice message explaining exactly what went wrong, though -- since this particular error is only going to happen when a user is invoking the test manually. Maybe: if (qemu == NULL) { fprintf(stderr, "..."); g_assert_not_reached(); } Though that does read a little strangely. ("Here's a nice error message for something we are asserting will never happen.") Well, either way, it's better than segfaulting, so: Reviewed-by: John Snow