From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFyVk-0003VF-6A for qemu-devel@nongnu.org; Thu, 23 Jun 2016 02:53:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFyVe-0001BR-Hm for qemu-devel@nongnu.org; Thu, 23 Jun 2016 02:53:12 -0400 Received: from [59.151.112.132] (port=56033 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFyVc-00014R-Uv for qemu-devel@nongnu.org; Thu, 23 Jun 2016 02:53:06 -0400 Message-ID: <576B8859.4070202@cn.fujitsu.com> Date: Thu, 23 Jun 2016 14:57:29 +0800 From: Changlong Xie MIME-Version: 1.0 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> <20160623062146.GA4848@noname.redhat.com> In-Reply-To: <20160623062146.GA4848@noname.redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit 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: Kevin Wolf Cc: Eric Blake , Paolo Bonzini , qemu devel , Jeff Cody , Fam Zheng , Stefan Hajnoczi , Max Reitz On 06/23/2016 02:21 PM, Kevin Wolf wrote: > 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. > So, i'll put assert(cb) in block_job_create as Paolo suggested. Thanks -Xie > Kevin > > > . >