Re: Good Use of GOTO
- Posted by Jason Gade <jaygade at yah?o.c?m> Jun 06, 2008
- 832 views
Okay, so it's three functions. Here's the second:
-- still assuming that structs and pointers and refs are sequences... function vfat_create(sequence dir_p, sequence dentry_p, integer mode, sequence nd_p) sequence sb_p sequence inode_p sequence bh_p sequence de_p sequence sinfo integer res sb_p = dir_p[I_SB] inode_p = {} bh_p = {} lock_kernel() res = vfat_add_entry(dir_p, dentry_p[D_NAME], 0, sinfo, bh_p, de_p) if res < 0 then -- out else inode = fat_build_inode(sb_p, de_p, sinfo[I_POS], res) brelse(bh_p) if length(inode) = 0 then -- out else res = 0 inode_p[I_MTIME] = CURRENT_TIME_SEC inode_p[I_ATIME] = CURRENT_TIME_SEC inode_p[I_CTIME] = CURRENT_TIME_SEC mark_inode_dirty(inode_p) inode_p[I_VERSION] += 1 dir_p[I_VERSION] += 1 dentry_p[D_TIME] = dentry_p[D_PARENT][D_INODE][I_VERSION] d_instatiate(dentry_p, inode_p) end if end if -- out unlock_kernel() return res end function
-- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.