Skip to contentSkip to conversation

data: Clean up expandKeys None value handling

PATCH In review Richard Purdie 2 participants 2 messages May 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 data: Clean up expandKeys None value handling

This comparison is interesting even in the case of empty vales. Enabling this warning actually found a bug in the metadata in avahi. Make the code handle None specifically and also remove the dead code path in the second if statement.

bitbake/lib/bb/data.py +2 -2
index 0d9da4c..e7557aa 100644
@@ -157,9 +157,9 @@ def expandKeys(alterdata, readdata = None):
             continue
         todolist[key] = ekey
         newval = alterdata.getVar(ekey, 0)
-        if newval:
+        if newval is not None:
             val = alterdata.getVar(key, 0)
-            if val is not None and newval is not None:
+            if val is not None:
                 bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
 
     # These two for loops are split for performance to maximise the
#1 lore raw
Quoted 5 lines · Richard Purdie

This comparison is interesting even in the case of empty vales. Enabling
this warning actually found a bug in the metadata in avahi. Make the code handle None specifically and also remove the dead code path in the second if statement.

LGTM, but I cannot approve it.
Thanks for the fix!

Cheers,

Quoted 20 lines
bitbake/lib/bb/data.py +2 -2
index 0d9da4c..e7557aa 100644
@@ -157,9 +157,9 @@ def expandKeys(alterdata, readdata = None):
            continue
        todolist[key] = ekey
        newval = alterdata.getVar(ekey, 0)
-        if newval:
+        if newval is not None:
            val = alterdata.getVar(key, 0)
-            if val is not None and newval is not None:
+            if val is not None:
 bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key,
 val, ekey, newval))
 

# These two for loops are split for performance to maximise the