[ovs-dev,v2] odp-util: fix a compiler warning
diff mbox series

Message ID 20180116140547.2596-1-aconole@bytheb.org
State Accepted
Headers show
Series
  • [ovs-dev,v2] odp-util: fix a compiler warning
Related show

Commit Message

Aaron Conole Jan. 16, 2018, 2:05 p.m. UTC
The result of a ternary operation will be promoted at least to int
type.  As such, the compiler may generate a warning as:
  format specifies type 'unsigned char' but the argument has type 'int'

Squelch this by preferring the %d format specifier to print 1/0 values.

Fixes: 74c4530dca93 ("ofproto-dpif: Don't slow-path controller actions with pause.")
Cc: Justin Pettit <jpettit@ovn.org>
Signed-off-by: Aaron Conole <aconole@bytheb.org>
---
v1->v2: instead of using a cast, use a different format string.

 lib/odp-util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stokes, Ian Jan. 17, 2018, 6:29 p.m. UTC | #1
> The result of a ternary operation will be promoted at least to int type.
> As such, the compiler may generate a warning as:
>   format specifies type 'unsigned char' but the argument has type 'int'
> 
> Squelch this by preferring the %d format specifier to print 1/0 values.
> 
> Fixes: 74c4530dca93 ("ofproto-dpif: Don't slow-path controller actions
> with pause.")
> Cc: Justin Pettit <jpettit@ovn.org>
> Signed-off-by: Aaron Conole <aconole@bytheb.org>
> ---
> v1->v2: instead of using a cast, use a different format string.
> 

Acked-by: Ian Stokes <ian.stokes@intel.com>
Tested-by: Ian Stokes <ian.stokes@intel.com>

>  lib/odp-util.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/odp-util.c b/lib/odp-util.c index af995efca..8a5e9e82e
> 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -481,8 +481,8 @@ format_odp_userspace_action(struct ds *ds, const
> struct nlattr *attr,
>                  ds_put_char(ds, ')');
>              } else if (cookie.type == USER_ACTION_COOKIE_CONTROLLER) {
>                  ds_put_format(ds, ",controller(reason=%"PRIu16
> -                              ",dont_send=%"PRIu8
> -                              ",continuation=%"PRIu8
> +                              ",dont_send=%d"
> +                              ",continuation=%d"
>                                ",recirc_id=%"PRIu32
>                                ",rule_cookie=%#"PRIx64
>                                ",controller_id=%"PRIu16
> --
> 2.14.3
Justin Pettit Jan. 17, 2018, 9:45 p.m. UTC | #2
Thanks for the fix.  I'd like to add the compiler to the description, since I didn't see it on gcc 5.4.0.

--Justin


> On Jan 16, 2018, at 6:05 AM, Aaron Conole <aconole@bytheb.org> wrote:
> 
> The result of a ternary operation will be promoted at least to int
> type.  As such, the compiler may generate a warning as:
>  format specifies type 'unsigned char' but the argument has type 'int'
> 
> Squelch this by preferring the %d format specifier to print 1/0 values.
> 
> Fixes: 74c4530dca93 ("ofproto-dpif: Don't slow-path controller actions with pause.")
> Cc: Justin Pettit <jpettit@ovn.org>
> Signed-off-by: Aaron Conole <aconole@bytheb.org>
> ---
> v1->v2: instead of using a cast, use a different format string.
> 
> lib/odp-util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/odp-util.c b/lib/odp-util.c
> index af995efca..8a5e9e82e 100644
> --- a/lib/odp-util.c
> +++ b/lib/odp-util.c
> @@ -481,8 +481,8 @@ format_odp_userspace_action(struct ds *ds, const struct nlattr *attr,
>                 ds_put_char(ds, ')');
>             } else if (cookie.type == USER_ACTION_COOKIE_CONTROLLER) {
>                 ds_put_format(ds, ",controller(reason=%"PRIu16
> -                              ",dont_send=%"PRIu8
> -                              ",continuation=%"PRIu8
> +                              ",dont_send=%d"
> +                              ",continuation=%d"
>                               ",recirc_id=%"PRIu32
>                               ",rule_cookie=%#"PRIx64
>                               ",controller_id=%"PRIu16
> -- 
> 2.14.3
>
Aaron Conole Jan. 18, 2018, 7:01 p.m. UTC | #3
Justin Pettit <jpettit@ovn.org> writes:

> Thanks for the fix.  I'd like to add the compiler to the description,
> since I didn't see it on gcc 5.4.0.

Will do.  This was observed on osx with clang.

The version string from clang --version:

  Apple LLVM version 8.1.0 (clang-802.0.42)

I'll spin a v3 with this information.

> --Justin
>
>
>> On Jan 16, 2018, at 6:05 AM, Aaron Conole <aconole@bytheb.org> wrote:
>> 
>> The result of a ternary operation will be promoted at least to int
>> type.  As such, the compiler may generate a warning as:
>>  format specifies type 'unsigned char' but the argument has type 'int'
>> 
>> Squelch this by preferring the %d format specifier to print 1/0 values.
>> 
>> Fixes: 74c4530dca93 ("ofproto-dpif: Don't slow-path controller actions with pause.")
>> Cc: Justin Pettit <jpettit@ovn.org>
>> Signed-off-by: Aaron Conole <aconole@bytheb.org>
>> ---
>> v1->v2: instead of using a cast, use a different format string.
>> 
>> lib/odp-util.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/lib/odp-util.c b/lib/odp-util.c
>> index af995efca..8a5e9e82e 100644
>> --- a/lib/odp-util.c
>> +++ b/lib/odp-util.c
>> @@ -481,8 +481,8 @@ format_odp_userspace_action(struct ds *ds, const struct nlattr *attr,
>>                 ds_put_char(ds, ')');
>>             } else if (cookie.type == USER_ACTION_COOKIE_CONTROLLER) {
>>                 ds_put_format(ds, ",controller(reason=%"PRIu16
>> -                              ",dont_send=%"PRIu8
>> -                              ",continuation=%"PRIu8
>> +                              ",dont_send=%d"
>> +                              ",continuation=%d"
>>                               ",recirc_id=%"PRIu32
>>                               ",rule_cookie=%#"PRIx64
>>                               ",controller_id=%"PRIu16
>> -- 
>> 2.14.3
>>
Justin Pettit Jan. 18, 2018, 7:02 p.m. UTC | #4
> On Jan 18, 2018, at 11:01 AM, Aaron Conole <aconole@bytheb.org> wrote:
> 
> Justin Pettit <jpettit@ovn.org> writes:
> 
>> Thanks for the fix.  I'd like to add the compiler to the description,
>> since I didn't see it on gcc 5.4.0.
> 
> Will do.  This was observed on osx with clang.
> 
> The version string from clang --version:
> 
>  Apple LLVM version 8.1.0 (clang-802.0.42)
> 
> I'll spin a v3 with this information.

Don't worry about that.  I can just integrate it into v2.  Thanks for the info!

--Justin
Justin Pettit Jan. 18, 2018, 9:12 p.m. UTC | #5
> On Jan 18, 2018, at 11:01 AM, Aaron Conole <aconole@bytheb.org> wrote:
> 
> Justin Pettit <jpettit@ovn.org> writes:
> 
>> Thanks for the fix.  I'd like to add the compiler to the description,
>> since I didn't see it on gcc 5.4.0.
> 
> Will do.  This was observed on osx with clang.
> 
> The version string from clang --version:
> 
>  Apple LLVM version 8.1.0 (clang-802.0.42)

Thanks, Aaron and Ian.  I pushed this to master and branch-2.9.

--Justin

Patch
diff mbox series

diff --git a/lib/odp-util.c b/lib/odp-util.c
index af995efca..8a5e9e82e 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -481,8 +481,8 @@  format_odp_userspace_action(struct ds *ds, const struct nlattr *attr,
                 ds_put_char(ds, ')');
             } else if (cookie.type == USER_ACTION_COOKIE_CONTROLLER) {
                 ds_put_format(ds, ",controller(reason=%"PRIu16
-                              ",dont_send=%"PRIu8
-                              ",continuation=%"PRIu8
+                              ",dont_send=%d"
+                              ",continuation=%d"
                               ",recirc_id=%"PRIu32
                               ",rule_cookie=%#"PRIx64
                               ",controller_id=%"PRIu16