Firewall Wizards mailing list archives
Re: Code reviews [Was: FWTK and smap/smapd]
From: Darren Reed <darrenr () reed wattle id au>
Date: Wed, 24 Jul 2002 02:35:24 +1000 (EST)
In some email I received from Joseph S D Yao, sie wrote:
Oh, geez, shouldn't everyone have written [something like] this?
No... Your parameters are wrong, for a start :-) They were "char *buf" and "unsigned int buflen".
register char *cp = buf; register int i, count = n; for (;;) { i = write(fd, cp, count); if (i < 0) { perror("..."); fprintf(stderr, ...); break; } count -= i; if (count <= 0) /* yes, should never be <, optionally fuss */ break; cp += i; if (i == 0 { sleep(1); /* should probably count and break if too many */ } }
You're using a "for (;;)" where it isn't required - should be "while (count != 0)", the "if (count <= 0) ..." should be nuked from orbit. Hanlding write() returning 0 bytes, is, umm, bizarre ? Carson never said anything about non-blocking I/O but apparently it was implied. That's a failure in the specification, I say :-) Carson wanted specific handling of things like EINTR... _______________________________________________ firewall-wizards mailing list firewall-wizards () honor icsalabs com http://honor.icsalabs.com/mailman/listinfo/firewall-wizards
Current thread:
- Re: FWTK and smap/smapd, (continued)
- Re: FWTK and smap/smapd Paul D. Robertson (Jul 19)
- Re: FWTK and smap/smapd R. DuFresne (Jul 19)
- Re: FWTK and smap/smapd Joseph S D Yao (Jul 19)
- Message not available
- Code reviews [Was: FWTK and smap/smapd] Marcus J. Ranum (Jul 19)
- Re: Code reviews [Was: FWTK and smap/smapd] Jim Duncan (Jul 19)
- Re: Code reviews [Was: FWTK and smap/smapd] Carson Gaspar (Jul 22)
- Re: Code reviews [Was: FWTK and smap/smapd] ark (Jul 23)
- Re: Code reviews [Was: FWTK and smap/smapd] Carson Gaspar (Jul 23)
- Re: Code reviews [Was: FWTK and smap/smapd] Joseph S D Yao (Jul 23)
- Re: Code reviews [Was: FWTK and smap/smapd] Carson Gaspar (Jul 23)
- Re: Code reviews [Was: FWTK and smap/smapd] Darren Reed (Jul 23)
- Re: Code reviews [Was: FWTK and smap/smapd] Joseph S D Yao (Jul 23)
- Re: Code reviews [Was: FWTK and smap/smapd] Darren Reed (Jul 23)
- Re: FWTK and smap/smapd Brian Hatch (Jul 19)
- Re: FWTK and smap/smapd Adam Shostack (Jul 17)
- Re: FWTK and smap/smapd Joseph S D Yao (Jul 17)
- Re: FWTK and smap/smapd Marcus J. Ranum (Jul 18)
- Re: FWTK and smap/smapd Darren Reed (Jul 18)
- Re: FWTK and smap/smapd Charles W. Swiger (Jul 17)
- Re: FWTK and smap/smapd Rick Murphy (Jul 17)