From 7876ca7acb71c4f1c385997cdfc9dbf12092b0bc Mon Sep 17 00:00:00 2001 From: elexis Date: Wed, 7 Aug 2019 15:38:40 +0000 Subject: [PATCH] Fix gcc 8 compiler warning in FileIo.cpp about truncating use of strncpy [-Wstringop-truncation]. Refs #5294 Differential Revision: https://code.wildfiregames.com/D2159 Tested on: gcc 9, Jenkins This was SVN commit r22626. --- source/ps/FileIo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ps/FileIo.cpp b/source/ps/FileIo.cpp index f8c358e766..0a129c1bf8 100644 --- a/source/ps/FileIo.cpp +++ b/source/ps/FileIo.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -47,7 +47,7 @@ CFilePacker::CFilePacker(u32 version, const char magic[4]) // put header in our data array. // (its payloadSize_le will be updated on every Pack*() call) FileHeader header; - strncpy(header.magic, magic, 4); // not 0-terminated => no _s + std::copy(magic, magic + 4, header.magic); write_le32(&header.version_le, version); write_le32(&header.payloadSize_le, 0); m_writeBuffer.Append(&header, sizeof(FileHeader));