Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: Uses of "short" ? Message-ID: <71@hadron.UUCP> Date: Thu, 14-Nov-85 01:05:33 EST Article-I.D.: hadron.71 Posted: Thu Nov 14 01:05:33 1985 Date-Received: Fri, 15-Nov-85 08:30:00 EST References: <486@houxh.UUCP> <2600017@ccvaxa> <2883@sun.uucp> <48@hadron.UUCP> <1931@srcsip.UUCP> <2984@sun.uucp> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 30 Here are some more. > Make as much static as possible. (No, not electricity.) Rephrase: restrict the scope of all variables and functions as much as possible. Use auto's and static's in preference to extern's. > Declare all functions which return a value as such. > If possible, declare non-value-returning functions as void. > After (not if) you use lint, do as little type-casting as possible. Instead, take a long look at what you're doing. Are you forgetting to check return values? Passing more bits than you can use? ... THEN cast types. > If you are using an extern in exactly the same way in code in different functions in different modules, perhaps you can make a single function to do all of this, and reduce the scope of the extern. > Do not use constants in functions. Well, maybe 0. MAYBE 1 or -1. Never 0 for a null pointer, or end-of-string. NEVER strings. > NUL is not NULL. ('\0' and (char *)0 may well be the same -- but it's not saying what you mean. Or, did you mean to say that a nul character was the same object as a null pointer? > Always check. Your return values. Your pointers. Your data, before you divide. This is not so much "portability" as "defensive programming," but what the hey. More abounds. Want more bounds? Keep asking. ;-) -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}