zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.04k stars 6.18k forks source link

[BUG] Compilation errors in "LVGL common input" on multiple instances of same node class #75443

Open rexut opened 3 days ago

rexut commented 3 days ago

This bug was introduced with PR #62757.

https://github.com/zephyrproject-rtos/zephyr/blob/ec601b89df93ee0054c9317e80974a924b65e332/modules/lvgl/input/lvgl_common_input.c#L76

In the case of multiple instantiation and thus multiple extraction of the macro LV_DEV_INIT(), the missing semicolon after the do-while loop leads to compilation errors

.../zephyr/modules/lvgl/input/lvgl_common_input.c: In function 'lvgl_init_input_devices':
.../zephyr/modules/lvgl/input/lvgl_common_input.c:71:9: error: expected ';' before 'do'
   71 |         do {                                                                       \
      |         ^~

For example with such kind of DTS snippets:

… … …
lvgl_axis_x_keypad: lvgl-axis-x-keypad {
    compatible = "zephyr,lvgl-keypad-input";
    input = <&joystick_axis_x_keys>;
    input-codes = <INPUT_KEY_LEFT INPUT_KEY_RIGHT>;
    lvgl-codes = <LV_KEY_LEFT LV_KEY_RIGHT>;
};
… … … 
lvgl_axis_y_keypad: lvgl-axis-y-keypad {
    compatible = "zephyr,lvgl-keypad-input";
    input = <&joystick_axis_y_keys>;
    input-codes = <INPUT_KEY_UP INPUT_KEY_DOWN>;
    lvgl-codes = <LV_KEY_UP LV_KEY_DOWN>;
};
… … …

To complete the small DTS example, the two phandles joystick_axis_x_keys and joystick_axis_y_keys are adc-keys nodes (hardware-specific properties are not shown):

… … …
joystick_axis_x_keys: joystick-axis-x-keys {
    compatible = "adc-keys";
    joystick_axis_x_key_0: joystick_axis_x_key_0 {
        zephyr,code = <INPUT_KEY_LEFT>;
    };
    joystick_axis_x_key_1: joystick_axis_x_key_1 {
        zephyr,code = <INPUT_KEY_RIGHT>;
    };
};
… … …
joystick_axis_y_keys: joystick-axis-y-keys {
    compatible = "adc-keys";
    joystick_axis_y_key_0: joystick_axis_y_key_0 {
        zephyr,code = <INPUT_KEY_DOWN>;
    };
    joystick_axis_y_key_1: joystick_axis_y_key_1 {
        zephyr,code = <INPUT_KEY_UP>;
    };
};
… … …
henrikbrixandersen commented 3 days ago

Please use our bug template when reporting bugs. You need to edit this issue to include the information requested in https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/001_bug_report.md

rexut commented 3 days ago

Please use our bug template when reporting bugs. You need to edit this issue to include the information requested in https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/001_bug_report.md

Thanks for pointing that out - I'm familiar with it. For this very very small bug with a simple one liner patch, I choose to ignore it - I found the template for it a little overloaded.