Remove unreachable code to make -Wunreachable-code on clang useful.

This commit is contained in:
Alex Young
2014-02-24 11:23:09 +00:00
parent 50ec8fb7cc
commit 374b4c616e
5 changed files with 13 additions and 12 deletions

View File

@@ -12,7 +12,15 @@ else
CFLAGS_EXTRA=-O2 CFLAGS_EXTRA=-O2
endif endif
CCFLAGS=-D_GNU_SOURCE=1 -Wall -Wextra -Werror-implicit-function-declaration -Wstrict-prototypes -Wno-missing-field-initializers $(CFLAGS_EXTRA) $(CFLAGS) # The -Wunreachable-code warning is only implemented in clang, but it
# doesn't break anything for gcc to see it.
WARNINGS=-Wall \
-Wextra \
-Werror-implicit-function-declaration \
-Wstrict-prototypes \
-Wno-missing-field-initializers \
-Wunreachable-code
CCFLAGS=-D_GNU_SOURCE=1 $(WARNINGS) $(CFLAGS_EXTRA) $(CFLAGS)
LLDFLAGS=-lrt -lev $(LDFLAGS_EXTRA) $(LDFLAGS) LLDFLAGS=-lrt -lev $(LDFLAGS_EXTRA) $(LDFLAGS)
CC?=gcc CC?=gcc

View File

@@ -126,7 +126,9 @@ void write_not_zeroes(struct client* client, uint64_t from, uint64_t len)
debug("(run adjusted to %d)", run); debug("(run adjusted to %d)", run);
} }
if (0) /* useful but expensive */ /*
// Useful but expensive
if (0)
{ {
uint64_t i; uint64_t i;
fprintf(stderr, "full map resolution=%d: ", map->resolution); fprintf(stderr, "full map resolution=%d: ", map->resolution);
@@ -139,6 +141,7 @@ void write_not_zeroes(struct client* client, uint64_t from, uint64_t len)
} }
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
*/
#define DO_READ(dst, len) ERROR_IF_NEGATIVE( \ #define DO_READ(dst, len) ERROR_IF_NEGATIVE( \
readloop( \ readloop( \

View File

@@ -220,7 +220,6 @@ void read_serve_param( int c, char **ip_addr, char **ip_port, char **file, char
case 'h': case 'h':
fprintf(stdout, "%s\n", serve_help_text ); fprintf(stdout, "%s\n", serve_help_text );
exit( 0 ); exit( 0 );
break;
case 'l': case 'l':
*ip_addr = optarg; *ip_addr = optarg;
break; break;
@@ -263,7 +262,6 @@ void read_listen_param( int c,
case 'h': case 'h':
fprintf(stdout, "%s\n", listen_help_text ); fprintf(stdout, "%s\n", listen_help_text );
exit(0); exit(0);
break;
case 'l': case 'l':
*ip_addr = optarg; *ip_addr = optarg;
break; break;
@@ -297,7 +295,6 @@ void read_readwrite_param( int c, char **ip_addr, char **ip_port, char **bind_ad
case 'h': case 'h':
fprintf(stdout, "%s\n", err_text ); fprintf(stdout, "%s\n", err_text );
exit( 0 ); exit( 0 );
break;
case 'l': case 'l':
*ip_addr = optarg; *ip_addr = optarg;
break; break;
@@ -331,7 +328,6 @@ void read_sock_param( int c, char **sock, char *help_text )
case 'h': case 'h':
fprintf( stdout, "%s\n", help_text ); fprintf( stdout, "%s\n", help_text );
exit( 0 ); exit( 0 );
break;
case 's': case 's':
*sock = optarg; *sock = optarg;
break; break;
@@ -362,7 +358,6 @@ void read_mirror_speed_param(
case 'h': case 'h':
fprintf( stdout, "%s\n", mirror_speed_help_text ); fprintf( stdout, "%s\n", mirror_speed_help_text );
exit( 0 ); exit( 0 );
break;
case 's': case 's':
*sock = optarg; *sock = optarg;
break; break;
@@ -394,7 +389,6 @@ void read_mirror_param(
case 'h': case 'h':
fprintf( stdout, "%s\n", mirror_help_text ); fprintf( stdout, "%s\n", mirror_help_text );
exit( 0 ); exit( 0 );
break;
case 's': case 's':
*sock = optarg; *sock = optarg;
break; break;
@@ -428,7 +422,6 @@ void read_break_param( int c, char **sock )
case 'h': case 'h':
fprintf( stdout, "%s\n", break_help_text ); fprintf( stdout, "%s\n", break_help_text );
exit( 0 ); exit( 0 );
break;
case 's': case 's':
*sock = optarg; *sock = optarg;
break; break;

View File

@@ -63,7 +63,5 @@ void do_remote_command(char* command, char* socket_name, int argc, char** argv)
print_response( response ); print_response( response );
exit(atoi(response)); exit(atoi(response));
close(remote);
} }

View File

@@ -42,7 +42,6 @@ void read_proxy_param(
case 'h' : case 'h' :
fprintf( stdout, "%s\n", proxy_help_text ); fprintf( stdout, "%s\n", proxy_help_text );
exit( 0 ); exit( 0 );
break;
case 'l': case 'l':
*downstream_addr = optarg; *downstream_addr = optarg;
break; break;