do { ZeroMemory(szProtoBuffer, sizeof(szProtoBuffer));
pMsgHdr = ( PNFS_MSG_HEADER )szProtoBuffer ;
ZeroMemory( pMsgHdr , sizeof( NFS_MSG_HEADER )) ;
pMsgHdr->dwSignature = RNFS_MAGIC ; pMsgHdr->wProtocolVersion = RNFS_PROTOVERSION ; pMsgHdr->btPacketType = RNFS_DGRAM_REQUEST ; pMsgHdr->dwPacketLength = 0 ; pMsgHdr->wFunctionNum = RNFS_OPEN_SESSION ; pMsgHdr->dwAckNumber = dwAckNumber ;
dwSize = MSG_HDR_LEN + pMsgHdr->dwPacketLength ;
dwStatus = GU_SendAll( SessionSocket , szProtoBuffer , dwSize ) ; if( 0 != dwStatus ) { break ; }
dwSize = MSG_HDR_LEN ;
dwStatus = GU_RecvAll( SessionSocket , szProtoBuffer, dwSize ) ; if( 0 != dwStatus ) { break ; }
if( pMsgHdr->dwAckNumber != dwAckNumber ) { dwStatus = ERROR_BAD_FORMAT ; break ; } if( pMsgHdr->dwRetStatus != 0 ) { dwStatus = pMsgHdr->dwRetStatus ; break ; }
dwSize = pMsgHdr->dwPacketLength ;
dwStatus = GU_RecvAll( SessionSocket , szProtoBuffer , dwSize ) ; if( 0 == dwStatus ) { PNFS_SESSION pSession = ( PNFS_SESSION )szProtoBuffer ; * pdwSessionId = pSession->dwSessionId ; } } while( FALSE ) ;
|
开始觉得不是多此一举吗?仔细分析了以后,才发现很妙,因为在不同的条件判断中就可以按需break;从而达到最终执行到最后一个返回语句。而以前的实现都是以goto来实现的。
阅读(874) | 评论(0) | 转发(0) |