From e6821a8a7b16e5a8e4c478c9544798fae59a21d1 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Dec 2022 16:20:58 -0800 Subject: Handle -Wstringop-truncation warning in HandleOverlayDef() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In function ‘HandleOverlayDef’, inlined from ‘HandleSectionBody’ at geometry.c:2778:18, inlined from ‘HandleSectionDef’ at geometry.c:2818:10, inlined from ‘HandleGeometryFile’ at geometry.c:2864:18: geometry.c:2573:9: warning: ‘strncpy’ output may be truncated copying 4 bytes from a string of length 4 [-Wstringop-truncation] 2573 | strncpy(key->over, keyDef->over, XkbKeyNameLength); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ geometry.c:2574:9: warning: ‘strncpy’ output may be truncated copying 4 bytes from a string of length 4 [-Wstringop-truncation] 2574 | strncpy(key->under, keyDef->under, XkbKeyNameLength); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith --- geometry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geometry.c b/geometry.c index 50df5eb..241f8d9 100644 --- a/geometry.c +++ b/geometry.c @@ -2570,8 +2570,8 @@ HandleOverlayDef(OverlayDef * def, } return False; } - strncpy(key->over, keyDef->over, XkbKeyNameLength); - strncpy(key->under, keyDef->under, XkbKeyNameLength); + strncpy(key->over, keyDef->over, sizeof(key->over)); + strncpy(key->under, keyDef->under, sizeof(key->under)); key->sectionRow = _GOK_UnknownRow; key->overlayRow = _GOK_UnknownRow; ol.keys = (OverlayKeyInfo *) AddCommonInfo(&ol.keys->defs, -- cgit v1.2.3