Re: Good Use of GOTO
- Posted by Derek Parnell <ddparnell at bigpond??om> Jun 06, 2008
- 842 views
Without goto #2:
-- 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 inode = fat_build_inode(sb_p, de_p, sinfo[I_POS], res) brelse(bh_p) if length(inode) != 0 then 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 unlock_kernel() return res end function
> With goto: Nah, actually the goto version is not pleasing to my eyes... -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell