dzd@cosivax.UUCP (Dean Douthat) (04/20/84)
<>
In a C program which needs current date and time, the following
sequence was used:
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
.
.
.
struct tm *p, *localtime();
time_t time(), time_sec;
.
.
.
time_sec = time(NULL);
p = localtime(@time_sec);
This was passed through lint on a VAX running Eunice. Lint
nattered about the last line with:
Inconsistent use of return value. [Huhh???]
This lint is, presumbably, based on BSD 4.? so I tried the same
code on an IBM PC running VENIX/86 which is presumably based on
AT&T System III. There, lint made no complaint whatsoever.
In examining lint's grammatical tables or templates or whatever
they're called in file llib-lc, the pertinent line is:
struct tm *localtime(c) time_t *c; { return localtime(c); }
This line is *exactly the same* in both the llib-lc for VENIX/86
and that for Eunice. Is this a bug in the Eunice (= BSD??)
lint, an error in the program [and therefore a bug in the
VENIX/86 (= AT&T System III??) lint] or simply another lint
koan, beyond the ken of all save UNIX gurus?
May the Source be with you!
Dean Douthat
UUCP: ...!sb1!mb2c!uofm-cv!cosivax!dzd | Mail: Zahntron, Inc.
Ma: (313) 995-9762 | 330 E. Liberty
MCI Mail: DDOUTHAT 187-3270 | Suite 3B
TWX/TELEX: 6501873270 | Ann Arbor, MI
Answerback: 6501873270 MCI | 48104dzd@cosivax.UUCP (04/26/84)
Thanks to Peter Gross for pointing out that I made a typo in my previous posting concerning a lint problem; I had "@time_sec" where I meant "&time_sec". This made the problem sound like merely a complaint on the obscurity of lint's error messages. It was correct (&) in the original program. In fact, my problem is not a complaint about lint reporting a syntax error with an obscure message but rather that it complained at all on one version (VAX with Eunice) but not on another (VENIX). As far as I can see, there is no error in the program, especially in type-declarations of localtime() and p. Thus I tend to believe VENIX but not Eunice. But no matter my personal beliefs, *one of them* is wrong. I would be interested to hear what other "lints" think about this program. If Eunice "lint" is wrong, its system administrator would like to know about it. If VENIX is wrong, I would like to know it. (The VAX is owned by Environmental Research Institute of Michigan and the IBM-PC/XT with VENIX is my own.) Dean Douthat UUCP: ...!sb1!mb2c!uofm-cv!cosivax!dzd | Mail: Zahntron, Inc. Ma: (313) 995-9762 | 330 E. Liberty MCI Mail: DDOUTHAT 187-3270 | Suite 3B TWX/TELEX: 6501873270 | Ann Arbor, MI Answerback: 6501873270 MCI | 48104