Page MenuHomeWildfire Games

Rewrite AtlasObjectXML.cpp to remove compiler warnings
AbandonedPublic

Authored by eecsninja on Apr 4 2018, 8:06 PM.

Details

Reviewers
wraitii
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

The case statement fall-through generates a lot of compiler warnings during build.

This patch rewrites the conversion code to use while loops instead of switch/case statements.

This is my first commit. Added myself to the contributors list.

Test Plan

Ran tests and they passed.
Verified that tests fail when the code is incorrectly written.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
master
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 5760
Build 9663: arc lint + arc unit

Event Timeline

eecsninja created this revision.Apr 4 2018, 8:06 PM
Owners added subscribers: Restricted Owners Package, Restricted Owners Package.Apr 4 2018, 8:06 PM
elexis added a subscriber: elexis.Apr 4 2018, 8:10 PM

See rP20095 for a FALLTHROUGH statement.

But your code also looks cleaner without the switch to begin with (deduplication).

Which compiler did you use - I don't recall anyone reporting compile warnings on this file.

I used x86_64-linux-gnu-gcc-7.

In rP20095, the description mentions that AtlasObjectXML still has compiler warnings and suggests that it should be fixed.

Stan added reviewers: Restricted Owners Package, Restricted Owners Package.Apr 4 2018, 8:34 PM

Could you attach your warnings?

The attached file contains the warnings that this patch removes:

Itms removed a reviewer: Restricted Owners Package.Apr 8 2018, 2:25 PM

The modified code was introduced in rP6764.
There we see that CStrW::ToUTF8 had very similar if actually not entirely identical code. Now that function uses utf8_from_wstring in lib/utf8.cpp`.
So perhaps that's something that can be done here as well.

Said identical code was replaced in rP7201.
There we see that even static const char trailingBytesForUTF8[256] = { is copy&pasted and one copy was replaced....

So it looks like this should be fixed by deletion.

source/tools/atlas/AtlasObject/AtlasObjectXML.cpp
93

The assert didn't seem so bad?

elexis added a comment.EditedDec 27 2018, 6:28 PM

The catch was that lib/utf8.h couldn't be included directly.
D1395 removes exactly that duplication.

@s0600204 so this is a "won't fix" and unfortunately must be abandoned? (The patch looked good at first sight otherwise)

elexis abandoned this revision.Dec 31 2018, 11:39 AM

See above. The patch looks good though, so too bad we didn't notice the underlying issues sooner and thanks for the support regardless!