Received: from eggs.gnu.org ([2001:4830:134:3::10]:43393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQcAg-0003Pp-W9 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 08:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQcAZ-00088O-Oz for qemu-devel@nongnu.org; Thu, 20 Mar 2014 08:34:06 -0400 From: Markus Armbruster References: <1395247965-13889-1-git-send-email-pbonzini@redhat.com> <5329D4B7.4090602@redhat.com> <5329F406.7040606@redhat.com> Date: Thu, 20 Mar 2014 08:32:58 +0100 In-Reply-To: <5329F406.7040606@redhat.com> (Paolo Bonzini's message of "Wed, 19 Mar 2014 20:46:14 +0100") Message-ID: <874n2tgw9h.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] scripts: add sample model file for Coverity Scan List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org Paolo Bonzini writes: > Il 19/03/2014 18:32, Eric Blake ha scritto: >>> + * >>> + * Copyright (C) 2014 Red Hat, Inc. >>> + * >>> + * Authors: >>> + * Markus Armbruster >>> + * Paolo Bonzini >>> + * >>> + * This work is licensed under the terms of the GNU GPL, version 2 >>> or, at your >>> + * option, any later version. See the COPYING file in the >>> top-level directory. >> >> Aren't the license and authors blurbs usually in the other order? > > Not in the sample I copied from (migration.c). > >> >>> +#define assert(x) if (!(x)) __coverity_panic__(); >> >> Will this break any 'if () assert(); else {}' blocks? Obviously, such >> blocks already violate coding convention, but you might as well make >> this definition safe to use for older code. > > Ok. Coverity's builtin model models assert already, see library/generic/libc/all/all.c. We shouldn't override it without a good reason. >>> + >>> +static void __write(uint8_t *buf, int len) >> >> Will the fact that you used 'int len' instead of 'size_t' bite us on 32- >> vs. 64-bit? Same for __read. > > Yeah, I copied this from address_space_rw. I'll change to ssize_t to > catch negative values. Change the real address_space_rw(), or the model's __write()? >>> +void * >>> +g_malloc0 (size_t n_bytes) >>> +{ >>> + void *mem; >>> + __coverity_negative_sink__((ssize_t) n_bytes); >>> + mem = calloc(1, n_bytes == 0 ? 1 : n_bytes); >>> + if (!mem) __coverity_panic__ (); >> >> Is it worth being consistent on spacing before (? > > Yes. > >>> +void g_free (void *mem) >>> +{ >>> + if (mem) { >>> + free(mem); >>> + } >> >> Doesn't coverity already know that free(NULL) is a no-op, without you >> having to repeat it? > > This part came from Markus. :) I don't know what possessed me when I wrote (or copied?) the silly conditional. Let's drop it before someone else copies it.