diff mbox

[Trusty,SRU,2/3] cpumask.h: silence warning with -Wsign-compare

Message ID 1402601042-15487-2-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner June 12, 2014, 7:24 p.m. UTC
From: Brian W Hart <hartb@linux.vnet.ibm.com>

BugLink: http://bugs.launchpad.net/bugs/1321791

Silence the warning when building with -Wsign-compare when cpumask.h
is included:

include/linux/cpumask.h: In function ‘cpumask_parse’:
include/linux/cpumask.h:603:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
  int len = nl ? nl - buf : strlen(buf);
                          ^

V2: Rusty pointed out that unsigned should be used instead.

Signed-off-by: Brian W Hart <hartb@linux.vnet.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(cherry picked from commit cea092c9488cbb22c8b70336ab1413e0daf350f0)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 include/linux/cpumask.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Brad Figg June 12, 2014, 7:35 p.m. UTC | #1
On 06/12/2014 12:24 PM, Tim Gardner wrote:
> From: Brian W Hart <hartb@linux.vnet.ibm.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1321791
> 
> Silence the warning when building with -Wsign-compare when cpumask.h
> is included:
> 
> include/linux/cpumask.h: In function ‘cpumask_parse’:
> include/linux/cpumask.h:603:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
>   int len = nl ? nl - buf : strlen(buf);
>                           ^
> 
> V2: Rusty pointed out that unsigned should be used instead.
> 
> Signed-off-by: Brian W Hart <hartb@linux.vnet.ibm.com>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> (cherry picked from commit cea092c9488cbb22c8b70336ab1413e0daf350f0)
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  include/linux/cpumask.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index d08e4d2..3557ea7 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -600,7 +600,7 @@ static inline int cpulist_scnprintf(char *buf, int len,
>  static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
>  {
>  	char *nl = strchr(buf, '\n');
> -	int len = nl ? nl - buf : strlen(buf);
> +	unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
>  
>  	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
>  }
>
diff mbox

Patch

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index d08e4d2..3557ea7 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -600,7 +600,7 @@  static inline int cpulist_scnprintf(char *buf, int len,
 static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
 {
 	char *nl = strchr(buf, '\n');
-	int len = nl ? nl - buf : strlen(buf);
+	unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
 
 	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
 }