From 3db2fad1ae84c7235507bf1adf471461856ddee4 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 17 Sep 2012 03:24:32 -0700 Subject: [PATCH] Fix all warnings found via clang. --- example/memcached_light.cc | 6 +- libmemcached/csl/parser.cc | 140 ++++++++++++------------ libmemcached/csl/parser.yy | 10 +- libmemcached/csl/scanner.cc | 62 +++++------ libmemcached/csl/scanner.h | 13 +-- libmemcached/error.cc | 4 + libmemcached/stats.cc | 4 +- libmemcachedutil/pool.cc | 2 +- libtest/cmdline.cc | 2 +- libtest/cpu.cc | 2 +- libtest/fatal.cc | 4 + libtest/server_container.h | 2 +- tests/libmemcached-1.0/generate.cc | 6 +- tests/libmemcached-1.0/mem_functions.cc | 10 +- tests/libmemcached-1.0/parser.cc | 2 +- util/log.hpp | 3 + 16 files changed, 138 insertions(+), 134 deletions(-) diff --git a/example/memcached_light.cc b/example/memcached_light.cc index 7a29db26..3f14c8ee 100644 --- a/example/memcached_light.cc +++ b/example/memcached_light.cc @@ -135,7 +135,7 @@ static void drive_client(memcached_socket_t fd, short, void *arg) flags|= EV_READ; } - event_set(&client->event, (intptr_t)fd, flags, drive_client, client); + event_set(&client->event, int(fd), flags, drive_client, client); event_base_set(event_base, &client->event); if (event_add(&client->event, 0) == -1) @@ -184,7 +184,7 @@ static void accept_handler(memcached_socket_t fd, short, void *arg) struct connection *client = &socket_userdata_map[sock]; client->userdata= c; - event_set(&client->event, (intptr_t)sock, EV_READ, drive_client, client); + event_set(&client->event, int(sock), EV_READ, drive_client, client); event_base_set(event_base, &client->event); if (event_add(&client->event, 0) == -1) { @@ -605,7 +605,7 @@ int main(int argc, char **argv) struct connection *conn= &socket_userdata_map[server_sockets[xx]]; conn->userdata= protocol_handle; - event_set(&conn->event, (intptr_t)server_sockets[xx], EV_READ | EV_PERSIST, accept_handler, conn); + event_set(&conn->event, int(server_sockets[xx]), EV_READ | EV_PERSIST, accept_handler, conn); event_base_set(event_base, &conn->event); if (event_add(&conn->event, 0) == -1) diff --git a/libmemcached/csl/parser.cc b/libmemcached/csl/parser.cc index 87d08dbe..fdc4ca67 100644 --- a/libmemcached/csl/parser.cc +++ b/libmemcached/csl/parser.cc @@ -1557,28 +1557,28 @@ yyreduce: { case 4: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 195 "libmemcached/csl/parser.yy" { } break; case 5: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 197 "libmemcached/csl/parser.yy" { } break; case 6: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 199 "libmemcached/csl/parser.yy" { } break; case 7: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 201 "libmemcached/csl/parser.yy" { context->set_end(); @@ -1588,7 +1588,7 @@ yyreduce: case 8: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 206 "libmemcached/csl/parser.yy" { context->rc= MEMCACHED_PARSE_USER_ERROR; @@ -1598,7 +1598,7 @@ yyreduce: case 9: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 211 "libmemcached/csl/parser.yy" { memcached_reset(context->memc); @@ -1607,7 +1607,7 @@ yyreduce: case 10: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 215 "libmemcached/csl/parser.yy" { yydebug= 1; @@ -1616,7 +1616,7 @@ yyreduce: case 11: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 219 "libmemcached/csl/parser.yy" { if ((context->rc= memcached_parse_configure_file(*context->memc, (yyvsp[(3) - (3)].string).c_str, (yyvsp[(3) - (3)].string).size)) != MEMCACHED_SUCCESS) @@ -1628,10 +1628,10 @@ yyreduce: case 12: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 230 "libmemcached/csl/parser.yy" { - if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number)))) + if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), uint32_t((yyvsp[(4) - (4)].number))))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", (yyvsp[(2) - (4)].server).c_str, uint32_t((yyvsp[(3) - (4)].number))); @@ -1643,10 +1643,10 @@ yyreduce: case 13: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 240 "libmemcached/csl/parser.yy" { - if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number)))) + if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), uint32_t((yyvsp[(4) - (4)].number))))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", (yyvsp[(2) - (4)].server).c_str, uint32_t((yyvsp[(3) - (4)].number))); @@ -1658,10 +1658,10 @@ yyreduce: case 14: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 250 "libmemcached/csl/parser.yy" { - if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, (yyvsp[(2) - (3)].string).c_str, (yyvsp[(3) - (3)].number)))) + if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, (yyvsp[(2) - (3)].string).c_str, uint32_t((yyvsp[(3) - (3)].number))))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", (yyvsp[(2) - (3)].string).c_str); @@ -1672,7 +1672,7 @@ yyreduce: case 15: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 259 "libmemcached/csl/parser.yy" { memcached_set_configuration_file(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size); @@ -1681,25 +1681,25 @@ yyreduce: case 16: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 263 "libmemcached/csl/parser.yy" { - context->memc->configure.initial_pool_size= (yyvsp[(2) - (2)].number); + context->memc->configure.initial_pool_size= uint32_t((yyvsp[(2) - (2)].number)); } break; case 17: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 267 "libmemcached/csl/parser.yy" { - context->memc->configure.max_pool_size= (yyvsp[(2) - (2)].number); + context->memc->configure.max_pool_size= uint32_t((yyvsp[(2) - (2)].number)); } break; case 19: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 275 "libmemcached/csl/parser.yy" { if (memcached_callback_get(context->memc, MEMCACHED_CALLBACK_PREFIX_KEY, NULL)) @@ -1716,7 +1716,7 @@ yyreduce: case 20: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 287 "libmemcached/csl/parser.yy" { memcached_flag(*context->memc, MEMCACHED_FLAG_IS_FETCHING_VERSION, true); @@ -1725,7 +1725,7 @@ yyreduce: case 21: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 291 "libmemcached/csl/parser.yy" { // Check to see if DISTRIBUTION has already been set @@ -1743,7 +1743,7 @@ yyreduce: case 22: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 304 "libmemcached/csl/parser.yy" { // Check to see if DISTRIBUTION has already been set @@ -1761,7 +1761,7 @@ yyreduce: case 23: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 317 "libmemcached/csl/parser.yy" { if (context->set_hash((yyvsp[(2) - (2)].hash)) == false) @@ -1773,7 +1773,7 @@ yyreduce: case 24: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 324 "libmemcached/csl/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (2)].behavior), (yyvsp[(2) - (2)].number))) != MEMCACHED_SUCCESS) @@ -1785,7 +1785,7 @@ yyreduce: case 25: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 331 "libmemcached/csl/parser.yy" { if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (1)].behavior), true)) != MEMCACHED_SUCCESS) @@ -1799,7 +1799,7 @@ yyreduce: case 26: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 340 "libmemcached/csl/parser.yy" { } @@ -1807,7 +1807,7 @@ yyreduce: case 27: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 346 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS; @@ -1816,7 +1816,7 @@ yyreduce: case 28: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 350 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT; @@ -1825,7 +1825,7 @@ yyreduce: case 29: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 354 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK; @@ -1834,7 +1834,7 @@ yyreduce: case 30: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 358 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK; @@ -1843,7 +1843,7 @@ yyreduce: case 31: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 362 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH; @@ -1852,7 +1852,7 @@ yyreduce: case 32: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 366 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS; @@ -1861,7 +1861,7 @@ yyreduce: case 33: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 370 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_POLL_TIMEOUT; @@ -1870,7 +1870,7 @@ yyreduce: case 34: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 374 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RCV_TIMEOUT; @@ -1879,7 +1879,7 @@ yyreduce: case 35: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 378 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RETRY_TIMEOUT; @@ -1888,7 +1888,7 @@ yyreduce: case 36: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 382 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SND_TIMEOUT; @@ -1897,7 +1897,7 @@ yyreduce: case 37: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 386 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE; @@ -1906,7 +1906,7 @@ yyreduce: case 38: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 390 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE; @@ -1915,7 +1915,7 @@ yyreduce: case 39: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 397 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL; @@ -1924,7 +1924,7 @@ yyreduce: case 40: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 401 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS; @@ -1933,7 +1933,7 @@ yyreduce: case 41: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 405 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY; @@ -1942,7 +1942,7 @@ yyreduce: case 42: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 409 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_NOREPLY; @@ -1951,7 +1951,7 @@ yyreduce: case 43: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 413 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ; @@ -1960,7 +1960,7 @@ yyreduce: case 44: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 417 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SORT_HOSTS; @@ -1969,7 +1969,7 @@ yyreduce: case 45: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 421 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_SUPPORT_CAS; @@ -1978,7 +1978,7 @@ yyreduce: case 46: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 425 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_NODELAY; @@ -1987,7 +1987,7 @@ yyreduce: case 47: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 429 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPALIVE; @@ -1996,7 +1996,7 @@ yyreduce: case 48: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 433 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPIDLE; @@ -2005,7 +2005,7 @@ yyreduce: case 49: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 437 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_USE_UDP; @@ -2014,7 +2014,7 @@ yyreduce: case 50: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 441 "libmemcached/csl/parser.yy" { (yyval.behavior)= MEMCACHED_BEHAVIOR_VERIFY_KEY; @@ -2023,35 +2023,35 @@ yyreduce: case 51: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 447 "libmemcached/csl/parser.yy" { (yyval.number)= MEMCACHED_DEFAULT_PORT;} break; case 52: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 449 "libmemcached/csl/parser.yy" { } break; case 53: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 453 "libmemcached/csl/parser.yy" { (yyval.number)= 1; } break; case 54: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 455 "libmemcached/csl/parser.yy" { } break; case 55: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 460 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_MD5; @@ -2060,7 +2060,7 @@ yyreduce: case 56: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 464 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_CRC; @@ -2069,7 +2069,7 @@ yyreduce: case 57: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 468 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1_64; @@ -2078,7 +2078,7 @@ yyreduce: case 58: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 472 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1A_64; @@ -2087,7 +2087,7 @@ yyreduce: case 59: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 476 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1_32; @@ -2096,7 +2096,7 @@ yyreduce: case 60: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 480 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_FNV1A_32; @@ -2105,7 +2105,7 @@ yyreduce: case 61: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 484 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_HSIEH; @@ -2114,7 +2114,7 @@ yyreduce: case 62: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 488 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_MURMUR; @@ -2123,7 +2123,7 @@ yyreduce: case 63: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 492 "libmemcached/csl/parser.yy" { (yyval.hash)= MEMCACHED_HASH_JENKINS; @@ -2132,7 +2132,7 @@ yyreduce: case 64: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 499 "libmemcached/csl/parser.yy" { (yyval.string)= (yyvsp[(1) - (1)].string); @@ -2141,7 +2141,7 @@ yyreduce: case 65: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 503 "libmemcached/csl/parser.yy" { (yyval.string)= (yyvsp[(1) - (1)].string); @@ -2150,7 +2150,7 @@ yyreduce: case 66: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 510 "libmemcached/csl/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_CONSISTENT; @@ -2159,7 +2159,7 @@ yyreduce: case 67: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 514 "libmemcached/csl/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_MODULA; @@ -2168,7 +2168,7 @@ yyreduce: case 68: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 518 "libmemcached/csl/parser.yy" { (yyval.distribution)= MEMCACHED_DISTRIBUTION_RANDOM; @@ -2177,7 +2177,7 @@ yyreduce: -/* Line 1806 of yacc.c */ +/* Line 1821 of yacc.c */ #line 2182 "libmemcached/csl/parser.cc" default: break; } diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index d263aea4..a5131d7f 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -228,7 +228,7 @@ statement: expression: SERVER HOSTNAME optional_port optional_weight { - if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) + if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, uint32_t($4)))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", $2.c_str, uint32_t($3)); @@ -238,7 +238,7 @@ expression: } | SERVER IPADDRESS optional_port optional_weight { - if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, $4))) + if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, $2.c_str, $3, uint32_t($4)))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add server: %s:%u", $2.c_str, uint32_t($3)); @@ -248,7 +248,7 @@ expression: } | SOCKET string optional_weight { - if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, $3))) + if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, $2.c_str, uint32_t($3)))) { char buffer[1024]; snprintf(buffer, sizeof(buffer), "Failed to add socket: %s", $2.c_str); @@ -261,11 +261,11 @@ expression: } | POOL_MIN NUMBER { - context->memc->configure.initial_pool_size= $2; + context->memc->configure.initial_pool_size= uint32_t($2); } | POOL_MAX NUMBER { - context->memc->configure.max_pool_size= $2; + context->memc->configure.max_pool_size= uint32_t($2); } | behaviors ; diff --git a/libmemcached/csl/scanner.cc b/libmemcached/csl/scanner.cc index c391f48e..6e4979b0 100644 --- a/libmemcached/csl/scanner.cc +++ b/libmemcached/csl/scanner.cc @@ -65,6 +65,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -188,6 +189,11 @@ typedef void* yyscan_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -210,11 +216,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state @@ -232,7 +233,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -311,7 +312,7 @@ static void config__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanne YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); void *config_alloc (yy_size_t ,yyscan_t yyscanner ); void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -362,7 +363,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; @@ -1090,7 +1091,7 @@ static yyconst flex_int16_t yy_chk[1815] = #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM) #define YY_NO_INPUT 1 -#line 1094 "libmemcached/csl/scanner.cc" +#line 1095 "libmemcached/csl/scanner.cc" #define INITIAL 0 @@ -1119,8 +1120,8 @@ struct yyguts_t size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; - int yy_n_chars; - int yyleng_r; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -1173,7 +1174,7 @@ FILE *config_get_out (yyscan_t yyscanner ); void config_set_out (FILE * out_str ,yyscan_t yyscanner ); -int config_get_leng (yyscan_t yyscanner ); +yy_size_t config_get_leng (yyscan_t yyscanner ); char *config_get_text (yyscan_t yyscanner ); @@ -1181,10 +1182,6 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -int config_get_column (yyscan_t yyscanner ); - -void config_set_column (int column_no ,yyscan_t yyscanner ); - YYSTYPE * config_get_lval (yyscan_t yyscanner ); void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); @@ -1229,7 +1226,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1240,7 +1237,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1332,7 +1329,7 @@ YY_DECL -#line 1336 "libmemcached/csl/scanner.cc" +#line 1333 "libmemcached/csl/scanner.cc" yylval = yylval_param; @@ -1775,7 +1772,7 @@ YY_RULE_SETUP #line 217 "libmemcached/csl/scanner.l" ECHO; YY_BREAK -#line 1779 "libmemcached/csl/scanner.cc" +#line 1776 "libmemcached/csl/scanner.cc" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1963,7 +1960,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1977,7 +1974,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2008,7 +2005,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); + yyg->yy_n_chars, num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; } @@ -2134,7 +2131,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -2158,7 +2155,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) case EOB_ACT_END_OF_FILE: { if ( config_wrap(yyscanner ) ) - return EOF; + return 0; if ( ! yyg->yy_did_buffer_switch_on_eof ) YY_NEW_FILE; @@ -2416,7 +2413,7 @@ void config_pop_buffer_state (yyscan_t yyscanner) */ static void config_ensure_buffer_stack (yyscan_t yyscanner) { - int num_to_alloc; + yy_size_t num_to_alloc; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; if (!yyg->yy_buffer_stack) { @@ -2514,12 +2511,11 @@ YY_BUFFER_STATE config__scan_string (yyconst char * yystr , yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; - yy_size_t n; - int i; + yy_size_t n, i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; @@ -2548,10 +2544,10 @@ YY_BUFFER_STATE config__scan_bytes (yyconst char * yybytes, int _yybytes_len , #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +static __attribute__((noreturn)) void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ @@ -2629,7 +2625,7 @@ FILE *config_get_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int config_get_leng (yyscan_t yyscanner) +yy_size_t config_get_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; diff --git a/libmemcached/csl/scanner.h b/libmemcached/csl/scanner.h index ab895707..74586412 100644 --- a/libmemcached/csl/scanner.h +++ b/libmemcached/csl/scanner.h @@ -69,6 +69,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -179,7 +180,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -223,7 +224,7 @@ void config_pop_buffer_state (yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); YY_BUFFER_STATE config__scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); +YY_BUFFER_STATE config__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner ); void *config_alloc (yy_size_t ,yyscan_t yyscanner ); void *config_realloc (void *,yy_size_t ,yyscan_t yyscanner ); @@ -278,7 +279,7 @@ FILE *config_get_out (yyscan_t yyscanner ); void config_set_out (FILE * out_str ,yyscan_t yyscanner ); -int config_get_leng (yyscan_t yyscanner ); +yy_size_t config_get_leng (yyscan_t yyscanner ); char *config_get_text (yyscan_t yyscanner ); @@ -286,10 +287,6 @@ int config_get_lineno (yyscan_t yyscanner ); void config_set_lineno (int line_number ,yyscan_t yyscanner ); -int config_get_column (yyscan_t yyscanner ); - -void config_set_column (int column_no ,yyscan_t yyscanner ); - YYSTYPE * config_get_lval (yyscan_t yyscanner ); void config_set_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); @@ -358,6 +355,6 @@ extern int config_lex \ #line 217 "libmemcached/csl/scanner.l" -#line 362 "libmemcached/csl/scanner.h" +#line 359 "libmemcached/csl/scanner.h" #undef config_IN_HEADER #endif /* config_HEADER_H */ diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 6ae5cba1..d15f9843 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -218,6 +218,10 @@ memcached_return_t memcached_set_error(org::libmemcached::Instance& self, memcac return memcached_set_error(self, rc, at, tmp); } +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif + memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); diff --git a/libmemcached/stats.cc b/libmemcached/stats.cc index ab00d4b8..29d9a425 100644 --- a/libmemcached/stats.cc +++ b/libmemcached/stats.cc @@ -95,11 +95,11 @@ static memcached_return_t set_data(memcached_stat_st *memc_stat, const char *key if (temp <= INT32_MAX and ( sizeof(pid_t) == sizeof(int32_t) )) { - memc_stat->pid= temp; + memc_stat->pid= pid_t(temp); } else if (temp > -1) { - memc_stat->pid= temp; + memc_stat->pid= pid_t(temp); } else { diff --git a/libmemcachedutil/pool.cc b/libmemcachedutil/pool.cc index 8816815a..a3f79ecf 100644 --- a/libmemcachedutil/pool.cc +++ b/libmemcachedutil/pool.cc @@ -59,7 +59,7 @@ struct memcached_pool_st master(master_arg), server_pool(NULL), firstfree(-1), - size(max_arg), + size(uint32_t(max_arg)), current_size(0), _owns_master(false) { diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc index 5cb76bff..5c3d09f2 100644 --- a/libtest/cmdline.cc +++ b/libtest/cmdline.cc @@ -623,7 +623,7 @@ void Application::Pipe::reset() close(READ); close(WRITE); -#if HAVE_PIPE2 +#if defined(HAVE_PIPE2) && HAVE_PIPE2 if (pipe2(_pipe_fd, O_NONBLOCK) == -1) #else if (pipe(_pipe_fd) == -1) diff --git a/libtest/cpu.cc b/libtest/cpu.cc index bfbf5ced..abf2b2ed 100644 --- a/libtest/cpu.cc +++ b/libtest/cpu.cc @@ -48,7 +48,7 @@ namespace libtest { size_t number_of_cpus() { size_t number_of_cpu= 1; -#if TARGET_OS_LINUX +#if defined(TARGET_OS_LINUX) && TARGET_OS_LINUX number_of_cpu= sysconf(_SC_NPROCESSORS_ONLN); #elif defined(HAVE_SYS_SYSCTL_H) && defined(CTL_HW) && defined(HW_NCPU) && defined(HW_AVAILCPU) && defined(HW_NCPU) int mib[4]; diff --git a/libtest/fatal.cc b/libtest/fatal.cc index 9517f778..cdccff82 100644 --- a/libtest/fatal.cc +++ b/libtest/fatal.cc @@ -48,6 +48,10 @@ exception::exception(const char *file_, int line_, const char *func_) : { } +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif + fatal::fatal(const char *file_, int line_, const char *func_, const char *format, ...) : exception(file_, line_, func_) { diff --git a/libtest/server_container.h b/libtest/server_container.h index a0287e6d..b8743033 100644 --- a/libtest/server_container.h +++ b/libtest/server_container.h @@ -73,7 +73,7 @@ public: uint32_t count() const { - return servers.size(); + return uint32_t(servers.size()); } void restart(); diff --git a/tests/libmemcached-1.0/generate.cc b/tests/libmemcached-1.0/generate.cc index 59fa2b2a..37f4a36e 100644 --- a/tests/libmemcached-1.0/generate.cc +++ b/tests/libmemcached-1.0/generate.cc @@ -92,7 +92,7 @@ test_return_t generate_large_pairs(memcached_st *memc) } memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true); - unsigned int check_execute= execute_set(memc, global_pairs, global_count); + unsigned int check_execute= execute_set(memc, global_pairs, (unsigned int)global_count); test_true(check_execute > (global_count / 2)); @@ -103,7 +103,7 @@ test_return_t generate_data(memcached_st *memc) { test_compare(TEST_SUCCESS, generate_pairs(memc)); - unsigned int check_execute= execute_set(memc, global_pairs, global_count); + unsigned int check_execute= execute_set(memc, global_pairs, (unsigned int)global_count); /* Possible false, positive, memcached may have ejected key/value based on * memory needs. */ @@ -117,7 +117,7 @@ test_return_t generate_data_with_stats(memcached_st *memc) { test_compare(TEST_SUCCESS, generate_pairs(memc)); - unsigned int check_execute= execute_set(memc, global_pairs, global_count); + unsigned int check_execute= execute_set(memc, global_pairs, (unsigned int)global_count); test_compare(check_execute, global_count); diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index a6adac1b..2155f7f3 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -598,7 +598,7 @@ test_return_t append_binary_test(memcached_st *memc) test_compare(value_length, sizeof(uint32_t) * count); test_compare(MEMCACHED_SUCCESS, rc); - for (uint32_t counter= count, *ptr= value; counter; counter--) + for (uint32_t counter= uint32_t(count), *ptr= value; counter; counter--) { test_compare(*ptr, store_list[count - counter]); ptr++; @@ -644,7 +644,7 @@ test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc) } else { - int which_key= random() %keys.size(); + int which_key= random() % int(keys.size()); size_t value_length; uint32_t flags; memcached_return_t rc; @@ -2634,7 +2634,7 @@ test_return_t user_supplied_bug20(memcached_st *memc) */ /* sighandler_t function that always asserts false */ -static void fail(int) +static __attribute__((noreturn)) void fail(int) { fatal_assert(0); } @@ -3167,7 +3167,7 @@ test_return_t noreply_test(memcached_st *memc) for (size_t x= 0; x < 100; ++x) { char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1]; - int check_length= (size_t)snprintf(key, sizeof(key), "%lu", (unsigned long)x); + int check_length= snprintf(key, sizeof(key), "%lu", (unsigned long)x); test_false((size_t)check_length >= sizeof(key) || check_length < 0); size_t len= (size_t)check_length; @@ -3222,7 +3222,7 @@ test_return_t noreply_test(memcached_st *memc) { char key[10]; - int check_length= (size_t)snprintf(key, sizeof(key), "%lu", (unsigned long)x); + int check_length= snprintf(key, sizeof(key), "%lu", (unsigned long)x); test_false((size_t)check_length >= sizeof(key) || check_length < 0); diff --git a/tests/libmemcached-1.0/parser.cc b/tests/libmemcached-1.0/parser.cc index a027f50e..f506a8f1 100644 --- a/tests/libmemcached-1.0/parser.cc +++ b/tests/libmemcached-1.0/parser.cc @@ -487,7 +487,7 @@ test_return_t random_statement_build_test(memcached_st*) { std::string random_options; - uint32_t number_of= random() % option_list.size(); + uint32_t number_of= random() % uint32_t(option_list.size()); for (uint32_t options= 0; options < number_of; options++) { size_t option_list_position= random() % option_list.size(); diff --git a/util/log.hpp b/util/log.hpp index 46ddaf45..662ef5f7 100644 --- a/util/log.hpp +++ b/util/log.hpp @@ -70,6 +70,9 @@ enum verbose_t VERBOSE_DEBUG= LOG_DEBUG // syslog:LOG_DEBUG }; +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif struct log_info_st { -- 2.30.2