fix -Wstringop-trunc in phy_common helper

gcc8 added a -Wstringop-truncation warning that flags
an issue in phy_common because we are copying a str
to another str without explicitly saying it's null-terminated.

we could turn off the warning using a pragma in the code
but I guess it's safe to just null-terminate after
copying manually

[1] https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice
This commit is contained in:
Andre Puschmann 2020-03-02 18:20:55 +01:00 committed by Xavier Arteaga
parent 31673d1797
commit 0aff9d9d26
1 changed files with 4 additions and 2 deletions

View File

@ -872,11 +872,13 @@ const char* srslte_ack_nack_feedback_mode_string(srslte_ack_nack_feedback_mode_t
srslte_ack_nack_feedback_mode_t srslte_string_ack_nack_feedback_mode(const char* str)
{
#define MAX_STR_LEN (8)
int i = 0;
char str2[8] = {};
char str2[MAX_STR_LEN] = {};
// Copy string in local buffer
strncpy(str2, str, sizeof(str2));
strncpy(str2, str, MAX_STR_LEN - 1);
str2[MAX_STR_LEN - 1] = '\0';
// Convert to lower case
while (str2[i] |= ' ', str2[++i])