nasa / to_lab

The Core Flight System (cFS) Telemetry Output Lab App (to_lab)
Apache License 2.0
26 stars 41 forks source link

string_variable[] initializer-string is too long #137

Closed thnkslprpt closed 1 year ago

thnkslprpt commented 2 years ago

Checklist

Describe the bug string_variable[] in TO_LAB_SendDataTypes() is initialized with a 10-character-long string literal: https://github.com/nasa/to_lab/blob/9e2ad8cccafaad6d09902213971344d9e277e9f9/fsw/src/to_lab_app.c#L381 However, the compiler will add on a terminating null character \0 as an additional (11th) character. string_variable is later used as an array (not a string) where it is fine, obviously, to utilize all 10 of the array elements. Nevertheless, it is still not ideal to have the array declared with a string literal that is too long (including the automatically added terminating null character) for its container.

Expected behavior char string_variable[10] = "ABCDEFGHI";

Alternative would be to just leave it uninitialized...

Reporter Info Avi Weiss @thnkslprpt