meulenbr@cst.UUCP (Frans Meulenbroeks) (11/12/88)
Hi! I've found a minor bug in fopen/fclose. 0 is used for assignment and comparison against _io_table, while (FILE *)0 would be better. I think it is cleaner to fix printdat.c as well. However, I don't know for sure if this is really needed. The bug applies to Minix/ST. PC people should check out for themselves whether or not this is appropriate. Fixes (cdiffs) are at the end. Frans Meulenbroeks (signature at end) # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. -----cut here-----cut here-----cut here-----cut here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # fclose.cdiff # fopen.cdiff # printdat.cdiff # This archive created: Fri Nov 11 19:32:53 1988 sed 's/^X//' << \SHAR_EOF > fclose.cdiff X*** ../lib/fclose.c Tue Mar 1 21:37:18 1988 X--- ./fclose.c Sat Nov 12 01:31:32 1988 X*************** X*** 7,13 **** X X for (i=0; i<NFILES; i++) X if (fp == _io_table[i]) { X! _io_table[i] = 0; X break; X } X if (i >= NFILES) X--- 7,13 ---- X X for (i=0; i<NFILES; i++) X if (fp == _io_table[i]) { X! _io_table[i] = (FILE *)0; X break; X } X if (i >= NFILES) SHAR_EOF sed 's/^X//' << \SHAR_EOF > fopen.cdiff X*** ../lib/fopen.c Tue Mar 1 21:37:20 1988 X--- ./fopen.c Sat Nov 12 01:31:16 1988 X*************** X*** 12,18 **** X int fd, X flags = 0; X X! for (i = 0; _io_table[i] != 0 ; i++) X if ( i >= NFILES ) X return(NULL); X X--- 12,18 ---- X int fd, X flags = 0; X X! for (i = 0; _io_table[i] != (FILE *)0 ; i++) X if ( i >= NFILES ) X return(NULL); X SHAR_EOF sed 's/^X//' << \SHAR_EOF > printdat.cdiff X*** ../lib/printdat.c Tue Mar 1 21:37:38 1988 X--- ./printdat.c Sat Nov 12 01:31:46 1988 X*************** X*** 19,23 **** X &_stdin, X &_stdout, X &_stderr, X! 0 X }; X--- 19,23 ---- X &_stdin, X &_stdout, X &_stderr, X! (FILE *)0 X }; SHAR_EOF # End of shell archive exit 0 -- Frans Meulenbroeks (meulenbr@cst.prl.philips.nl) Centre for Software Technology ( or try: ...!mcvax!philmds!prle!cst!meulenbr)
henry@utzoo.uucp (Henry Spencer) (11/15/88)
In article <259@cst.UUCP> meulenbr@cst.UUCP (Frans Meulenbroeks) writes: >I've found a minor bug in fopen/fclose. 0 is used for assignment >and comparison against _io_table, while (FILE *)0 would be better. This is not a bug if the code is written in C (whether the language accepted by the ST Minix compiler is precisely C is something I cannot check at the moment). The only place where it is necessary to cast a 0 or NULL to a specific pointer type is when passing a parameter to a function. In all other contexts, a C compiler knows what the type of the value is supposed to be, and will do the cast for you. -- Sendmail is a bug, | Henry Spencer at U of Toronto Zoology not a feature. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu