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

fix(scripts): initialize reserved fields of lv_image_dsc_t and lv_image_header_t to prevent compiler warnings #7799

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sparkles43
Copy link
Contributor

Previously the LVGLImage.py script did not initialize reserved fields of the lv_image_dsc_t and lv_image_header_t. This led to a flood of compiler warnings about uninitialized variables.

This PR sets these variables to zero and NULL respectively.

Copy link
Member

@uLipe uLipe left a comment

Choose a reason for hiding this comment

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

Thanks for the correction, this source of warning could be a pain on projects that promotes warnings to errors.

@lvgl-bot
Copy link

We need some feedback on this pull request.

Now we mark this as "Abandoned" because there was no activity here for 14 days.

Remove the "Abandoned" label or comment else this will be closed in 7 days.

Copy link
Member

@liamHowatt liamHowatt left a comment

Choose a reason for hiding this comment

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

Just had a thought. If we replace these reserved fields someday, they will actually have to be anonymous unions so that old code assigning a value to reserved will still compile.

typedef struct {
    lv_image_header_t header;   /**< A header describing the basics of the image*/
    uint32_t data_size;         /**< Size of the image in bytes*/
    const uint8_t * data;       /**< Pointer to the data of the image*/
    union {const void * reserved; void * some_new_field};
} lv_image_dsc_t;

Copy link
Collaborator

@XuNeo XuNeo left a comment

Choose a reason for hiding this comment

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

I think it would be automatically initialized to zero. https://en.cppreference.com/w/c/language/struct_initialization

If the compiler you used generates warning, then we can do the simple fix.
So looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants