From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMC6P-00086p-Cc for qemu-devel@nongnu.org; Thu, 21 Jan 2016 05:04:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMC6O-0002zi-F6 for qemu-devel@nongnu.org; Thu, 21 Jan 2016 05:04:29 -0500 From: Markus Armbruster References: <1453219845-30939-1-git-send-email-eblake@redhat.com> <1453219845-30939-16-git-send-email-eblake@redhat.com> <874me8m6h0.fsf@blackfin.pond.sub.org> <569FF411.3080005@redhat.com> <87twm7mgta.fsf@blackfin.pond.sub.org> <20160121094616.GA4490@noname.redhat.com> Date: Thu, 21 Jan 2016 11:04:20 +0100 In-Reply-To: <20160121094616.GA4490@noname.redhat.com> (Kevin Wolf's message of "Thu, 21 Jan 2016 10:46:16 +0100") Message-ID: <87zivzjljv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v9 15/37] qom: Swap 'name' next to visitor in ObjectPropertyAccessor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Eduardo Habkost , "open list:nvme" , "Michael S. Tsirkin" , John Snow , Jason Wang , qemu-devel@nongnu.org, Alexander Graf , Keith Busch , marcandre.lureau@redhat.com, Gonglei , "open list:sPAPR" , Gerd Hoffmann , Igor Mammedov , Paolo Bonzini , Richard Henderson , Jiri Slaby , Andreas =?utf-8?Q?F=C3=A4rber?= , David Gibson Kevin Wolf writes: > Am 21.01.2016 um 10:18 hat Markus Armbruster geschrieben: >> Eric Blake writes: >> > On 01/20/2016 11:49 AM, Markus Armbruster wrote: >> >> Eric Blake writes: >> >> >> >> However, the actual match is looser! For instance, it also matches >> >> >> >> void foo(int *pi, unsigned *pu, void *vp, const char *cp, double **dpp) >> >> { >> >> } >> > >> > Uggh. My intent was to match exactly 'Object *' and 'Visitor *' as the >> > first two types, where 'int *' and 'unsigned *' are NOT matches. But I >> > don't know Coccinelle well enough to make that blatantly obvious (is my >> > declaration of 'type Object' not correct?). >> >> 'type Object' makes 'Object' a metavariable matching any C type. > > I can't say anything on this one, because I've never used 'type'. You > may or may not be right. However... > >> >> This could mess up unrelated function. I could double-check it doesn't, >> >> but I'd rather have a narrower match instead. Can't give one offhand, >> >> though. Ideas? >> > >> > Is 'typedef' better than 'type' for constraining the type of the first >> > two arguments? >> >> Matches any C typedef name. Less wrong, but still wrong :) > > ...I'm pretty sure that this is wrong and 'typedef' only declares that a > specific type exists as a typedef. Coccinelle's documentation is awfully terse. Looks like I jumped to conclusions. >> > Or does Coccinelle do literal matches on anything you >> > don't pre-declare, as in: >> >> Yes, but... >> >> > @ rule1 @ >> > identifier fn; >> > identifier obj, v, opaque, name, errp; >> > @@ >> > void fn >> > - (Object *obj, Visitor *v, void *opaque, const char *name, >> > + (Object *obj, Visitor *v, const char *name, void *opaque, >> > Error **errp) { ... } >> >> ... when I try that, spatch throws a parse error. > > Because you need to declare the typedef. :-) > > I had a similar problem and asked Julia about it at KVM Forum, so I'm > pretty sure that it's right. If I replace 'type' by 'typedef', spatch no longer messes up void foo(int *pi, unsigned *pu, void *vp, const char *cp, double **dpp) but still rewrites void bar(Object *o, Visitor *v, void *opq, const char *n, Error **ep) Thanks, Kevin! Eric, could you try to regenerate your patch with the corrected script?