Skip to content

Fix gitversion array size to include null terminator#7

Closed
edsammy wants to merge 1 commit intorichiefrom
fix/gitversion-null-terminator
Closed

Fix gitversion array size to include null terminator#7
edsammy wants to merge 1 commit intorichiefrom
fix/gitversion-null-terminator

Conversation

@edsammy
Copy link
Copy Markdown

@edsammy edsammy commented Feb 15, 2026

Fixes build error with newer GCC versions that enforce null terminator space in string arrays.

Matches upstream fix from commaai#2309.

@heysenbug
Copy link
Copy Markdown

Which GCC version is this a fix for?

@edsammy
Copy link
Copy Markdown
Author

edsammy commented Feb 15, 2026

From downquark7

Including space for the null terminator in this string fixes a warning that was not added to gcc until version 15. Compile code with gcc version 15 to reproduce this error.

After running setup.sh arm-none-eabi-gcc got upgraded to 15.2.1 20251203 and was causing the following error on board builds

In file included from board/bootstub.c:18:
./board/obj/gitversion.h:2:32: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (19 chars into 18 available) [-Werror=unterminated-string-initialization]
    2 | const uint8_t gitversion[18] = "DEV-395acfb9-DEBUG";
      |                                ^~~~~~~~~~~~~~~~~~~~
In file included from board/bootstub.c:18:
./board/obj/gitversion.h:2:32: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (19 chars into 18 available) [-Werror=unterminated-string-initialization]
    2 | const uint8_t gitversion[18] = "DEV-395acfb9-DEBUG";
      |                                ^~~~~~~~~~~~~~~~~~~~
In file included from board/jungle/main.c:20:
./board/obj/gitversion.h:2:32: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (19 chars into 18 available) [-Werror=unterminated-string-initialization]
    2 | const uint8_t gitversion[18] = "DEV-395acfb9-DEBUG";
      |                                ^~~~~~~~~~~~~~~~~~~~
In file included from board/main.c:23:
./board/obj/gitversion.h:2:32: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (19 chars into 18 available) [-Werror=unterminated-string-initialization]
    2 | const uint8_t gitversion[18] = "DEV-395acfb9-DEBUG";
    ```

@heysenbug heysenbug closed this Feb 15, 2026
@heysenbug
Copy link
Copy Markdown

Addressed in #8

@edsammy edsammy deleted the fix/gitversion-null-terminator branch February 18, 2026 02:04
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.

2 participants