From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu From: Sape Mullender In-Reply-To: <3afc1f4defb71eb39b20882e5243fb22@vitanuova.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] (Re:) Exception handling Date: Mon, 12 May 2003 13:30:24 -0400 Topicbox-Message-UUID: a9a8d2ca-eacb-11e9-9e20-41e7f4b1d025 I have `ported' (it's so trivial, it doesn't deserve being calleda port) the kernel's exception mechanism (error, waserror, nexterror, poperror) to a largish application we're building for a high-speed wireless switch. I did this after we already had a lot of conventional error checking in the code, e.g., snprint(buf, sizeof(buf), "add %s 255.255.255.255 %s %d proxy", con->locaddr, con->remaddr, 2048); if(fprint(cfd, "%s", buf) < 0){ close(cfd); return "can't set addresses"; } if(fprint(cfd, "iprouting 1") < 0){ close(cfd); return "can't set iprouting"; } (This routine used a nn-nil return as an error indication). The caller of this routine would have a similar test: if (error = ipsetup(con)){ cleanup(); ... Converting the whole app from this error checking style to using waserror, etc. took some time, but in the end it did reduce code size and it made the code more legible. It also made it harder to ignore unhandled errors deep in several layers of subroutines.