diff mbox

[v14,13/15] qapi: Enforce (or whitelist) case conventions on qapi members

Message ID 87lh9dukyw.fsf@blackfin.pond.sub.org
State New
Headers show

Commit Message

Markus Armbruster Dec. 2, 2015, 11:51 a.m. UTC
This is the fixup I mentioned in the v13 thread.  The "Unreachable and
not implemented" hunk should probably be its own patch.

Comments

Eric Blake Dec. 2, 2015, 1:41 p.m. UTC | #1
On 12/02/2015 04:51 AM, Markus Armbruster wrote:
> This is the fixup I mentioned in the v13 thread.  The "Unreachable and
> not implemented" hunk should probably be its own patch.

In fact, that hunk...

> 
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 6d38d7c..870e476 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py

> @@ -1073,7 +1071,8 @@ class QAPISchemaMember(object):
>                  return '(parameter of %s)' % owner[:-4]
>              else:
>                  assert owner.endswith('-wrapper')
> -                return '(branch of %s)' % owner[:-8]
> +                # Unreachable and not implemented
> +                assert False
>          if owner.endswith('Kind'):
>              # See QAPISchema._make_implicit_enum_type()
>              return '(branch of %s)' % owner[:-4]

...should probably just be squashed directly into commit 8f3a05b on your
current qapi-next branch, since it hasn't landed upstream yet.

Your fixup looks sane, and eliminates the need for 12/15.  So I'm fine
if you'd like to make that change when updating qapi-next.
Reviewed-by: Eric Blake <eblake@redhat.com>
Eric Blake Dec. 2, 2015, 2:11 p.m. UTC | #2
On 12/02/2015 04:51 AM, Markus Armbruster wrote:
> This is the fixup I mentioned in the v13 thread.  The "Unreachable and
> not implemented" hunk should probably be its own patch.
> 

> +++ b/tests/qapi-schema/args-member-case.err
> @@ -1 +1 @@
> -tests/qapi-schema/args-member-case.json:3: Member 'Arg' of 'Foo' should use lowercase
> +tests/qapi-schema/args-member-case.json:3: 'Arg' (parameter of Foo) should not use uppercase

Oh, and I forgot to use the name 'no-way-this-will-get-whitelisted' (or
NoWayThisWillGetWhitelisted) as suggested in v13, if you want to also
change naming.

> diff --git a/tests/qapi-schema/enum-member-case.err b/tests/qapi-schema/enum-member-case.err
> index e50b12a..a1d67c6 100644
> --- a/tests/qapi-schema/enum-member-case.err
> +++ b/tests/qapi-schema/enum-member-case.err
> @@ -1 +1 @@
> -tests/qapi-schema/enum-member-case.json:3: Member 'Value' of 'Foo' should use lowercase
> +tests/qapi-schema/enum-member-case.json:3: 'Value' (member of Foo) should not use uppercase
> diff --git a/tests/qapi-schema/union-branch-case.err b/tests/qapi-schema/union-branch-case.err
> index 6c6b740..0b4c1b5 100644
> --- a/tests/qapi-schema/union-branch-case.err
> +++ b/tests/qapi-schema/union-branch-case.err
> @@ -1 +1 @@
> -tests/qapi-schema/union-branch-case.json:3: Member 'Branch' of 'Foo' should use lowercase
> +tests/qapi-schema/union-branch-case.json:3: 'Branch' (branch of Foo) should not use uppercase
>
Markus Armbruster Dec. 2, 2015, 4:48 p.m. UTC | #3
Eric Blake <eblake@redhat.com> writes:

