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