UDSim
UDSim copied to clipboard
Build Error in logparser.cc
I got the following build error when building UDSim on my Arch Linux:
logparser.cc: In member function ‘std::string LogParser::processNext()’:
logparser.cc:36:14: error: ordered comparison of pointer with integer zero (‘FILE*’ and ‘int’)
36 | if(logfp < 0) {
| ~~~~~~^~~
make: *** [Makefile:17: logparser.o] Error 1
To fix the issue I changed the corrensponding line to
if(logfp != 0) {
Keep in mind I'm not a C programmer and don't know if that is the way, this issue should be fixed. But for me it works :-)
@Loris1123 - Yes, that will work, although arguably better for readability to use if(logfp != NULL) {
2018 POSIX spec for fopen says: "Upon successful completion, fopen() shall return a pointer to the object controlling the stream. Otherwise, a null pointer shall be returned, and errno shall be set to indicate the error."
Looks like that was also the behavior of fopen
in POSIX.1-2001. Not sure what changed since this code was released, but this is a good fix that should be mainlined.