1

I need to be able to suppress lint warnings on specific lines of C code, and I would like to do this with in-line directives. This is for a very large body of legacy code that I am porting to 64 bit, and I'd much rather put the directives in the code than in the Makefile that runs lint, as the latter is quite obscure.

The problem is that Solaris lint documentation specifies how to do this for only a few warning types (as far as I can tell).

In the past, the following form was used and the Solaris documentation suggests that this is still allowed, but it doesn't seem to work. Complicating the issue is that the Solaris lint does not give error numbers, but rather uses identifiers like E_CAST_INT_TO_SMALL_INT.

Here is the old way (and there are lots of these in the code already):

/*line -e511*/
John Moore
  • 332
  • 2
  • 14
  • Have you tried `/*line -eE_CAST_INT_TO_SMALL_INT */`, just substituting the identifier for the error number? – Andy Lester Jul 22 '15 at 19:34
  • 1
    Wondering if OP _should_ suppress these warnings. Maybe post an example of code with a warning that OP would like to suppress? – chux - Reinstate Monica Jul 22 '15 at 20:39
  • 1
    @chux - Agreed. When porting old code to 64-bit, I'd think lint warnings such as `E_CAST_INT_TO_SMALL_INT` are exactly the kinds of problems that **must** be fixed, especially if they involve `size_t` and/or pointer code written by someone who "knows that size_t is an unsigned int". That sounds all too likely here. – Andrew Henle Jul 22 '15 at 21:07
  • I've never seen the `/* line -e511 */` form with Solaris lint before - are you sure those aren't for another lint product? – alanc Jul 22 '15 at 23:45
  • I tried the /*lint -e... and it did not work. The existing code had a number of lines of that form from ancient history when /*lint -e*/ did work. I am suppressing the warnings because the particular piece of code will not encounter a case where more than 32 is needed, but is part of a huge code base where it is not worth rewriting tons of code (potentially introducing bugs) in order to make this warning go away naturally. – John Moore Jul 23 '15 at 00:25
  • Comments like `/* lint -e511 */` are used by PC-Lint. AT&T-based lints have used other formats. – Mark Plotnick Jul 23 '15 at 16:42

1 Answers1

3

Described in Lint Directives Section at this link

There are two inline ways to suppress lint warnings for a single line of code - the old way and the recommended new way.

The old way is to use a LINTED comment: /*LINTED*/

The new way is to use a lint macro: NOTE(LINTED (msg))

The new way also requires including note.h.

John Moore
  • 332
  • 2
  • 14