Skip to contentSkip to conversation

qmp: object-add: Validate class before creating object

PATCH Andreas Färber 1 participant 1 message May 16, 2014 6 messages not in the archive

lore
Share & tools
lore
#6 lore raw
In reply to a message not in the archive

Am 25.04.2014 21:16, schrieb Eduardo Habkost:

Quoted 23 lines · Andreas Färber
Quoted 22 lines

Am 25.04.2014 20:02, schrieb Luiz Capitulino:

Quoted 20 lines
Quoted 4 lines · On Fri, 25 Apr 2014 17:57:12 +0200 Andreas Färber <[email protected]> wrote:

Am 25.04.2014 17:12, schrieb Luiz Capitulino:

Quoted 3 lines

On Wed, 16 Apr 2014 14:39:38 -0300
Eduardo Habkost <[email protected]> wrote:

Quoted 11 lines
Quoted 9 lines

qmp.c void object_add(const char *type, const char *id, const QDict *qdict, · line 543

Quoted 9 lines
qmp.c +1 -0
index 87a28f7..9a93ab1 100644
@@ -540,14 +540,27 @@ void object_add(const char *type, const char *id, const QDict *qdict,
                 Visitor *v, Error **errp)
 {
     Object *obj;
+    ObjectClass *klass;

Luiz, can you rename klass to oc please?

My pull request is almost ready (finishing last few tests), so I think it's a bit late for a style change.

Quoted 6 lines
Quoted 2 lines

Then either one of you please follow-up with a fix before you forget. I've been asked to change patches that way, so I expect others do, too.

Could you explain why this is a bug? The patch matches the existing style in qmp.c, and if I grep the whole tree I see 482 matches for 'ObjectClass *klass' and 165 for 'ObjectClass *oc'.

Simple explanation for the numbers: "klass" was introduced through Anthony's Python-automated qdev -> QOM conversion, because C++ reserves "class". Then when I started making use of QOM for CPUs I was asked to change my copied "klass" to "oc", with the argument that "klass" is a deliberate misspelling and that we already used dc for DeviceClass, etc. Therefore I expect others to update their patches to the new style, too.

ObjectClass *oc
#define MY_CLASS(class) # or MY_CLASS(cls) -- not forbidden in macros

Just like DO_UPCAST() and other pre-QOM macros, the only remedy to avoid bad copy&paste will be to pass over the source tree and fix it consistently. No time for that myself now, maybe a GSoC/OPW task?

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg