summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2010-09-08 14:52:19 +0000
committerAndrey Nazarov <skuller@skuller.net>2010-09-08 14:52:19 +0000
commit2527d68e7054dc9c6301b8f7befc7e26ef2f9f46 (patch)
tree986984b352aaa2df72fb5a2121f34c3516eda1a1
parent8835f28384d51414340098b17b145d0165e36ae2 (diff)
Avoid extra endianess conversion in SV_MatchAddress.
-rw-r--r--source/sv_ccmds.c11
-rw-r--r--source/sv_main.c2
2 files changed, 8 insertions, 5 deletions
diff --git a/source/sv_ccmds.c b/source/sv_ccmds.c
index 28daa46..048f0e8 100644
--- a/source/sv_ccmds.c
+++ b/source/sv_ccmds.c
@@ -872,21 +872,24 @@ static qboolean parse_mask( const char *s, uint32_t *addr, uint32_t *mask ) {
return qfalse;
}
- *addr = BigLong( *( uint32_t * )address.ip );
- *mask = ~( ( 1 << ( 32 - bits ) ) - 1 );
+ *addr = *( uint32_t * )address.ip;
+ *mask = BigLong( ~( ( 1 << ( 32 - bits ) ) - 1 ) );
return qtrue;
}
static size_t format_mask( addrmatch_t *match, char *buf, size_t size ) {
byte ip[4];
+ uint32_t mask;
int i;
- *( uint32_t * )ip = BigLong( match->addr );
+ *( uint32_t * )ip = match->addr;
+ mask = BigLong( match->mask );
for( i = 0; i < 32; i++ ) {
- if( match->mask & ( 1 << i ) ) {
+ if( mask & ( 1 << i ) ) {
break;
}
}
+
return Q_snprintf( buf, size, "%d.%d.%d.%d/%d",
ip[0], ip[1], ip[2], ip[3], 32 - i );
}
diff --git a/source/sv_main.c b/source/sv_main.c
index 3b6ecc2..8c4f63b 100644
--- a/source/sv_main.c
+++ b/source/sv_main.c
@@ -282,7 +282,7 @@ static void SV_RateInit( ratelimit_t *r, const char *s ) {
}
addrmatch_t *SV_MatchAddress( list_t *list, netadr_t *address ) {
- uint32_t addr = BigLong( *( uint32_t * )address->ip );
+ uint32_t addr = *( uint32_t * )address->ip;
addrmatch_t *match;
LIST_FOR_EACH( addrmatch_t, match, list, entry ) {