Skip to contentSkip to conversation

bitbake.conf: fix suspicious comparison with ('' or 'custom')

PATCH In review Masahiro Yamada 2 participants 2 messages Dec 22, 2019 – Dec 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake.conf: fix suspicious comparison with ('' or 'custom')

I am not sure what is intended by the code:

    d.getVar('TARGET_OS', d, 1) == ('' or 'custom')

This is equivalent to:

    d.getVar('TARGET_OS', d, 1) == 'custom'

If the intended behavior is to take the second element of the array when TARGET_OS is empty or 'custom', the correct code would be:

    d.getVar('TARGET_OS', d, 1) == '' or
    d.getVar('TARGET_OS', d, 1) == 'custom'

Or, more simply:

    d.getVar('TARGET_OS', d, 1) in ('', 'custom')

I guess this is probably the intended behavior.

---

 meta/conf/bitbake.conf | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/conf/bitbake.conf +2 -2
index e75bbcece0..7dc446b9a4 100644
@@ -129,7 +129,7 @@ SDKUSE_NLS ??= "yes"
 TARGET_ARCH = "${TUNE_ARCH}"
 TARGET_OS = "linux${LIBCEXTENSION}${ABIEXTENSION}"
 TARGET_VENDOR = "-oe"
-TARGET_SYS = "${TARGET_ARCH}${TARGET_VENDOR}${@['-' + d.getVar('TARGET_OS'), ''][d.getVar('TARGET_OS') == ('' or 'custom')]}"
+TARGET_SYS = "${TARGET_ARCH}${TARGET_VENDOR}${@['-' + d.getVar('TARGET_OS'), ''][d.getVar('TARGET_OS') in ('', 'custom')]}"
 TARGET_PREFIX = "${TARGET_SYS}-"
 TARGET_CC_ARCH = "${TUNE_CCARGS}"
 TARGET_LD_ARCH = "${TUNE_LDARGS}"
@@ -138,7 +138,7 @@ TARGET_AS_ARCH = "${TUNE_ASARGS}"
 SDKMACHINE ??= "x86_64"
 SDK_OS = "${BUILD_OS}"
 SDK_VENDOR = "-oesdk"
-SDK_SYS = "${SDK_ARCH}${SDK_VENDOR}${@['-' + d.getVar('SDK_OS'), ''][d.getVar('SDK_OS') == ('' or 'custom')]}"
+SDK_SYS = "${SDK_ARCH}${SDK_VENDOR}${@['-' + d.getVar('SDK_OS'), ''][d.getVar('SDK_OS') in ('', 'custom')]}"
 SDK_PREFIX = "${SDK_SYS}-"
 SDK_CC_ARCH = "${BUILD_CC_ARCH}"
 SDKPKGSUFFIX = "nativesdk"
Signature · 1 line
2.17.1
#1 lore raw
Quoted 14 lines · Masahiro Yamada

I am not sure what is intended by the code:

    d.getVar('TARGET_OS', d, 1) == ('' or 'custom')

This is equivalent to:

    d.getVar('TARGET_OS', d, 1) == 'custom'

If the intended behavior is to take the second element of the array when TARGET_OS is empty or 'custom', the correct code would be:

    d.getVar('TARGET_OS', d, 1) == '' or
    d.getVar('TARGET_OS', d, 1) == 'custom'
Quoted 8 lines

Or, more simply:

    d.getVar('TARGET_OS', d, 1) in ('', 'custom')

I guess this is probably the intended behavior.

---

Thanks for spotting this. Given this doesn't seem useful, I'm going to test a patch going one step further and removing all this indirection. I can't what use it has...

Cheers,

Richard