I sent these changes in with a bunch of others. Some were folded in but
others, like these, were not. I am not sure why so I am resending this
to the developers list by itself for discussion.
The readon why I suggest these changes is that the compiler can't tell
that minimum_count is initialized before it is used. The tests that I
add in here will cause an immediate error if it doesn't. As the comments
below suggest, if it is 100% guaranteed that the variable will always
be initialized then how this is so should be commented here. I don't
know how much strain the actual test puts on the performance but if it
isn't too much then maybe leave it in for absolute safety anyway.
There are also a few returns just to stop warnings.
*** ../src.original/./backend/optimizer/geqo/geqo_erx.c Fri Apr 18 09:12:39 1997
- --- ./backend/optimizer/geqo/geqo_erx.c Fri Apr 18 09:28:53 1997
***************
*** 278,284 ****
int i;
Gene friend;
int minimum_edges;
! int minimum_count;
int rand_decision;
/* no point has edges to more than 4 other points
- --- 278,284 ----
int i;
Gene friend;
int minimum_edges;
! int minimum_count = -1;
int rand_decision;
/* no point has edges to more than 4 other points
***************
*** 304,313 ****
- --- 304,320 ----
if there is more than one cadidate with the minimum number
of unused edges keep count of this number (minimum_count); */
+ /* The test for minimum_count can probably be removed at some
+ point but comments should probably indicate exactly why it
+ is guaranteed that the test will always succeed the first
+ time around. If it can fail then the code is in error */
+
if (edge_table[(int) friend].unused_edges < minimum_edges) {
minimum_edges = edge_table[(int) friend].unused_edges;
minimum_count = 1;
}
+ else if (minimum_count == -1)
+ elog(WARN, "gimme_gene: Internal error - minimum_count not set");
else
if (edge_table[(int) friend].unused_edges == minimum_edges)
minimum_count++;
***************
*** 332,337 ****
- --- 339,345 ----
/* ... should never be reached */
elog(WARN,"gimme_gene: neither shared nor minimum number nor random edge found");
+ return 0; /* to keep the compiler quiet */
}
/* edge_failure--
***************
*** 420,424 ****
- --- 428,433 ----
/* ... should never be reached */
elog(WARN,"edge_failure: no edge detected");
+ return 0; /* to keep the compiler quiet */
}
- --
D'Arcy J.M. Cain | Democracy is three wolves
darcy@{druid.net|vex.net} | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
-- http://www.druid.net/darcy --
------------------------------