compiler warning and possible misbahavior in iocLogServer.c

Bug #1254776 reported by Dirk Zimoch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Invalid
Undecided
Unassigned

Bug Description

../iocLogServer.c: In function 'seekLatestLine':
../iocLogServer.c:297: warning: comparison is always true due to limited range of data type
../iocLogServer.c:301: warning: comparison is always false due to limited range of data type

This is the code:
            char c = fgetc (pserver->poutfile);

            /*
             * bypass the line if it does not match the expected format
             */
            while ( c!=EOF && c!='\n' ) {
                c = fgetc (pserver->poutfile);
            }

            if (c==EOF) {
                break;
            }

The problem is that EOF is -1 but char is unsigned on some systems. Where char is signed, it is worse because here the code 0xFF is treated as EOF.

The solution is to use 'int c', as described in the man page of fgetc.

Revision history for this message
Andrew Johnson (anj) wrote :

Thi s was fixed in commit 12370 to the 3.14 branch in October 2012, and thus was present in the 3.14.12.3 release from almost a year ago.

Changed in epics-base:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.