Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various: Enclose string if checks in quotes #11617

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

nordicjm
Copy link
Contributor

@nordicjm nordicjm commented Jun 26, 2023

Fixes possible issues whereby string variables are checked without being properly encased in quote marks.

This is needed because unescaped variables will be treated as variable names, then errors will be emitted when they are dereferenced and those variables do not exist.

An example of what happens with bad code when configuring a build:

   *************************
   * Running CMake for ncp *
   *************************

CMake Error at CMakeLists.txt:10 (if):
  if given arguments:

    "STREQUAL" "nrf52840dongle_nrf52840"

  Unknown arguments specified


-- Configuring incomplete, errors occurred!
CMake Error at cmake/modules/sysbuild_extensions.cmake:405 (message):
  CMake configure failed for Zephyr project: ncp

@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Jun 26, 2023
@nordicjm nordicjm requested review from tejlmand and removed request for maje-emb and vili-nordic June 26, 2023 14:25
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Jun 26, 2023

Test specification

CI/Jenkins/NRF

  • Integration Platforms

CI/Jenkins/integration

Test Module File based changes Manually selected West overwrite
desktop52_verification X
test-ci-nrfconnect-boot-fw-update X
test-fw-nrfconnect-ble X
test-fw-nrfconnect-ble_samples X
test-fw-nrfconnect-chip X
test-fw-nrfconnect-nrf-iot_zephyr_lwm2m X
test-fw-nrfconnect-nrf_crypto X
test-fw-nrfconnect-tfm X
test-fw-nrfconnect-zigbee X
test-sdk-find-my X
test-sdk-homekit X

Detailed information of selected test modules

Note: This message is automatically posted and updated by the CI

@Damian-Nordic
Copy link
Contributor

Could you improve the PR description? That is, what kind of issues this might cause? At least I wasn't aware this might be wrong so would like to learn something :)

@@ -14,7 +14,7 @@ set(APPLICATION_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/configuration/\${BOARD}"
set(multiprotocol_rpmsg_KCONFIG_ROOT "\\\${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/chip-module/Kconfig.multiprotocol_rpmsg.root")
set(hci_rpmsg_KCONFIG_ROOT "\\\${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.root")

if(OVERLAY_CONFIG STREQUAL "overlay-factory_data.conf")
if("${OVERLAY_CONFIG}" STREQUAL "overlay-factory_data.conf")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all of them are issues, it is the ones using variables outside of quotes that are issues, I've updated the rest so that the style throughout the code remains uniform.

@nordicjm
Copy link
Contributor Author

@Damian-Nordic I have added a description and example to the original message.

Copy link
Contributor

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks good to me, but could you explain in the commit message why this is necessary? Right now it is not clear to me, and I'd like to understand it. Thanks!

@nordicjm nordicjm requested a review from carlescufi July 17, 2023 08:22
@nordicjm nordicjm force-pushed the zigfix branch 2 times, most recently from 79ede0e to 0ccd0ac Compare July 17, 2023 08:28
Copy link
Contributor

@KAGA164 KAGA164 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It even fixes some CI toolchain issues

samples/bluetooth/direct_test_mode/CMakeLists.txt Outdated Show resolved Hide resolved
samples/peripheral/radio_test/CMakeLists.txt Outdated Show resolved Hide resolved
@frkv
Copy link
Contributor

frkv commented Jul 21, 2023

will the IN_LIST => IN LISTS issue be resolved? it looks like an actual error

@nordicjm
Copy link
Contributor Author

will the IN_LIST => IN LISTS issue be resolved? it looks like an actual error

IN_LIST is the correct command, IN_LISTS does not exist, as per https://cmake.org/cmake/help/v3.3/command/if.html

@KAGA164
Copy link
Contributor

KAGA164 commented Jul 25, 2023

@nordicjm @frkv

will the IN_LIST => IN LISTS issue be resolved? it looks like an actual error

IN_LIST is the correct command, IN_LISTS does not exist, as per https://cmake.org/cmake/help/v3.3/command/if.html

We have foreach statement here not if. https://cmake.org/cmake/help/v3.3/command/foreach.html

Fixes possible issues whereby string variables are checked
without being properly encased in quote marks. This is needed
because unescaped variables will be treated as variable names,
then errors will be emitted when they are dereferenced and those
variables do not exist. This fixes issue like the following:

       *************************
       * Running CMake for ncp *
       *************************
    CMake Error at CMakeLists.txt:10 (if):
      if given arguments:
        "STREQUAL" "nrf52840dongle_nrf52840"
      Unknown arguments specified

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
@frkv
Copy link
Contributor

frkv commented Jul 25, 2023

will the IN_LIST => IN LISTS issue be resolved? it looks like an actual error

IN_LIST is the correct command, IN_LISTS does not exist, as per https://cmake.org/cmake/help/v3.3/command/if.html

IN LISTS is not with an underscore, and this is not an if-statement.

Copy link
Contributor

@frkv frkv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@carlescufi carlescufi merged commit 6f4c69d into nrfconnect:main Jul 26, 2023
@nordicjm nordicjm deleted the zigfix branch September 25, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants