Article View: comp.bugs.sys5
Article #143bug in "lint" pass 2
From: Doug Gwyn
Date: Sat, 25 Nov 1989 05:32
Date: Sat, 25 Nov 1989 05:32
38 lines
1707 bytes
1707 bytes
I found out why the SVR2 version of "lint" would, when fed code like foo.c: #include "hdr.h" ... bar.c: #include "hdr.h" ... hdr.h: extern void XxxxxxxxY(); extern void XxxxxxxxZ(); produce a warning like hdr.h (as included in foo.c): (2) warning: `XxxxxxxxY' may be indistinguishable from `XxxxxxxxY' due to internal name truncation instead of the expected hdr.h (as included in foo.c): (2) warning: `XxxxxxxxY' may be indistinguishable from `XxxxxxxxZ' due to internal name truncation The problem was that the function in "lint" source file lerror2.c named gethstr() returned a pointer to an internal static character buffer, so the second time it was called the new string (internally known as name1) would overwrite the previous one (known as name2) and the printf() would format the message using two pointers to the same static buffer, which contained only the second string read. This is easily fixed by giving gethstr() an integer argument which would be 0 or 1 to select between an array of two internal buffers, and invoke it with different arguments for the two strings needed for the printf(). I had to change about 7 lines of code to implement this fix. They should be obvious to anyone who is competent to make changes to system code. I don't know whether later releases of UNIX System V have the same bug.
Technical Details
Message-ID:
<11683@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!samsung!rex!ames!haven!adm!smoke!gwynShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!samsung!rex!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.bugs.sys5 Subject: bug in "lint" pass 2 Keywords: SVR2 lint bug Message-ID: <11683@smoke.BRL.MIL> Date: 25 Nov 89 05:32:04 GMT Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 38