From f9b94dcafa867c38dfaeb9b24f37b392d1ad80d8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 14 Jan 2015 13:55:34 +0100 Subject: [SERVER] Crank up warning levels of gcc and fix them all (mostly sign compare and some unused params) Also allow newline at end of alt-servers file without complaining about it not being a valid alt server definition. --- src/server/altservers.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/server/altservers.c') diff --git a/src/server/altservers.c b/src/server/altservers.c index 457405f..e9bdba5 100644 --- a/src/server/altservers.c +++ b/src/server/altservers.c @@ -66,8 +66,7 @@ int altservers_load() FILE *fp = fopen( name, "r" ); free( name ); if ( fp == NULL ) return -1; - while ( !feof( fp ) ) { - if ( fgets( buffer, 1000, fp ) == NULL ) break; + while ( fgets( buffer, 1000, fp ) != NULL ) { bool isPrivate = false; bool isClientOnly = false; for (line = buffer; *line != '\0'; ) { // Trim left and scan for "-" prefix @@ -76,9 +75,15 @@ int altservers_load() else if ( *line != ' ' && *line != '\t' ) break; line++; } + if ( *line == '\r' || *line == '\n' || *line == '\0' ) continue; // Ignore empty lines trim_right( line ); - space = strchr( line, ' ' ); - if ( space != NULL ) *space++ = '\0'; + space = line; + while ( *space != '\0' ) { + if ( *space == ' ' || *space == '\t' ) break; + space++; + } + if ( *space == '\0' ) space = NULL; + else *space++ = '\0'; if ( !parse_address( line, &host ) ) { if ( space != NULL ) *--space = ' '; memlogf( "[WARNING] Invalid entry in alt-servers file ignored: '%s'", line ); @@ -336,7 +341,7 @@ void altservers_serverFailed(const dnbd3_host_t * const host) * will update quite quickly. Needs to be improved some time, ie. by only * updating the rtt if the last update was at least X seconds ago. */ -static void *altservers_main(void *data) +static void *altservers_main(void *data UNUSED) { const int ALTS = 4; int ret, itLink, itAlt, numAlts; -- cgit v1.2.3-55-g7522