I ran ELL through a static analysis tool and came up with a lot of hits.
Only a handful were bogus, and there are also some that definitely require
fixes (I'll send patches).
There are a few broad classes of issues that I wanted to get some feedback
on before making changes.
1. Ignored returned error values from l_io_get_fd()
l_io_get_fd() returns -1 when it's passed a NULL l_io pointer. In many
places, that -1 gets passed to a system call as a file descriptor. Those
system calls typically return an error when they are given a bad fd, and
there is typically proper error handling for the system call.
Many of these cases involve passing in a pointer that's only used by ELL
internals and is never set to NULL anyway. What do you think about leaving
these alone as long as there's a defined error path (even if that error
path involves a system call that could have been skipped)?
2. Ignored returned error values from l_hashmap_insert()
l_hashmap_insert() returns false when passed a NULL l_hashmap pointer.
This isn't always checked, especially when the l_hashmap is something used
by the ELL internals and is never set to NULL.
Seems like these are low risk if it can be confirmed that the pointers
aren't set to NULL during their owner's lifetime.
3. strcpy() instances that could easily be strncpy()
A number of calls to strcpy() were flagged that are copying to
destinations of known length.
These should get fixed, especially where the source string comes from
non-ELL code. I can't think of a reason to use strcpy() over strncpy()
unless the source string is hard-coded, and even then strncpy() isn't a
4. Ignored errors in test/example code
These are low risk because they aren't in the library itself. However,
tests and examples are used as templates for new programs. Does it make
sense to make the examples (and maybe the tests) squeaky-clean in terms of
To take a step back, it's one thing to fix these bugs now, but another to
have something in place to catch future problems. I think it would be good
to set up ELL for scanning on an opensource-friendly static analysis site
- I'll volunteer to babysit that process too.