Patchwork [3/5] qapi: avoid reserved word restrict

login
register
mail settings
Submitter Anthony Liguori
Date Aug. 1, 2012, 12:01 a.m.
Message ID <87r4rr5vkw.fsf@codemonkey.ws>
Download mbox | patch
Permalink /patch/174359/
State New
Headers show

Comments

Anthony Liguori - Aug. 1, 2012, 12:01 a.m.
Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 30/07/2012 18:04, blauwirbel@gmail.com ha scritto:
>> From: Blue Swirl <blauwirbel@gmail.com>
>> 
>> Clang compiler complained about use of reserved word 'restrict' in SLIRP
>> and QAPI.
>> 
>> Rename 'restrict' to 'restricted' which also matches other SLIRP code.
>
> Can't do it, this changes the command-line option.
>
> Luiz, Michael, any ideas?

Just change c_var() in scripts/qapi.py to have:


Then fixup and build failures (make sure to do a clean
first--dependencies seem to be off for qapi).

Regards,

Anthony Liguori

>
> Paolo
>
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>> ---
>>  net/slirp.c      |    6 +++---
>>  qapi-schema.json |    4 ++--
>>  2 files changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/net/slirp.c b/net/slirp.c
>> index 5c2e6b2..8c42b53 100644
>> --- a/net/slirp.c
>> +++ b/net/slirp.c
>> @@ -722,9 +722,9 @@ int net_init_slirp(const NetClientOptions *opts, const char *name,
>>      net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD);
>>      net_init_slirp_configs(user->guestfwd, 0);
>>  
>> -    ret = net_slirp_init(vlan, "user", name, user->restrict, vnet, user->host,
>> -                         user->hostname, user->tftp, user->bootfile,
>> -                         user->dhcpstart, user->dns, user->smb,
>> +    ret = net_slirp_init(vlan, "user", name, user->restricted, vnet,
>> +                         user->host, user->hostname, user->tftp,
>> +                         user->bootfile, user->dhcpstart, user->dns, user->smb,
>>                           user->smbserver);
>>  
>>      while (slirp_configs) {
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index bc55ed2..3912430 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -1925,7 +1925,7 @@
>>  #
>>  # @hostname: #optional client hostname reported by the builtin DHCP server
>>  #
>> -# @restrict: #optional isolate the guest from the host
>> +# @restricted: #optional isolate the guest from the host
>>  #
>>  # @ip: #optional legacy parameter, use net= instead
>>  #
>> @@ -1956,7 +1956,7 @@
>>  { 'type': 'NetdevUserOptions',
>>    'data': {
>>      '*hostname':  'str',
>> -    '*restrict':  'bool',
>> +    '*restricted':'bool',
>>      '*ip':        'str',
>>      '*net':       'str',
>>      '*host':      'str',
>>

Patch

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 8082af3..34bfbf6 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -131,6 +131,8 @@  def camel_case(name):
     return new_name
 
 def c_var(name):
+    if name in ['restrict']:
+        return 'q_restrict'
     return name.replace('-', '_').lstrip("*")
 
 def c_fun(name):