gcc8 and Wstringop-truncation

gcc8 introduced a new warning (Wstringop-truncation) which in our case
is being treated as error.
Disabling the warning globally might introduce bugs related to string
truncation which are not desired by the developer (e.g. bug).
Instead, this patch disables the warning only for those occurences
which have been verified to be non-bugs but the desired behaviour as per
developer will.

Change-Id: I0f04ff6b4fad44061e80a65af633fd7e0148a0c5
Signed-off-by: Marco Varlese <marco.varlese@suse.com>
This commit is contained in:
Marco Varlese
2018-06-27 09:54:44 +02:00
committed by Dave Barach
parent c5ee4fd4aa
commit 99d7a72cbc
4 changed files with 13 additions and 9 deletions

View File

@ -109,9 +109,8 @@ vl_api_get_first_msg_id_t_handler (vl_api_get_first_msg_id_t * mp)
if (am->msg_range_by_name == 0)
goto out;
strncpy ((char *) name, (char *) mp->name, ARRAY_LEN (name) - 1);
strncpy ((char *) name, (char *) mp->name, ARRAY_LEN (name));
name[ARRAY_LEN (name) - 1] = '\0';
p = hash_get_mem (am->msg_range_by_name, name);
if (p == 0)
goto out;
@ -157,7 +156,10 @@ vl_api_api_versions_t_handler (vl_api_api_versions_t * mp)
rmp->api_versions[i].major = htonl (vl->major);
rmp->api_versions[i].minor = htonl (vl->minor);
rmp->api_versions[i].patch = htonl (vl->patch);
strncpy ((char *) rmp->api_versions[i].name, vl->name, 64 - 1);
strncpy ((char *) rmp->api_versions[i].name, vl->name,
ARRAY_LEN (rmp->api_versions[i].name));
rmp->api_versions[i].name[ARRAY_LEN (rmp->api_versions[i].name) - 1] =
'\0';
}
vl_api_send_msg (reg, (u8 *) rmp);