Fix exception warning (patch)

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderators: Committer, Committer

Post Reply
Message
Author
spikethehobbit
Space Squid
Posts: 66
Joined: Mon Aug 27, 2012 7:24 pm

Fix exception warning (patch)

#1 Post by spikethehobbit » Thu Oct 31, 2019 10:55 am

There are nine places where exceptions are caught by value instead of by reference. Attached is a trivial patch to change these to const&.
Attachments
fix-exception-warnings.diff.txt
(3.77 KiB) Downloaded 34 times
All contributions are submitted under GPL or LGPL v2 or later, or under appropriate Creative Commons licence, consistent with project guidlines.

o01eg
Programmer
Posts: 626
Joined: Sat Dec 10, 2011 5:46 am

Re: Fix exception warning (patch)

#2 Post by o01eg » Thu Oct 31, 2019 11:03 am

spikethehobbit wrote:
Thu Oct 31, 2019 10:55 am
There are nine places where exceptions are caught by value instead of by reference. Attached is a trivial patch to change these to const&.
What about to open PR on the Github?
Gentoo Linux x64, gcc-9.2, boost-1.72.0
Ubuntu Server 18.04 x64, gcc-7.4, boost-1.65.1
Welcome to slow multiplayer game at freeorion-lt.dedyn.io. Version 2020-01-26.adf31db 0.4.9 RC2.
Donates are welcome: BTC:14XLekD9ifwqLtZX4iteepvbLQNYVG87zK

spikethehobbit
Space Squid
Posts: 66
Joined: Mon Aug 27, 2012 7:24 pm

Re: Fix exception warning (patch)

#3 Post by spikethehobbit » Thu Oct 31, 2019 11:10 am

o01eg wrote:
Thu Oct 31, 2019 11:03 am
spikethehobbit wrote:
Thu Oct 31, 2019 10:55 am
There are nine places where exceptions are caught by value instead of by reference. Attached is a trivial patch to change these to const&.
What about to open PR on the Github?
I closed my Github account when Microsoft bought them.
All contributions are submitted under GPL or LGPL v2 or later, or under appropriate Creative Commons licence, consistent with project guidlines.

User avatar
Vezzra
Release Manager, Design
Posts: 5109
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Fix exception warning (patch)

#4 Post by Vezzra » Fri Nov 01, 2019 11:32 am

I have created a PR with this patch: #2625

spikethehobbit
Space Squid
Posts: 66
Joined: Mon Aug 27, 2012 7:24 pm

Re: Fix exception warning (patch)

#5 Post by spikethehobbit » Sat Dec 07, 2019 10:28 pm

Sorry for the delay. There are nine changed lines in the submitted patch, of which only six were applied. Geoff's suggestion of using catch (...) is a viable alternative in several cases as noted.

The following files are each missing one change:
network/Message.cpp
server/ServerApp.cpp
util/Directories.cpp
All contributions are submitted under GPL or LGPL v2 or later, or under appropriate Creative Commons licence, consistent with project guidlines.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12499
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fix exception warning (patch)

#6 Post by Geoff the Medio » Sun Dec 08, 2019 10:43 am


User avatar
Vezzra
Release Manager, Design
Posts: 5109
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Fix exception warning (patch)

#7 Post by Vezzra » Sun Dec 08, 2019 7:34 pm

Should that get cherry picked into the release branch?

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12499
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Fix exception warning (patch)

#8 Post by Geoff the Medio » Sun Dec 08, 2019 9:17 pm

Vezzra wrote:
Sun Dec 08, 2019 7:34 pm
Should that get cherry picked into the release branch?
https://github.com/freeorion/freeorion/ ... 83a6b42cec

User avatar
Vezzra
Release Manager, Design
Posts: 5109
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: Fix exception warning (patch)

#9 Post by Vezzra » Tue Dec 10, 2019 6:08 pm

Oh, good. Should have checked before asking... ;)

Post Reply