All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] base.bbclass: in base_contains, check for var existance before using it
@ 2010-01-15 17:36 Chris Larson
  2010-01-18 19:59 ` Khem Raj
  2010-01-26 15:49 ` Marcin Juszkiewicz
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Larson @ 2010-01-15 17:36 UTC (permalink / raw)
  To: openembedded-devel

From: Brian Pomerantz <bapper@mvista.com>

When using base_contains() to check for a string in a variable for a,
if the variable is not defined an exception occurs.  By checking the
existance of the variable and returning false if it isn't there,
a value can be checked for a variable regardless of whether or not it
is defined.

Signed-off-by: Brian Pomerantz <bapper@mvista.com>
Signed-off-by: Chris Larson <clarson@mvista.com>
---
 classes/base.bbclass |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index 384a67d..f67773a 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -226,14 +226,17 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
         return falsevalue
 
 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
+	val = bb.data.getVar(variable,d,1)
+	if not val:
+		return falsevalue
 	matches = 0
 	if type(checkvalues).__name__ == "str":
 		checkvalues = [checkvalues]
 	for value in checkvalues:
-		if bb.data.getVar(variable,d,1).find(value) != -1:	
+		if val.find(value) != -1:
 			matches = matches + 1
 	if matches == len(checkvalues):
-		return truevalue		
+		return truevalue
 	return falsevalue
 
 def base_both_contain(variable1, variable2, checkvalue, d):
-- 
1.6.4.339.g527d




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] base.bbclass: in base_contains, check for var existance before using it
  2010-01-15 17:36 [PATCH] base.bbclass: in base_contains, check for var existance before using it Chris Larson
@ 2010-01-18 19:59 ` Khem Raj
  2010-01-26 15:49 ` Marcin Juszkiewicz
  1 sibling, 0 replies; 3+ messages in thread
From: Khem Raj @ 2010-01-18 19:59 UTC (permalink / raw)
  To: openembedded-devel

On (15/01/10 10:36), Chris Larson wrote:
> From: Brian Pomerantz <bapper@mvista.com>
> 
> When using base_contains() to check for a string in a variable for a,
> if the variable is not defined an exception occurs.  By checking the
> existance of the variable and returning false if it isn't there,
> a value can be checked for a variable regardless of whether or not it
> is defined.
> 
> Signed-off-by: Brian Pomerantz <bapper@mvista.com>
> Signed-off-by: Chris Larson <clarson@mvista.com>

Acked-by: Khem Raj <raj.khem@gmail.com>


> ---
>  classes/base.bbclass |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/classes/base.bbclass b/classes/base.bbclass
> index 384a67d..f67773a 100644
> --- a/classes/base.bbclass
> +++ b/classes/base.bbclass
> @@ -226,14 +226,17 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
>          return falsevalue
>  
>  def base_contains(variable, checkvalues, truevalue, falsevalue, d):
> +	val = bb.data.getVar(variable,d,1)
> +	if not val:
> +		return falsevalue
>  	matches = 0
>  	if type(checkvalues).__name__ == "str":
>  		checkvalues = [checkvalues]
>  	for value in checkvalues:
> -		if bb.data.getVar(variable,d,1).find(value) != -1:	
> +		if val.find(value) != -1:
>  			matches = matches + 1
>  	if matches == len(checkvalues):
> -		return truevalue		
> +		return truevalue
>  	return falsevalue
>  
>  def base_both_contain(variable1, variable2, checkvalue, d):
> -- 
> 1.6.4.339.g527d
> 
> 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] base.bbclass: in base_contains, check for var existance before using it
  2010-01-15 17:36 [PATCH] base.bbclass: in base_contains, check for var existance before using it Chris Larson
  2010-01-18 19:59 ` Khem Raj
@ 2010-01-26 15:49 ` Marcin Juszkiewicz
  1 sibling, 0 replies; 3+ messages in thread
From: Marcin Juszkiewicz @ 2010-01-26 15:49 UTC (permalink / raw)
  To: openembedded-devel

[-- Attachment #1: Type: Text/Plain, Size: 736 bytes --]

Dnia piątek, 15 stycznia 2010 o 18:36:58 Chris Larson napisał(a):
> From: Brian Pomerantz <bapper@mvista.com>
> 
> When using base_contains() to check for a string in a variable for a,
> if the variable is not defined an exception occurs.  By checking the
> existance of the variable and returning false if it isn't there,
> a value can be checked for a variable regardless of whether or not it
> is defined.
> 
> Signed-off-by: Brian Pomerantz <bapper@mvista.com>
> Signed-off-by: Chris Larson <clarson@mvista.com>

Acked-by: Marcin Juszkiewicz <marcin@juszkiewicz.com.pl>


Regards, 
-- 
JID:      hrw@jabber.org
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-01-26 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-15 17:36 [PATCH] base.bbclass: in base_contains, check for var existance before using it Chris Larson
2010-01-18 19:59 ` Khem Raj
2010-01-26 15:49 ` Marcin Juszkiewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.