Xref: utzoo comp.lang.c:31695 comp.unix.programmer:7 Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!sdd.hp.com!cs.utexas.edu!helios!diamond!jdm5548 From: jdm5548@diamond.tamu.edu (James Darrell McCauley) Newsgroups: comp.lang.c,comp.unix.programmer Subject: hiding lint's ravings (was Re: FAQ - malloc array - clarify) Keywords: malloc, Sun, lint Message-ID: <8086@helios.TAMU.EDU> Date: 8 Sep 90 17:45:06 GMT References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> Sender: usenet@helios.TAMU.EDU Reply-To: jdm5548@diamond.tamu.edu (James Darrell McCauley) Followup-To: comp.unix.programmer Organization: Texas A&M University Agricultural Engineering Dept Lines: 41 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. (I'm embarrassed for those who publish code in which lint detects things like unused arguments, etc). I could just: #ifndef lint m = (double *) malloc(... #endif but before long, the code looks disgusting. Do you just ignore warnings like this and remain confident in your code, or do you do your best to work around them? By the way, I got this error while using a Sparc under Sun OS 4.0.3c, but not under 4.0.3 (which perplexes me). --- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - James Darrell McCauley jdm5548@diamond.tamu.edu Dept of Ag. Engineering (409) 845-6484 Texas A&M University, College Station, Texas 77843-2117, USA - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -