Openembedded Devel Discussions
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-devel@lists.openembedded.org
Subject: Re: [PATCH] base.bbclass: in base_contains, check for var existance before using it
Date: Mon, 18 Jan 2010 11:59:49 -0800	[thread overview]
Message-ID: <20100118195949.GB31712@gmail.com> (raw)
In-Reply-To: <1263577018-9627-1-git-send-email-clarson@mvista.com>

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



  reply	other threads:[~2010-01-18 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2010-01-26 15:49 ` Marcin Juszkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100118195949.GB31712@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox