Page MenuHomeWildfire Games

Fix FileIo.cpp gcc 8 compile warning about strncpy use without copying the null-termination [-Wstringop-truncation]
ClosedPublic

Authored by elexis on Aug 7 2019, 5:25 PM.

Details

Summary

-Wstringop-truncation was introduced in gcc 8 and it is triggered for one line in the code.
It's not broken, since the \n is intentionally omitted. The warning shall vanish without the warning being disabled though.

Test Plan

Ensure that the code behavior is the same:

This can be achieved by backing up a PMP file, overwriting it in atlas, seeing that the contents didn't change.
Fun fact: If one passes a number smaller than three, then the according substring is copied and the rest of the 4 bytes are zeroes.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Aug 7 2019, 5:25 PM
Vulcan added a comment.Aug 7 2019, 5:30 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/338/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Aug 7 2019, 5:38 PM
This revision was automatically updated to reflect the committed changes.