bugFreeciv - Bugs: bug #22026, is_native_move(): missing...

Show feedback again

bug #22026: is_native_move(): missing "break" in switch statement

Submitted by:  pepeto <pepeto>
Submitted on:  Thu 08 May 2014 08:34:51 AM UTC  
Category: generalSeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Assigned to: pepeto <pepeto>Open/Closed: Closed
Release: trunk r24826Operating System: None
Planned Release: 2.6.0Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Thu 15 May 2014 03:01:19 PM UTC, SVN revision 24890:

Rewrite and fix is_native_move().

Report and patch by me

See gna bug #22026.

(Browse SVN revision 24890)

pepeto <pepeto>
Project MemberIn charge of this item.
Fri 09 May 2014 07:12:05 AM UTC, comment #3:

'const struct foo *' means a pointer to a read-only structure. The pointer can be reassigned, but you cannot write to the memory.

'struct foo *const' means a constant pointer to a structure which can modified.

If we were using the incorrect alternative, I bet that gcc would have complained. So, it is safe to define this variable at the function scope.

pepeto <pepeto>
Project MemberIn charge of this item.
Fri 09 May 2014 05:45:47 AM UTC, comment #2:

This code is much cleaner than the original implementation: thank you. I'm a little worried about declaring proad a const at function scope though, as the value is changed in each iteration: should this not use a non-const struct (and extra_road_get()), or to put the declaration of proad inside the extra_type_list iteration?

Emmet Hikory <persia>
Project Member
Thu 08 May 2014 09:48:52 AM UTC, comment #1:

Second version that additionaly pushes disembarking or leaving port outside the extra type iteration loop.

(file #20689)

pepeto <pepeto>
Project MemberIn charge of this item.
Thu 08 May 2014 08:34:51 AM UTC, original submission:

When reading is_native_move(), I noticed that breaks were missing to separate cases in the switch statement.

The attached patch returns TRUE as soon as possible and reduce the huge number of spaces used for the indentation.

pepeto <pepeto>
Project MemberIn charge of this item.


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #20689:  is_native_move2.diff added by pepeto (5kB - text/x-diff)
file #20688:  is_native_move.diff added by pepeto (4kB - text/x-diff)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by persia (Posted a comment)
  • -unavailable- added by pepeto (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 15 May 2014 03:01:34 PM UTCpepetoStatusReady For Test=>Fixed
    Mon 12 May 2014 12:51:52 PM UTCpepetoAssigned toNone=>pepeto
    Thu 08 May 2014 09:48:52 AM UTCpepetoAttached File-=>Added is_native_move2.diff, #20689
    Thu 08 May 2014 08:34:52 AM UTCpepetoAttached File-=>Added is_native_move.diff, #20688
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup