mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
cleanup (version upgrade test works)
This commit is contained in:
parent
92292ad1fe
commit
93526d38d7
1 changed files with 15 additions and 28 deletions
|
@ -542,18 +542,14 @@ static void
|
||||||
addrFromStream( CommsAddrRec* addrP, XWStreamCtxt* stream )
|
addrFromStream( CommsAddrRec* addrP, XWStreamCtxt* stream )
|
||||||
{
|
{
|
||||||
XP_U8 tmp = stream_getU8( stream );
|
XP_U8 tmp = stream_getU8( stream );
|
||||||
if ( STREAM_VERS_MULTIADDR <= stream_getVersion( stream ) ) {
|
if ( (STREAM_VERS_MULTIADDR > stream_getVersion( stream ))
|
||||||
/* do nothing */
|
&& (COMMS_CONN_NONE != tmp) ) {
|
||||||
} else {
|
|
||||||
if ( COMMS_CONN_NONE != tmp ) {
|
|
||||||
tmp = 1 << (tmp - 1);
|
tmp = 1 << (tmp - 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
addrP->_conTypes = tmp;
|
addrP->_conTypes = tmp;
|
||||||
|
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
XP_U32 state = 0;
|
for ( XP_U32 st = 0; addr_iter( addrP, &typ, &st ); ) {
|
||||||
while ( addr_iter( addrP, &typ, &state ) ) {
|
|
||||||
addrFromStreamOne( addrP, stream, typ );
|
addrFromStreamOne( addrP, stream, typ );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,8 +758,7 @@ addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addrP )
|
||||||
stream_putU8( stream, addrP->_conTypes );
|
stream_putU8( stream, addrP->_conTypes );
|
||||||
|
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
XP_U32 state = 0;
|
for ( XP_U32 st = 0; addr_iter( addrP, &typ, &st ); ) {
|
||||||
while ( addr_iter( addrP, &typ, &state ) ) {
|
|
||||||
addrToStreamOne( stream, typ, addrP );
|
addrToStreamOne( stream, typ, addrP );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2258,40 +2253,32 @@ static XP_Bool
|
||||||
addr_iter( const CommsAddrRec* addr, CommsConnType* typp, XP_U32* state )
|
addr_iter( const CommsAddrRec* addr, CommsConnType* typp, XP_U32* state )
|
||||||
{
|
{
|
||||||
CommsConnType typ = *state;
|
CommsConnType typ = *state;
|
||||||
XP_U16 flags = addr->_conTypes;
|
XP_U16 conTypes = addr->_conTypes;
|
||||||
while ( ++typ < COMMS_CONN_NTYPES ) {
|
while ( ++typ < COMMS_CONN_NTYPES ) {
|
||||||
*state = typ;
|
*state = typ;
|
||||||
XP_U16 mask = 1 << (typ - 1);
|
XP_U16 mask = 1 << (typ - 1);
|
||||||
if ( mask == (flags & mask) ) {
|
if ( mask == (conTypes & mask) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XP_Bool result = typ < COMMS_CONN_NTYPES;
|
XP_Bool found = typ < COMMS_CONN_NTYPES;
|
||||||
if ( result ) {
|
if ( found ) {
|
||||||
*typp = typ;
|
*typp = typ;
|
||||||
}
|
}
|
||||||
XP_LOGF( "%s(flag=%x)=>%d (typ=%s)", __func__, flags, result, ConnType2Str( typ ) );
|
XP_LOGF( "%s(flag=%x)=>%d (typ=%s)", __func__, conTypes, found, ConnType2Str( typ ) );
|
||||||
return result;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommsConnType
|
CommsConnType
|
||||||
addr_getType( const CommsAddrRec* addr )
|
addr_getType( const CommsAddrRec* addr )
|
||||||
{
|
{
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
XP_U16 flags = addr->_conTypes;
|
XP_U32 st = 0;
|
||||||
if ( 0 == flags ) {
|
if ( !addr_iter( addr, &typ, &st ) ) {
|
||||||
typ = COMMS_CONN_NONE;
|
typ = COMMS_CONN_NONE;
|
||||||
} else {
|
|
||||||
for ( typ = COMMS_CONN_NONE + 1; typ < COMMS_CONN_NTYPES; ++typ ) {
|
|
||||||
XP_U16 mask = (1 << (typ - 1));
|
|
||||||
if ( 0 != (flags & mask) ) {
|
|
||||||
XP_ASSERT( 0 == (flags & ~mask )); /* confirm only bit set */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
XP_ASSERT( !addr_iter( addr, &typ, &st ) ); /* shouldn't be a second -- yet */
|
||||||
}
|
LOG_RETURNF( "%s", ConnType2Str( typ ) );
|
||||||
XP_ASSERT( COMMS_CONN_NTYPES != typ );
|
|
||||||
// LOG_RETURNF( "%s", ConnType2Str( typ ) );
|
|
||||||
return typ;
|
return typ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue