barryg@sdcrdcf.UUCP (Barry Gold) (11/01/83)
1. (minor) The manual page for lint claims that the comment /*NOSTRICT*/ shuts off strict type checking in the next expression. I tried using this to get lint to shut up about a variety of things I didn't care about; there was NO CHANGE in the output. I then went to the sources and did a grep on the sources of lint and ccom. NOSTRICT does not appear anywhere in those sources (4.2bsd). Is this something that was planned and never implemented, or something that got deleted because it turned out to be a misfeature? Or what? 2. (portability problem) Lint seems to assume that all machines support both signed and unsigned chars. Before porting a simplified implementation of TCP/IP to a 370, I linted it and cleaned up everything possible. I later had an interesting debugging problem. The code contained the following: typedef struct tcb { ... char ntoack; ... } TCB; . . . proc rcvdata(rtcb) TCB *rtcb; . . . if (--rtcb->ntoack <= 0) { rtcb->sndwrk = FL_ACK; /* schedule an ACK to be sent */ rtcb->ntoack = 3; } /* in otherwise, ACK every third packet */ The problem was that the 370 c made ALL chars unsigned. After one ACK had been sent, it would be a looong time before another got sent. The other end of the connection kept retransmitting in hopes of seeing the ACK, thus creating an unnecessary load on both systems (and the network). (Eventually a separate timer-based acknowledgement got sent, but the performance was horrendous). ANOTHER EXAMPLE from a system I'm working on now (on the vax, as it happens): #define TEXT unsigned char #define EOFCH 0xfe #define EOLCH 0xff TEXT synbuf[1025]; ... if (synbuf[i] >= EOFCH) ... lint accepted the above as OK. I noticed the non-portability by eyeballing the above code: The PDP-11 (among others) ignores "unsigned" when applied to "char". Since 0xfe will be negative in a signed 8-bit integer, the test wont work as intended. I changed to what I thought was a more portable version: #define TEXT char #define EOFCH '\376' #define EOLCH '\377' TEXT synbuf[1025]; ... if (synbuf[i] == EOLCH || synbuf[i] == EOFCH) ... Guess what? Lint now complains about a "non-portable character comparison". Seems to me lint has this one backward.