> On 12/02/2015 04:51 AM, Markus Armbruster wrote:
>> This is the fixup I mentioned in the v13 thread.  The "Unreachable and
>> not implemented" hunk should probably be its own patch.
>
> In fact, that hunk...
>
>> 
>> diff --git a/scripts/qapi.py b/scripts/qapi.py
>> index 6d38d7c..870e476 100644
>> --- a/scripts/qapi.py
>> +++ b/scripts/qapi.py
>
>> @@ -1073,7 +1071,8 @@ class QAPISchemaMember(object):
>>                  return '(parameter of %s)' % owner[:-4]
>>              else:
>>                  assert owner.endswith('-wrapper')
>> -                return '(branch of %s)' % owner[:-8]
>> +                # Unreachable and not implemented
>> +                assert False
>>          if owner.endswith('Kind'):
>>              # See QAPISchema._make_implicit_enum_type()
>>              return '(branch of %s)' % owner[:-4]
>
> ...should probably just be squashed directly into commit 8f3a05b on your
> current qapi-next branch, since it hasn't landed upstream yet.

Good idea.

> Your fixup looks sane, and eliminates the need for 12/15.  So I'm fine

Yes, let's set that patch aside for now.  We can bring it back if we
find a need.

> if you'd like to make that change when updating qapi-next.
> Reviewed-by: Eric Blake <eblake@redhat.com>

Checkout out your later fixups now.
diff mbox

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 6d38d7c..870e476 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -63,7 +63,6 @@  returns_whitelist = [
 case_whitelist = [
     # From QMP:
     'ACPISlotType',         # DIMM, visible through query-acpi-ospm-status
-    'CpuInfo',              # CPU, PC, visible through query-cpu
     'CpuInfoBase',          # CPU, visible through query-cpu
     'CpuInfoMIPS',          # PC, visible through query-cpu
     'CpuInfoTricore',       # PC, visible through query-cpu
@@ -1053,10 +1052,9 @@  class QAPISchemaMember(object):
 
     def check_clash(self, info, seen):
         cname = c_name(self.name)
-        if cname.lower() != cname and info['name'] not in case_whitelist:
+        if cname.lower() != cname and self.owner not in case_whitelist:
             raise QAPIExprError(info,
-                                "Member '%s' of '%s' should use lowercase"
-                                % (self.name, info['name']))
+                                "%s should not use uppercase" % self.describe())
         if cname in seen:
             raise QAPIExprError(info,
                                 "%s collides with %s"
@@ -1073,7 +1071,8 @@  class QAPISchemaMember(object):
                 return '(parameter of %s)' % owner[:-4]
             else:
                 assert owner.endswith('-wrapper')
-                return '(branch of %s)' % owner[:-8]
+                # Unreachable and not implemented
+                assert False
         if owner.endswith('Kind'):
             # See QAPISchema._make_implicit_enum_type()
             return '(branch of %s)' % owner[:-4]
diff --git a/tests/qapi-schema/args-member-case.err b/tests/qapi-schema/args-member-case.err
index 7bace48..44c31ea 100644
--- a/tests/qapi-schema/args-member-case.err
+++ b/tests/qapi-schema/args-member-case.err
@@ -1 +1 @@ 
-tests/qapi-schema/args-member-case.json:3: Member 'Arg' of 'Foo' should use lowercase
+tests/qapi-schema/args-member-case.json:3: 'Arg' (parameter of Foo) should not use uppercase
diff --git a/tests/qapi-schema/enum-member-case.err b/tests/qapi-schema/enum-member-case.err
index e50b12a..a1d67c6 100644
--- a/tests/qapi-schema/enum-member-case.err
+++ b/tests/qapi-schema/enum-member-case.err
@@ -1 +1 @@ 
-tests/qapi-schema/enum-member-case.json:3: Member 'Value' of 'Foo' should use lowercase
+tests/qapi-schema/enum-member-case.json:3: 'Value' (member of Foo) should not use uppercase
diff --git a/tests/qapi-schema/union-branch-case.err b/tests/qapi-schema/union-branch-case.err
index 6c6b740..0b4c1b5 100644
--- a/tests/qapi-schema/union-branch-case.err
+++ b/tests/qapi-schema/union-branch-case.err
@@ -1 +1 @@ 
-tests/qapi-schema/union-branch-case.json:3: Member 'Branch' of 'Foo' should use lowercase
+tests/qapi-schema/union-branch-case.json:3: 'Branch' (branch of Foo) should not use uppercase