summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-10 16:20:58 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-03 11:02:11 -0800
commite6821a8a7b16e5a8e4c478c9544798fae59a21d1 (patch)
tree80bdbd72a5ff3d4becaec1990281735a159c7fdb
parent81e46cab5f4bdd69fa0a644dba86f6902cece175 (diff)
downloadxorg-app-xkbcomp-e6821a8a7b16e5a8e4c478c9544798fae59a21d1.tar.gz
Handle -Wstringop-truncation warning in HandleOverlayDef()
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 <alan.coopersmith@oracle.com>
-rw-r--r--geometry.c4
1 files 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,