mirror of https://github.com/PentHertz/srsLTE.git
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:
parent
31673d1797
commit
0aff9d9d26
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue