How to de-lint files

Warning: Please don't change anything if you're not sure it's okay. You could hide bugs that way.

For more information about lint's diagnostics, see the tests in /usr/tests/usr.bin/xlint/lint1.

What do I do when I get the following error from lint?

  • bitwise '%s' on signed value possibly nonportable [117]

    Try to do the same with an unsigned variable. ISO C11 does not guarantee the results of any shifts where the left hand side operand is not an unsigned int.

  • argument '%s' unused in function '%s' [231]

    If it's not a real error, use /* ARGSUSEDn */ to tell lint how many arguments to check (n being that number).

  • converting '%s' to '%s' increases alignment from %u to %u [135]

    If lint is overzealous, you can avoid the warning by a void cast: p = (foo *)(void *)q. You should do that only if you are certain that the pointer is aligned, otherwise you will be masking real bugs.

  • pointer cast from '%s' to '%s' may be troublesome [247]

    If lint is overzealous, you can avoid the warning by a void cast: p = (foo *)(void *)q.

  • conversion from '%s' to '%s' may lose accuracy [132]

    If you're sure the accuracy loss is acceptable, cast the variable to the new type. Another tactic is to use an additional [unsigned] [long] long variable for intermediate calculations and only cast the result at the end.

  • cast discards 'const' from type '%s' [275]

    If you're sure it's okay, add a /* LINTED const cast-away */ above the line producing the warning.

  • extra bits set to 0 in conversion of '%s' to '%s', op '%s' [309]

    One case where this happens is when you logically combine (for example with &) some long value with a constant, which is int by default. In this case, you can fix it by making the constant a long, too: long & 0xffffffff -> long & 0x00000000ffffffffULL

Back to NetBSD Developer Documentation