OpenSolaris

  subsites   code review   repo   packages   bugs   defect   polls   planet
You are not signed in. Sign in or register.

HEADS UP: LINT fixes for uts

Date: Tue, 01 Jul 2008 11:37:16 -0700
From: "Garrett D'Amore" <gdamore at sun dot com>
To: on-all at sun dot com, onnv-gate at onnv dot eng dot sun dot com
Subject: HEADS UP: LINT fixes for uts

If you don't work in uts, you can probably ignore this message, although 
the information may still be useful if you work in C code that is 
covered by lint.

Gatekeepers please pay special attention.

As a result of my putbacks of

6692913 MBLKL generates E_PTRDIFF_OVERFLOW lint warnings

6717598 MBLKSIZE() causes lint pointer-difference warnings


I've fixed a number of cases where lint overrides were required for 
device drivers.  I've not cleaned *all* of uts up, but quite a few 
drivers.   Please don't use -erroff=E_PTRDIFF_OVERFLOW in any new driver 
Makefiles.  All of the macros in sys/strsun.h are now lint-safe for use.

Furthermore, if you previously used /*LINTED*/ above the strsun macros 
(MBLKL(), MBLKTAIL(), and company) you may get new lint warnings on your 
code indicating that the LINT directive is not used.  The solution is 
just to remove the /*LINTED*/ override.  I've already done this for all 
the code in ON.

Gatekeepers, I would appreciate if you would enforce a rule that no new 
kernel code integrates with a non-empty set of LINTTAGS overrides.  
There should be no reason to provide global overrides over any new code 
integrating into the kernel.  (The only possible exception being code 
integrated from a 3rd party source where consistency between what's in 
ON and the 3rd party source dictates that we minimize deltas between our 
code and the upstream source.  Cases of this are fairly rare in the kernel.)

Furthermore, as part of this, I've cleaned up quite a few cases where 
folks were using other lint overrides in some drivers... for example, 
-erroff=E_BAD_PTR_CAST_ALIGN is often the result of taking pointers that 
should be untyped, but are typed as char * (such as mp->b_rptr and 
mp->b_wptr) and dereferencing them using another type.  A simple way to 
resolve this is to actually perform the dereference through an untyped 
void *pointer (assuming you're certain that the alignment really is 
safe).  For example, instead of:

    iocp = (struct iocblk *)mp->b_rptr;

use

    iocp = (void *)mp->b_rptr;

The binary code is identical, but it makes lint happy to know that the 
programmer knows that the pointer is really being treated as untyped.

Another common bug I find is -erroff=E_STATIC_UNUSED.  This should never 
be used.  If you have routines in your debug build that exist for access 
from mdb, then just declare them as global.  E.g. instead of

static void mydriver_dump_registers(void) {...}

use

void mydriver_dump_registers(void) { ... }

(Since you're planning on looking up the symbol from another module, 
namely mdb, the removal of the static linkage is actually technically 
correct.)

Kernel developers, feel free to ask me if you desire any further advice 
or have questions about producing lint clean kernel code.

    -- Garrett