Menu

#2 Reduce the number of error reports

1.0
open
None
2019-11-23
2019-11-23
No

Currently the code like:

##define INTALIGNMENT       offsetof(struct tagIntAlignment, value)
##define REALALIGNMENT      offsetof(struct tagRealAlignment, value)
##define POINTERALIGNMENT   offsetof(struct tagPointerAlignment, value)
##define NUMERICALIGNMENT   (((INTALIGNMENT) > (REALALIGNMENT)) ? (INTALIGNMENT) : (REALALIGNMENT))
##define ALIGNMENT           (((NUMERICALIGNMENT) > (POINTERALIGNMENT)) ? (NUMERICALIGNMENT) : (POINTERALIGNMENT))

will generate 3 "Condition in '?:' is constant" warnings for every line that refers to ALIGNMENT in C code, ALL OF THEM LEGITIMATE, and if we further say:

#define BLOCK_HEADER_SIZE   (sizeof(BlockHeader) + ((ALIGNMENT - sizeof(BlockHeader) % ALIGNMENT) % ALIGNMENT))

...that will be 9(!) "Condition in '?:' is constant" warnings for every line that mentions BLOCK_HEADER_SIZE.

This is too much. Even if there are several different errors in the same source line, it will do no good to report them all. So, when a message is logged with a given "anchor":

  • If it's an error, all subsequent errors and warnings with the same anchor shall be suppressed.
  • If it's a warning, all subsequent less-important warnings with the same anchor shall be suppressed.

Of course, it the message is a fatal error, then toe application is terminated and the iccue does not arise.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB