🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #854

Re: hiding lint's ravings (was Re: FAQ - malloc array - clarify)

#854
From: Doug McDonald
Date: Sat, 08 Sep 1990 18:33
35 lines
2096 bytes
In article <8086@helios.TAMU.EDU> jdm5548@diamond.tamu.edu (James Darrell McCauley) writes:
>How do you professionals deal with insignificant(?) ravings from
>lint (or other high quality C program verifiers) such as the 
>following:
>
>>test.c(x): warning: possible pointer alignment problem
>which was caused by the malloc in:
>
>>double **dmatrix(nr,nc)
>>int nr,nc;
>>{
>>  double **m = NULL;
>>
>>  m = (double **) malloc( (unsigned) nr * sizeof(double *) );
>>  if (!m) ...
>
>From what netlanders tell me, this warning is explanined as:
>(by Conor P. Cahill) 
>|>                         The problem is that malloc is defined
>|> as returning a pointer to char which has looser alignment requirements than
>|> pointer to pointer.  Since malloc guarrantees that the result is suitably 
>|> alligned for all data types, you can ignore this message.
>
>Well, I can just ignore warnings like this, but those who review
>my code (professors, employers, clients) are not likely to. It makes
>an bad impression and frankly, I find it a little embarrassing.


It is NOT embarrassing to you. It just plain a BUG in lint. Pure and
simple. Complain to the person that sold you the broken "lint".
A checker program really OUGHT to understand the rules of what it is
checking. One of those rules concersn alignments of the return
value of malloc.

Doug McDonald
Technical Details
Message-ID: <1990Sep8.183320.9427@ux1.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!aries!mcdonald
References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <8086@helios.TAMU.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!aries!mcdonald
From: mcdonald@aries.scs.uiuc.edu (Doug McDonald)
Newsgroups: comp.unix.programmer
Subject: Re: hiding lint's ravings (was Re: FAQ - malloc array - clarify)
Keywords: malloc, Sun, lint
Message-ID: <1990Sep8.183320.9427@ux1.cso.uiuc.edu>
Date: 8 Sep 90 18:33:20 GMT
References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <8086@helios.TAMU.EDU>
Sender: news@ux1.cso.uiuc.edu (News)
Reply-To: mcdonald@aries.scs.uiuc.edu (Doug McDonald)
Organization: School of Chemical Sciences, Univ. of Illinois at Urbana-Champaign
Lines: 35