enum mismatch [was: Sun Workshop compiler warnings]

David Relson relson at osagesoftware.com
Tue Aug 5 04:01:21 CEST 2003


At 07:47 PM 8/4/03, Matthias Andree wrote:
>"lexer_v3.l", line 120: warning: 37589 is invalid in #line directive
>"lexer_v3.l", line 168: warning: 37746 is invalid in #line directive
>"lexer_v3.l", line 264: warning: 38113 is invalid in #line directive
>
>These cannot be fixed easily, apparently Sun Workshop complains if
>__LINE__ exceeds 32767 (the largest guaranteed signed short).
>
>"src/main.c", line 157: warning: enum type mismatch: op "="
>
>This one is a problem when the rc_t and ex_t interfaces to not match.
>Can we kill one of the two interfaces without sacrificing too much
>functionality? We should to so to keep the code maintainable.

Logically the rc_t type refers to spam status codes (internal to 
bogofilter), while the ex_t refers to externally visible program exit 
codes.  I defined one enum in terms of the other for convenience.

We could use a switch or a rc_2_ex mapping array to do this.  I'm thinking 
of something like:

switch (status) {
case RC_SPAM:  exitcode = EX_SPAM; break;
case RC_HAM:   exitcode = HAMN; break;
case RC_UNSURE:  exitcode = EX_UNSURE; break;
default: fprintf(stderr, "Unknown RC status (%d)\n", status);
}

Yes, it's long, but a good optimizer should shrink it down.  It





More information about the bogofilter-dev mailing list