aboutsummaryrefslogtreecommitdiff
path: root/sys/netsmb/smb_iod.c
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2003-08-23 21:43:33 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2003-08-23 21:43:33 +0000
commite51fe8759dcaaa412c74c06298576a134d9ec533 (patch)
tree9740f1cb5fa3620cec720b3ec06817bb11d02a6c /sys/netsmb/smb_iod.c
parentcfd5696d2217aead6f6e1dd9a51230579e9a30b2 (diff)
downloadsrc-e51fe8759dcaaa412c74c06298576a134d9ec533.tar.gz
src-e51fe8759dcaaa412c74c06298576a134d9ec533.zip
Rewrite the code that uses the try/catch paradigm implemented by
goto and abstracted by the itry, ithrow and icatch macros (among others). The problem with this code is that it doesn't compile on ia64. The compiler is sufficiently confused that it inserts a call to __ia64_save_stack_nonlock(). This is a magic function that saves enough of the stack to allow for non-local gotos, such as would be the case for nested functions. Since it's not a compiler defined function, it needs a runtime implementation. This we have not in a standalone compilation as is the kernel. There's no indication that the compiler is not confused on other platforms. It's likely that saving the stack in those cases is trivial enough that the compiler doesn't need to off-load the complexity to a runtime function. The code is believed to be correctly translated, but has not been tested. The overall structure remained the same, except that it's made explicit. The macros that implement the try/catch construct have been removed to avoid reintroduction of their use. It's not a good idea. In general the rewritten code is slightly more optimal in that it doesn't need as much stack space and generally is smaller in size. Found by: LINT
Notes
Notes: svn path=/head/; revision=119376
Diffstat (limited to 'sys/netsmb/smb_iod.c')
-rw-r--r--sys/netsmb/smb_iod.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c
index 2c5e2c3917d2..ae9c45723060 100644
--- a/sys/netsmb/smb_iod.c
+++ b/sys/netsmb/smb_iod.c
@@ -141,29 +141,39 @@ smb_iod_connect(struct smbiod *iod)
}
vcp->vc_genid++;
error = 0;
- itry {
- ithrow(SMB_TRAN_CREATE(vcp, td));
- SMBIODEBUG("tcreate\n");
- if (vcp->vc_laddr) {
- ithrow(SMB_TRAN_BIND(vcp, vcp->vc_laddr, td));
- }
- SMBIODEBUG("tbind\n");
- ithrow(SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, td));
- SMB_TRAN_SETPARAM(vcp, SMBTP_SELECTID, &iod->iod_flags);
- iod->iod_state = SMBIOD_ST_TRANACTIVE;
- SMBIODEBUG("tconnect\n");
-/* vcp->vc_mid = 0;*/
- ithrow(smb_smb_negotiate(vcp, &iod->iod_scred));
- SMBIODEBUG("snegotiate\n");
- ithrow(smb_smb_ssnsetup(vcp, &iod->iod_scred));
- iod->iod_state = SMBIOD_ST_VCACTIVE;
- SMBIODEBUG("completed\n");
- smb_iod_invrq(iod);
- } icatch(error) {
- smb_iod_dead(iod);
- } ifinally {
- } iendtry;
- return error;
+
+ error = (int)SMB_TRAN_CREATE(vcp, td);
+ if (error)
+ goto fail;
+ SMBIODEBUG("tcreate\n");
+ if (vcp->vc_laddr) {
+ error = (int)SMB_TRAN_BIND(vcp, vcp->vc_laddr, td);
+ if (error)
+ goto fail;
+ }
+ SMBIODEBUG("tbind\n");
+ error = (int)SMB_TRAN_CONNECT(vcp, vcp->vc_paddr, td);
+ if (error)
+ goto fail;
+ SMB_TRAN_SETPARAM(vcp, SMBTP_SELECTID, &iod->iod_flags);
+ iod->iod_state = SMBIOD_ST_TRANACTIVE;
+ SMBIODEBUG("tconnect\n");
+ /* vcp->vc_mid = 0;*/
+ error = (int)smb_smb_negotiate(vcp, &iod->iod_scred);
+ if (error)
+ goto fail;
+ SMBIODEBUG("snegotiate\n");
+ error = (int)smb_smb_ssnsetup(vcp, &iod->iod_scred);
+ if (error)
+ goto fail;
+ iod->iod_state = SMBIOD_ST_VCACTIVE;
+ SMBIODEBUG("completed\n");
+ smb_iod_invrq(iod);
+ return (0);
+
+ fail:
+ smb_iod_dead(iod);
+ return (error);
}
static int