Received: from eggs.gnu.org ([2001:4830:134:3::10]:49506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Icr-0002XX-27 for qemu-devel@nongnu.org; Tue, 23 Jun 2015 03:28:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7Icn-00086K-Rq for qemu-devel@nongnu.org; Tue, 23 Jun 2015 03:28:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7Icn-000863-Mx for qemu-devel@nongnu.org; Tue, 23 Jun 2015 03:28:05 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9D2DC8F2FD for ; Tue, 23 Jun 2015 07:28:04 +0000 (UTC) From: Markus Armbruster References: <1435001200-20610-1-git-send-email-armbru@redhat.com> <1435001200-20610-4-git-send-email-armbru@redhat.com> <558885A3.202@redhat.com> Date: Tue, 23 Jun 2015 09:28:01 +0200 In-Reply-To: <558885A3.202@redhat.com> (Eric Blake's message of "Mon, 22 Jun 2015 16:01:07 -0600") Message-ID: <87wpyuzxxa.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 3/7] qga: Clean up unnecessarily dirty casts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: pbonzini@redhat.com, mst@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com Eric Blake writes: > On 06/22/2015 01:26 PM, Markus Armbruster wrote: >> qga_vss_fsfreeze() casts error_set_win32() from >> >> void (*)(Error **, int, ErrorClass, const char *, ...) >> >> to >> >> void (*)(void **, int, int, const char *, ...) >> >> The result is later called. Since the two types are not compatible, >> the call is undefined behavior. It works in practice anyway. > > Better than some other horrid casts we do, like monitor.c playing fast > and loose with 'Monitor *' vs. 'FILE *' in hmp_info_mtree() and friends. > But that's a cleanup for another series. I wonder why we don't have a warning to flag casts of a function where calling the result would be undefined behavior. >> However, there's no real need for trickery here. Clean it up as >> follows: >> >> * Declare struct Error, and fix the first parameter. >> >> * Switch to error_setg_win32(). This gets rid of the troublesome >> ErrorClass parameter. Requires converting error_setg_win32() from >> macro to function, but that's trivially easy, because this is the >> only user of error_set_win32(). >> >> Signed-off-by: Markus Armbruster >> --- > > Reviewed-by: Eric Blake Thanks!