Skip to content

UART: Fix maybe-uninitialized diagnostic#685

Merged
tannewt merged 1 commit into
adafruit:masterfrom
jepler:uart-diagnostic
Mar 20, 2018
Merged

UART: Fix maybe-uninitialized diagnostic#685
tannewt merged 1 commit into
adafruit:masterfrom
jepler:uart-diagnostic

Conversation

@jepler
Copy link
Copy Markdown

@jepler jepler commented Mar 20, 2018

The following error occurs when building with gcc 5.4.1 (debian stretch) while building the atmel-samd port:

common-hal/busio/UART.c:104:83: error: 'sercom_index' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                   sercom_insts[rx->sercom[j].index]->USART.CTRLA.bit.ENABLE == 0) ||

It may be related to the addition of rx-only UARTs; gcc is unable
to infer the intended relationship between have_tx and sercom_index
being set (I am still not entirely confident of it myself)

The following error occurs when building with gcc 5.4.1 (debian stretch):

common-hal/busio/UART.c:104:83: error: 'sercom_index' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                   sercom_insts[rx->sercom[j].index]->USART.CTRLA.bit.ENABLE == 0) ||

It may be related to the addition of rx-only UARTs; gcc is unable
to infer the intended relationship between have_tx and sercom_index
being set (I am still not entirely confident of it myself)
@dhalbert
Copy link
Copy Markdown
Collaborator

This diagnostic does not appear in gcc 7.3.1 (see my comment in #686 re our build choices), probably due to better flow analysis in the later version of the compiler.

@tannewt tannewt self-requested a review March 20, 2018 16:58
Copy link
Copy Markdown
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

This is fine with me even though we don't need it for later compilers. Thanks for the PR!

@tannewt tannewt merged commit 0f90f35 into adafruit:master Mar 20, 2018
@jepler jepler deleted the uart-diagnostic branch March 23, 2018 01:25
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.

3 participants