event->mask & EventQueueOverflow is already checked once early in the
function, no need to do the check twice.
Details
- Reviewers
ngraham - Group Reviewers
Baloo - Commits
- R293:bcb5950e958e: [Inotify] Remove dead/duplicate code
Diff Detail
- Repository
- R293 Baloo
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | First check is here |
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | ... but only also if wd is < 0 |
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | man inotify
|
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | then add an assert for this case, referencing the documentation? |
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | asserts are IMHO pointless, nobody enables them, but it clutters the code. Anyone touching the code should and has to read the man pages etc anyway. |
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | no, an assert is sort of "program by contract": you make it clear that this situation ought to not happen, and it if does, at least some people may notice that
and an explicit mention/comment in the code never killed anyone, nor made the code "cluttered"; also what is valid today might change in the future, so writing down why a check/assert was added make sure that people reading the changed documentation know why it made sense when it was added |
src/file/kinotify.cpp | ||
---|---|---|
350 ↗ | (On Diff #78600) | After two years of maintaining baloo (and other software for much longer) I can assure you you are wrong. If we checked all the conditions which are guaranteed by the API (null termination of strings, only complete events, bounds check of event->len ...) here and everywhere else, the could would be cluttered. And just picking an arbitrary condition to be more equal is nonsense. This is kernel API, it does not change. Comments are useful when some code is not obvious. Copying an explicitly spelled out condition from the man page does clutter the code. Otherwise we would have to copy the whole man page to have the code covered in its entirety. |