Skip to content

Commit 3998de9

Browse files
Merge pull request #67 from yegorich/fix-warnings
Fix and forbid unused variable warnings
2 parents a1c5fdc + 6e320ea commit 3998de9

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ add_compile_options(-Wall -pedantic -Wextra)
1919
add_compile_options(-Werror=unused-label)
2020
add_compile_options(-Werror=unused-parameter)
2121
add_compile_options(-Werror=strict-prototypes)
22+
add_compile_options(-Werror=unused-variable)
23+
add_compile_options(-Werror=unused-but-set-variable)
2224

2325
set(SOURCES
2426
colors.c

main.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,9 @@ int main(int argc, char *argv[])
907907
int c = 0;
908908
int count = -1, curncount = 0;
909909
double wait = 1.0;
910+
#if HAVE_NCURSES
910911
char wait_set = 0;
912+
#endif
911913
int audible = 0;
912914
int ok = 0, err = 0;
913915
double timeout = 30.0;
@@ -932,7 +934,9 @@ int main(int argc, char *argv[])
932934
int Bps_limit = -1;
933935
char show_bytes_xfer = 0, show_fp = 0;
934936
SSL *ssl_h = NULL;
937+
#if HAVE_OPENSSL
935938
BIO *s_bio = NULL;
939+
#endif
936940
struct sockaddr_in *bind_to = NULL;
937941
struct sockaddr_in bind_to_4;
938942
struct sockaddr_in6 bind_to_6;
@@ -953,14 +957,18 @@ int main(int argc, char *argv[])
953957
aggregate_t *aggregates = NULL;
954958
char *au_dummy = NULL, *ap_dummy = NULL;
955959
stats_t t_connect, t_request, t_total, t_resolve, t_write, t_ssl, t_close, stats_to, tcp_rtt_stats, stats_header_size;
960+
#if HAVE_NCURSES
956961
char first_resolve = 1;
957962
double graph_limit = MY_DOUBLE_INF;
958963
char nc_graph = 1;
959-
char adaptive_interval = 0;
960964
double show_slow_log = MY_DOUBLE_INF;
965+
#endif
966+
char adaptive_interval = 0;
961967
char use_tcp_nodelay = 1;
962968
int max_mtu = -1;
969+
#ifdef linux
963970
int write_sleep = 500; /* in us (microseconds), determines resolution of transmit time determination */
971+
#endif
964972
char keep_cookies = 0;
965973
char abbreviate = 0;
966974
char *divert_connect = NULL;
@@ -970,14 +978,14 @@ int main(int argc, char *argv[])
970978
int n_additional_headers = 0;
971979
#if HAVE_OPENSSL
972980
SSL_CTX *client_ctx = NULL;
973-
#endif
974981
const char *ca_path = NULL;
982+
char ignore_ssl_errors = 0;
983+
#endif
975984
struct sockaddr_in6 addr;
976985
struct addrinfo *ai = NULL, *ai_use = NULL;
977986
struct addrinfo *ai_proxy = NULL, *ai_use_proxy = NULL;
978987
char http2 = 0;
979988
char use_median = 0;
980-
char ignore_ssl_errors = 0;
981989

982990
static struct option long_options[] =
983991
{
@@ -1087,9 +1095,11 @@ int main(int argc, char *argv[])
10871095
http2 = 1;
10881096
break;
10891097

1098+
#if HAVE_OPENSSL
10901099
case 26:
10911100
ca_path = optarg;
10921101
break;
1102+
#endif
10931103

10941104
case 27:
10951105
use_median = 1;
@@ -1145,17 +1155,21 @@ int main(int argc, char *argv[])
11451155
break;
11461156
#endif
11471157

1158+
#if HAVE_NCURSES
11481159
case 13:
11491160
show_slow_log = atof(optarg);
11501161
break;
1162+
#endif
11511163

11521164
case 12:
11531165
adaptive_interval = 1;
11541166
break;
11551167

1168+
#if HAVE_NCURSES
11561169
case 11:
11571170
graph_limit = atof(optarg);
11581171
break;
1172+
#endif
11591173

11601174
#if HAVE_NCURSES
11611175
case 'K':
@@ -1318,12 +1332,14 @@ int main(int argc, char *argv[])
13181332
count = atoi(optarg);
13191333
break;
13201334

1335+
#if HAVE_NCURSES
13211336
case 'i':
13221337
wait = atof(optarg);
13231338
if (wait < 0.0)
13241339
error_exit(gettext("-i cannot have a value smaller than zero"));
13251340
wait_set = 1;
13261341
break;
1342+
#endif
13271343

13281344
case 't':
13291345
timeout = atof(optarg);
@@ -1341,11 +1357,13 @@ int main(int argc, char *argv[])
13411357
audible = 1;
13421358
break;
13431359

1360+
#if HAVE_NCURSES
13441361
case 'f':
13451362
wait = 0;
13461363
wait_set = 1;
13471364
adaptive_interval = 0;
13481365
break;
1366+
#endif
13491367

13501368
case 'G':
13511369
get_instead_of_head = 1;
@@ -1369,9 +1387,11 @@ int main(int argc, char *argv[])
13691387
show_statuscodes = 1;
13701388
break;
13711389

1390+
#if HAVE_OPENSSL
13721391
case 'k':
13731392
ignore_ssl_errors = 1;
13741393
break;
1394+
#endif
13751395

13761396
case 'V':
13771397
version();
@@ -1648,7 +1668,9 @@ int main(int argc, char *argv[])
16481668
char *sc = NULL, *scdummy = NULL;
16491669
char *fp = NULL;
16501670
int re_tx = 0, pmtu = 0, recv_tos = 0;
1671+
#if defined(linux) || defined(__FreeBSD__)
16511672
socklen_t recv_tos_len = sizeof recv_tos;
1673+
#endif
16521674

16531675
dstart = get_ts();
16541676

0 commit comments

Comments
 (0)