From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFy1T-0001hY-9c for qemu-devel@nongnu.org; Thu, 23 Jun 2016 02:21:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFy1P-0002O6-2a for qemu-devel@nongnu.org; Thu, 23 Jun 2016 02:21:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41177) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFy1O-0002Nt-Sr for qemu-devel@nongnu.org; Thu, 23 Jun 2016 02:21:50 -0400 Date: Thu, 23 Jun 2016 08:21:46 +0200 From: Kevin Wolf Message-ID: <20160623062146.GA4848@noname.redhat.com> References: <1466587008-3933-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <1466587008-3933-2-git-send-email-xiecl.fnst@cn.fujitsu.com> <2b17fa8d-d2bb-d20e-2445-e010aa7066b1@redhat.com> <576A6486.4070409@cn.fujitsu.com> <233d4f8a-8d64-ffa8-9470-8c51463ef69b@redhat.com> <576ACB8C.7050304@redhat.com> <576B3588.1070806@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <576B3588.1070806@cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH 1/2] blockjob: assert(cb) in the entry functions of blockjob List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Changlong Xie Cc: Eric Blake , Paolo Bonzini , qemu devel , Jeff Cody , Fam Zheng , Stefan Hajnoczi , Max Reitz Am 23.06.2016 um 03:04 hat Changlong Xie geschrieben: > On 06/23/2016 01:31 AM, Eric Blake wrote: > >On 06/22/2016 04:19 AM, Paolo Bonzini wrote: > >> > >> > >>On 22/06/2016 12:12, Changlong Xie wrote: > >>> > >>>commit/mirror/stream/backup use block_job_create(..., cb,..) to create > >>>relevant blockjob. When they finished, these jobs will invoke > >>>block_job_completed, then invoke job->cb() unconditionally. So i think > >>>we need this to avoid segment fault. Actually backup has implemented this. > >> > >>So this suggests that the right place to put the assertion would be > >>block_job_create. But it's even better to add a > >> > >>#define QEMU_NONNULL __attribute__((__nonnull__)) > >> > >>to include/qemu/compiler.h and declare the arguments as non-null. > > > >Or alternatively fix things to only invoke job->cb() if it is non-NULL, > >so that callers don't have to pass in a no-op callback just to appease a > >non-NULL attribute. > > Is there any reason, that we should invoke job->cb() unconditionally > without nonnull check? There is no relevant clue in the historical > commit messages. If yes, i prefer paolo's suggestion; otherwise > eric's solution is better. I don't think no-op callbacks actually exist for jobs. Kevin