From 9bcd450682e20f0d704d86948bbb0880e414dfb4 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 17 Mar 2011 14:45:08 -0700 Subject: [PATCH] Merge in updates to make sure exit/return is done properly. --- clients/execute.c | 4 +- clients/memcapable.c | 12 +-- clients/memcat.c | 2 +- clients/memcp.c | 6 +- clients/memdump.c | 4 +- clients/memerror.c | 6 +- clients/memflush.c | 4 +- clients/memrm.c | 2 +- clients/memslap.c | 4 +- clients/ms_conn.c | 122 +++++++++++++------------- clients/ms_setting.c | 20 ++--- clients/ms_sigsegv.c | 10 +-- clients/ms_task.c | 8 +- clients/ms_thread.c | 6 +- example/memcached_light.c | 18 ++-- libhashkit/digest.c | 6 +- libhashkit/hsieh.c | 2 +- libhashkit/ketama.c | 8 +- libmemcached/behavior.c | 14 +-- libmemcached/hash.c | 4 +- libmemcached/hosts.c | 4 +- libmemcached/io.c | 4 +- libmemcached/protocol/ascii_handler.c | 6 +- libmemcached/util/pool.c | 2 +- libtest/test.c | 4 +- tests/atomsmasher.c | 8 +- tests/cpp_example.cc | 2 +- tests/start.c | 2 +- 28 files changed, 147 insertions(+), 147 deletions(-) diff --git a/clients/execute.c b/clients/execute.c index 0beaae4b..dbc102c6 100644 --- a/clients/execute.c +++ b/clients/execute.c @@ -116,7 +116,7 @@ unsigned int execute_mget(memcached_st *memc, fprintf(stderr, "Failed to execute mget: %s\n", memcached_strerror(memc, rc)); memcached_quit(memc); - return 0; + return EXIT_SUCCESS; } } else @@ -124,7 +124,7 @@ unsigned int execute_mget(memcached_st *memc, fprintf(stderr, "Failed to execute mget: %s\n", memcached_strerror(memc, rc)); memcached_quit(memc); - return 0; + return EXIT_SUCCESS; } return retrieved; diff --git a/clients/memcapable.c b/clients/memcapable.c index fdbc35c8..69d2557e 100644 --- a/clients/memcapable.c +++ b/clients/memcapable.c @@ -623,7 +623,7 @@ static enum test_return test_binary_quit_impl(uint8_t cc) PROTOCOL_BINARY_RESPONSE_SUCCESS)); } - /* Socket should be closed now, read should return 0 */ + /* Socket should be closed now, read should return EXIT_SUCCESS */ verify(timeout_io_op(sock, POLLIN, rsp.bytes, sizeof(rsp.bytes)) == 0); return TEST_PASS_RECONNECT; @@ -1211,7 +1211,7 @@ static enum test_return test_ascii_quit(void) /* Verify that quit works */ execute(send_string("quit\r\n")); - /* Socket should be closed now, read should return 0 */ + /* Socket should be closed now, read should return EXIT_SUCCESS */ char buffer[80]; verify(timeout_io_op(sock, POLLIN, buffer, sizeof(buffer)) == 0); return TEST_PASS_RECONNECT; @@ -1976,7 +1976,7 @@ int main(int argc, char **argv) if (timeout == 0) { fprintf(stderr, "Invalid timeout. Please specify a number for -t\n"); - return 1; + return EXIT_FAILURE; } break; case 'v': verbose= true; @@ -2004,7 +2004,7 @@ int main(int argc, char **argv) "\t-a\tOnly test the ascii protocol\n" "\t-b\tOnly test the binary protocol\n", argv[0]); - return 1; + return EXIT_FAILURE; } } @@ -2014,7 +2014,7 @@ int main(int argc, char **argv) { fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname, port, strerror(get_socket_errno())); - return 1; + return EXIT_FAILURE; } for (int ii= 0; testcases[ii].description != NULL; ++ii) @@ -2072,7 +2072,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname, port, strerror(get_socket_errno())); fprintf(stderr, "%d of %d tests failed\n", failed, total); - return 1; + return EXIT_FAILURE; } } } diff --git a/clients/memcat.c b/clients/memcat.c index 5c7a512f..8998ff0c 100644 --- a/clients/memcat.c +++ b/clients/memcat.c @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) if (!initialize_sasl(memc, opt_username, opt_passwd)) { memcached_free(memc); - return 1; + return EXIT_FAILURE; } while (optind < argc) diff --git a/clients/memcp.c b/clients/memcp.c index 5b0518e7..bce35ce6 100644 --- a/clients/memcp.c +++ b/clients/memcp.c @@ -63,13 +63,13 @@ static long strtol_wrapper(const char *nptr, int base, bool *error) || (errno != 0 && val == 0)) { *error= true; - return 0; + return EXIT_SUCCESS; } if (endptr == nptr) { *error= true; - return 0; + return EXIT_SUCCESS; } *error= false; @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) if (!initialize_sasl(memc, opt_username, opt_passwd)) { memcached_free(memc); - return 1; + return EXIT_FAILURE; } while (optind < argc) diff --git a/clients/memdump.c b/clients/memdump.c index 3b8027fd..67a2a540 100644 --- a/clients/memdump.c +++ b/clients/memdump.c @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) if (!initialize_sasl(memc, opt_username, opt_passwd)) { memcached_free(memc); - return 1; + return EXIT_FAILURE; } rc= memcached_dump(memc, callbacks, NULL, 1); @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) shutdown_sasl(); - return 0; + return EXIT_SUCCESS; } static void options_parse(int argc, char *argv[]) diff --git a/clients/memerror.c b/clients/memerror.c index 1ac09118..c30dd2e9 100644 --- a/clients/memerror.c +++ b/clients/memerror.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) options_parse(argc, argv); if (argc != 2) - return 1; + return EXIT_FAILURE; value= strtoul(argv[1], (char **) NULL, 10); @@ -46,10 +46,10 @@ int main(int argc, char *argv[]) else { fprintf(stderr, "Unknown Error Code\n"); - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } diff --git a/clients/memflush.c b/clients/memflush.c index 9f2b57c6..813bf9e1 100644 --- a/clients/memflush.c +++ b/clients/memflush.c @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) if (!initialize_sasl(memc, opt_username, opt_passwd)) { memcached_free(memc); - return 1; + return EXIT_FAILURE; } rc = memcached_flush(memc, opt_expire); @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) shutdown_sasl(); - return 0; + return EXIT_SUCCESS; } diff --git a/clients/memrm.c b/clients/memrm.c index 5ba5cdcd..8023a638 100644 --- a/clients/memrm.c +++ b/clients/memrm.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) if (!initialize_sasl(memc, opt_username, opt_passwd)) { memcached_free(memc); - return 1; + return EXIT_FAILURE; } while (optind < argc) diff --git a/clients/memslap.c b/clients/memslap.c index 94048802..37e93ec3 100644 --- a/clients/memslap.c +++ b/clients/memslap.c @@ -659,7 +659,7 @@ static int ms_check_para() return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_check_para */ @@ -904,5 +904,5 @@ int main(int argc, char *argv[]) ms_global_struct_destroy(); ms_setting_cleanup(); - return 0; + return EXIT_SUCCESS; } /* main */ diff --git a/clients/ms_conn.c b/clients/ms_conn.c index ae3145f5..e7ee3f12 100644 --- a/clients/ms_conn.c +++ b/clients/ms_conn.c @@ -224,7 +224,7 @@ static void ms_task_init(ms_conn_t *c) * @param c, pointer of the concurrency * @param is_udp, whether it's udp * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_udp_init(ms_conn_t *c, const bool is_udp) { @@ -260,7 +260,7 @@ static int ms_conn_udp_init(ms_conn_t *c, const bool is_udp) memset(c->udppkt, 0, MAX_UDP_PACKET * sizeof(ms_udppkt_t)); } - return 0; + return EXIT_SUCCESS; } /* ms_conn_udp_init */ @@ -272,7 +272,7 @@ static int ms_conn_udp_init(ms_conn_t *c, const bool is_udp) * @param read_buffer_size * @param is_udp, whether it's udp * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_init(ms_conn_t *c, const int init_state, @@ -381,7 +381,7 @@ static int ms_conn_init(ms_conn_t *c, atomic_add_32(&ms_stats.active_conns, 1); } - return 0; + return EXIT_SUCCESS; } /* ms_conn_init */ @@ -414,7 +414,7 @@ static void ms_warmup_num_init(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_item_win_init(ms_conn_t *c) { @@ -458,7 +458,7 @@ static int ms_item_win_init(ms_conn_t *c) ms_warmup_num_init(c); - return 0; + return EXIT_SUCCESS; } /* ms_item_win_init */ @@ -469,7 +469,7 @@ static int ms_item_win_init(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_sock_init(ms_conn_t *c) { @@ -553,7 +553,7 @@ static int ms_conn_sock_init(ms_conn_t *c) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_conn_sock_init */ @@ -563,7 +563,7 @@ static int ms_conn_sock_init(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_conn_event_init(ms_conn_t *c) { @@ -579,7 +579,7 @@ static int ms_conn_event_init(ms_conn_t *c) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_conn_event_init */ @@ -589,7 +589,7 @@ static int ms_conn_event_init(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_conn(ms_conn_t *c) { @@ -613,7 +613,7 @@ int ms_setup_conn(ms_conn_t *c) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_setup_conn */ @@ -707,7 +707,7 @@ static void ms_conn_close(ms_conn_t *c) * * @param ai, server address information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_new_socket(struct addrinfo *ai) { @@ -771,7 +771,7 @@ static void ms_maximize_sndbuf(const int sfd) * @param is_udp, whether it's udp * @param ret_sfd, the connected socket file descriptor * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_network_connect(ms_conn_t *c, char *srv_host_name, @@ -894,7 +894,7 @@ static int ms_network_connect(ms_conn_t *c, * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_reconn(ms_conn_t *c) { @@ -984,7 +984,7 @@ static int ms_reconn(ms_conn_t *c) c->alive_sfds--; } - return 0; + return EXIT_SUCCESS; } /* ms_reconn */ @@ -996,7 +996,7 @@ static int ms_reconn(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_reconn_socks(ms_conn_t *c) { @@ -1010,7 +1010,7 @@ int ms_reconn_socks(ms_conn_t *c) if ((c->total_sfds == 1) || (c->total_sfds == c->alive_sfds)) { - return 0; + return EXIT_SUCCESS; } for (uint32_t i= 0; i < c->total_sfds; i++) @@ -1065,7 +1065,7 @@ int ms_reconn_socks(ms_conn_t *c) } } - return 0; + return EXIT_SUCCESS; } /* ms_reconn_socks */ @@ -1137,7 +1137,7 @@ static int ms_tokenize_command(char *command, * @param c, pointer of the concurrency * @param command, the string responded by server * - * @return int, if the command completed return 0, else return + * @return int, if the command completed return EXIT_SUCCESS, else return * -1 */ static int ms_ascii_process_line(ms_conn_t *c, char *command) @@ -1312,7 +1312,7 @@ void ms_reset_conn(ms_conn_t *c, bool timeout) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_try_read_line(ms_conn_t *c) { @@ -1322,7 +1322,7 @@ static int ms_try_read_line(ms_conn_t *c) if ((uint64_t)c->rbytes < sizeof(c->binary_header)) { /* need more data! */ - return 0; + return EXIT_SUCCESS; } else { @@ -1352,7 +1352,7 @@ static int ms_try_read_line(ms_conn_t *c) fprintf(stderr, "Invalid magic: %x\n", c->binary_header.response.magic); ms_conn_set_state(c, conn_closing); - return 0; + return EXIT_SUCCESS; } /* process this complete response */ @@ -1377,11 +1377,11 @@ static int ms_try_read_line(ms_conn_t *c) assert(c->rcurr <= (c->rbuf + c->rsize)); if (c->rbytes == 0) - return 0; + return EXIT_SUCCESS; el= memchr(c->rcurr, '\n', (size_t)c->rbytes); if (! el) - return 0; + return EXIT_SUCCESS; cont= el + 1; if (((el - c->rcurr) > 1) && (*(el - 1) == '\r')) @@ -1635,7 +1635,7 @@ static int ms_udp_read(ms_conn_t *c, char *buf, int len) * close. * before reading, move the remaining incomplete fragment of a command * (if any) to the beginning of the buffer. - * return 0 if there's nothing to read on the first read. + * return EXIT_SUCCESS if there's nothing to read on the first read. */ /** @@ -1646,8 +1646,8 @@ static int ms_udp_read(ms_conn_t *c, char *buf, int len) * @param c, pointer of the concurrency * * @return int, - * return 0 if there's nothing to read on the first read. - * return 1 if get data + * return EXIT_SUCCESS if there's nothing to read on the first read. + * return EXIT_FAILURE if get data * return -1 if error happens */ static int ms_try_read_network(ms_conn_t *c) @@ -2013,7 +2013,7 @@ static void ms_complete_nread(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_add_msghdr(ms_conn_t *c) { @@ -2057,7 +2057,7 @@ static int ms_add_msghdr(ms_conn_t *c) return ms_add_iov(c, NULL, UDP_HEADER_SIZE); } - return 0; + return EXIT_SUCCESS; } /* ms_add_msghdr */ @@ -2067,7 +2067,7 @@ static int ms_add_msghdr(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_ensure_iov_space(ms_conn_t *c) { @@ -2094,7 +2094,7 @@ static int ms_ensure_iov_space(ms_conn_t *c) } } - return 0; + return EXIT_SUCCESS; } /* ms_ensure_iov_space */ @@ -2106,7 +2106,7 @@ static int ms_ensure_iov_space(ms_conn_t *c) * @param buf, the buffer includes data to send * @param len, the data length in the buffer * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_add_iov(ms_conn_t *c, const void *buf, int len) { @@ -2160,7 +2160,7 @@ static int ms_add_iov(ms_conn_t *c, const void *buf, int len) } while (leftover > 0); - return 0; + return EXIT_SUCCESS; } /* ms_add_iov */ @@ -2169,7 +2169,7 @@ static int ms_add_iov(ms_conn_t *c, const void *buf, int len) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_udp_headers(ms_conn_t *c) { @@ -2220,7 +2220,7 @@ static int ms_build_udp_headers(ms_conn_t *c) + UDP_HEADER_SIZE)); } - return 0; + return EXIT_SUCCESS; } /* ms_build_udp_headers */ @@ -2725,7 +2725,7 @@ void ms_event_handler(const int fd, const short which, void *arg) * @param c, pointer of the concurrency * @param cmd, command(get or set ) * - * @return int, if success, return the index, else return 0 + * @return int, if success, return the index, else return EXIT_SUCCESS */ static uint32_t ms_get_rep_sock_index(ms_conn_t *c, int cmd) { @@ -2734,7 +2734,7 @@ static uint32_t ms_get_rep_sock_index(ms_conn_t *c, int cmd) if (c->total_sfds == 1) { - return 0; + return EXIT_SUCCESS; } if (ms_setting.rep_write_srv == 0) @@ -2803,7 +2803,7 @@ static uint32_t ms_get_next_sock_index(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_update_conn_sock_event(ms_conn_t *c) { @@ -2867,7 +2867,7 @@ static int ms_update_conn_sock_event(ms_conn_t *c) } } - return 0; + return EXIT_SUCCESS; } /* ms_update_conn_sock_event */ @@ -2879,7 +2879,7 @@ static int ms_update_conn_sock_event(ms_conn_t *c) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item) { @@ -2924,7 +2924,7 @@ static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_build_ascii_write_buf_set */ @@ -2935,7 +2935,7 @@ static int ms_build_ascii_write_buf_set(ms_conn_t *c, ms_task_item_t *item) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item) { @@ -2979,7 +2979,7 @@ int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item) item->key_size + item->value_size); atomic_add_size(&ms_stats.cmd_set, 1); - return 0; + return EXIT_SUCCESS; } /* ms_mcd_set */ @@ -2991,7 +2991,7 @@ int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_ascii_write_buf_get(ms_conn_t *c, ms_task_item_t *item) { @@ -3006,7 +3006,7 @@ static int ms_build_ascii_write_buf_get(ms_conn_t *c, ms_task_item_t *item) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_build_ascii_write_buf_get */ @@ -3017,7 +3017,7 @@ static int ms_build_ascii_write_buf_get(ms_conn_t *c, ms_task_item_t *item) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item) { @@ -3059,7 +3059,7 @@ int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item) atomic_add_size(&ms_stats.cmd_get, 1); - return 0; + return EXIT_SUCCESS; } /* ms_mcd_get */ @@ -3069,7 +3069,7 @@ int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_ascii_write_buf_mlget(ms_conn_t *c) { @@ -3100,7 +3100,7 @@ static int ms_build_ascii_write_buf_mlget(ms_conn_t *c) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_build_ascii_write_buf_mlget */ @@ -3109,7 +3109,7 @@ static int ms_build_ascii_write_buf_mlget(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_mcd_mlget(ms_conn_t *c) { @@ -3159,7 +3159,7 @@ int ms_mcd_mlget(ms_conn_t *c) atomic_add_size(&ms_stats.cmd_get, 1); } - return 0; + return EXIT_SUCCESS; } /* ms_mcd_mlget */ @@ -3172,7 +3172,7 @@ int ms_mcd_mlget(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_bin_process_response(ms_conn_t *c) { @@ -3188,7 +3188,7 @@ static int ms_bin_process_response(ms_conn_t *c) { c->rvbytes= (int32_t)bodylen; c->readval= true; - return 1; + return EXIT_FAILURE; } else { @@ -3255,7 +3255,7 @@ static int ms_bin_process_response(ms_conn_t *c) } } - return 0; + return EXIT_SUCCESS; } /* ms_bin_process_response */ @@ -3321,7 +3321,7 @@ static void ms_add_key_to_iov(ms_conn_t *c, ms_task_item_t *item) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_bin_write_buf_set(ms_conn_t *c, ms_task_item_t *item) { @@ -3353,7 +3353,7 @@ static int ms_build_bin_write_buf_set(ms_conn_t *c, ms_task_item_t *item) } ms_add_iov(c, &ms_setting.char_block[value_offset], item->value_size); - return 0; + return EXIT_SUCCESS; } /* ms_build_bin_write_buf_set */ @@ -3365,7 +3365,7 @@ static int ms_build_bin_write_buf_set(ms_conn_t *c, ms_task_item_t *item) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_bin_write_buf_get(ms_conn_t *c, ms_task_item_t *item) { @@ -3375,7 +3375,7 @@ static int ms_build_bin_write_buf_get(ms_conn_t *c, ms_task_item_t *item) (uint32_t)item->key_size); ms_add_key_to_iov(c, item); - return 0; + return EXIT_SUCCESS; } /* ms_build_bin_write_buf_get */ @@ -3387,7 +3387,7 @@ static int ms_build_bin_write_buf_get(ms_conn_t *c, ms_task_item_t *item) * @param item, pointer of task item which includes the object * information * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_build_bin_write_buf_mlget(ms_conn_t *c) { @@ -3411,5 +3411,5 @@ static int ms_build_bin_write_buf_mlget(ms_conn_t *c) c->wcurr= c->wbuf; - return 0; + return EXIT_SUCCESS; } /* ms_build_bin_write_buf_mlget */ diff --git a/clients/ms_setting.c b/clients/ms_setting.c index d7099709..c3444c9a 100644 --- a/clients/ms_setting.c +++ b/clients/ms_setting.c @@ -195,7 +195,7 @@ static void ms_get_serverlist(char *str) /** * used to get the CPU count of the current system * - * @return return the cpu count if get, else return 1 + * @return return the cpu count if get, else return EXIT_FAILURE */ static uint32_t ms_get_cpu_count() { @@ -223,7 +223,7 @@ static uint32_t ms_get_cpu_count() #endif /* the system with one cpu at least */ - return 1; + return EXIT_FAILURE; } /* ms_get_cpu_count */ @@ -262,7 +262,7 @@ ms_conf_type_t ms_get_conf_type(char *line) * * @param line, string of one line * - * @return if success, return 1, else return 0 + * @return if success, return EXIT_FAILURE, else return EXIT_SUCCESS */ static int ms_is_line_data(char *line) { @@ -275,9 +275,9 @@ static int ms_is_line_data(char *line) begin_ptr++; } if ((begin_ptr[0] == '\0') || (begin_ptr[0] == '#')) - return 0; + return EXIT_SUCCESS; - return 1; + return EXIT_FAILURE; } /* ms_is_line_data */ @@ -287,14 +287,14 @@ static int ms_is_line_data(char *line) * @param line, string of one line * @param nread, length of the line * - * @return if it's EOF or not line data, return 0, else return 1 + * @return if it's EOF or not line data, return EXIT_SUCCESS, else return EXIT_FAILURE */ static int ms_read_is_data(char *line, ssize_t nread) { if ((nread == EOF) || ! ms_is_line_data(line)) - return 0; + return EXIT_SUCCESS; - return 1; + return EXIT_FAILURE; } /* ms_read_is_data */ @@ -575,7 +575,7 @@ static void ms_calc_avg_size() * @param distr, pointer of distribution structure array * @param length, length of the array * - * @return always return 0 + * @return always return EXIT_SUCCESS */ static int ms_shuffle_distr(ms_distr_t *distr, int length) { @@ -614,7 +614,7 @@ static int ms_shuffle_distr(ms_distr_t *distr, int length) } /* switch */ } - return 0; + return EXIT_SUCCESS; } /* ms_shuffle_distr */ diff --git a/clients/ms_sigsegv.c b/clients/ms_sigsegv.c index 60e1f59c..c9a366a0 100644 --- a/clients/ms_sigsegv.c +++ b/clients/ms_sigsegv.c @@ -61,7 +61,7 @@ static void ms_signal_int(int signum, siginfo_t *info, void *ptr) /** * redirect signal seg * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigsegv(void) { @@ -73,7 +73,7 @@ int ms_setup_sigsegv(void) if (sigaction(SIGSEGV, &action, NULL) < 0) { perror("sigaction"); - return 0; + return EXIT_SUCCESS; } return -1; @@ -83,7 +83,7 @@ int ms_setup_sigsegv(void) /** * redirect signal pipe * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigpipe(void) { @@ -97,7 +97,7 @@ int ms_setup_sigpipe(void) /** * redirect signal int * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigint(void) { @@ -109,7 +109,7 @@ int ms_setup_sigint(void) if (sigaction(SIGINT, &action_3, NULL) < 0) { perror("sigaction"); - return 0; + return EXIT_SUCCESS; } return -1; diff --git a/clients/ms_task.c b/clients/ms_task.c index 631c35ea..7e7921fc 100644 --- a/clients/ms_task.c +++ b/clients/ms_task.c @@ -1053,7 +1053,7 @@ static void ms_update_task_result(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ static int ms_run_getset_task(ms_conn_t *c) { @@ -1085,7 +1085,7 @@ static int ms_run_getset_task(ms_conn_t *c) return -1; } - return 0; + return EXIT_SUCCESS; } /* ms_run_getset_task */ @@ -1094,7 +1094,7 @@ static int ms_run_getset_task(ms_conn_t *c) * * @param c, pointer of the concurrency * - * @return int, if success, return 0, else return -1 + * @return int, if success, return EXIT_SUCCESS, else return -1 */ int ms_exec_task(struct conn *c) { @@ -1110,5 +1110,5 @@ int ms_exec_task(struct conn *c) } } - return 0; + return EXIT_SUCCESS; } /* ms_exec_task */ diff --git a/clients/ms_thread.c b/clients/ms_thread.c index 299412a1..1efe5cfb 100644 --- a/clients/ms_thread.c +++ b/clients/ms_thread.c @@ -146,7 +146,7 @@ static void ms_clock_handler(const int fd, const short which, void *arg) * * @param cpu, cpu index * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ static uint32_t ms_set_thread_cpu_affinity(uint32_t cpu) { @@ -175,7 +175,7 @@ static uint32_t ms_set_thread_cpu_affinity(uint32_t cpu) * * @param thread_ctx, pointer of the thread context structure * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ static int ms_setup_thread(ms_thread_ctx_t *thread_ctx) { @@ -231,7 +231,7 @@ static int ms_setup_thread(ms_thread_ctx_t *thread_ctx) } } - return 0; + return EXIT_SUCCESS; } /* ms_setup_thread */ diff --git a/example/memcached_light.c b/example/memcached_light.c index 84635b2a..8465ff28 100644 --- a/example/memcached_light.c +++ b/example/memcached_light.c @@ -180,7 +180,7 @@ static int server_socket(const char *port) else perror("getaddrinfo()"); - return 1; + return EXIT_FAILURE; } struct linger ling= {0, 0}; @@ -343,7 +343,7 @@ static protocol_binary_response_status unknown(const void *cookie, * * @param argc number of items in the argument vector * @param argv argument vector - * @return 0 on success, 1 otherwise + * @return EXIT_SUCCESS on success, 1 otherwise */ int main(int argc, char **argv) { @@ -356,7 +356,7 @@ int main(int argc, char **argv) if (event_base == NULL) { fprintf(stderr, "Failed to create an instance of libevent\n"); - return 1; + return EXIT_FAILURE; } /* @@ -389,14 +389,14 @@ int main(int argc, char **argv) default: (void)fprintf(stderr, "Usage: %s [-p port] [-v] [-1] [-c #clients] [-P pidfile]\n", argv[0]); - return 1; + return EXIT_FAILURE; } } if (! initialize_storage()) { /* Error message already printed */ - return 1; + return EXIT_FAILURE; } if (! global_options.has_port) @@ -423,7 +423,7 @@ int main(int argc, char **argv) if (num_server_sockets == 0) { fprintf(stderr, "I don't have any server sockets\n"); - return 1; + return EXIT_FAILURE; } /* @@ -439,14 +439,14 @@ int main(int argc, char **argv) if ((protocol_handle= memcached_protocol_create_instance()) == NULL) { fprintf(stderr, "Failed to allocate protocol handle\n"); - return 1; + return EXIT_FAILURE; } socket_userdata_map= calloc((size_t)(maxconns), sizeof(struct connection)); if (socket_userdata_map == NULL) { fprintf(stderr, "Failed to allocate room for connections\n"); - return 1; + return EXIT_FAILURE; } memcached_binary_protocol_set_callbacks(protocol_handle, interface); @@ -470,5 +470,5 @@ int main(int argc, char **argv) event_base_loop(event_base, 0); /* NOTREACHED */ - return 0; + return EXIT_SUCCESS; } diff --git a/libhashkit/digest.c b/libhashkit/digest.c index 4ff6de29..f418dc0b 100644 --- a/libhashkit/digest.c +++ b/libhashkit/digest.c @@ -35,13 +35,13 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo #ifdef HAVE_HSIEH_HASH return libhashkit_hsieh(key, key_length); #else - return 1; + return EXIT_FAILURE; #endif case HASHKIT_HASH_MURMUR: #ifdef HAVE_MURMUR_HASH return libhashkit_murmur(key, key_length); #else - return 1; + return EXIT_FAILURE; #endif case HASHKIT_HASH_JENKINS: return libhashkit_jenkins(key, key_length); @@ -56,5 +56,5 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo break; } - return 1; + return EXIT_FAILURE; } diff --git a/libhashkit/hsieh.c b/libhashkit/hsieh.c index ba46ed2c..cb5af8ae 100644 --- a/libhashkit/hsieh.c +++ b/libhashkit/hsieh.c @@ -23,7 +23,7 @@ uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attri int rem; if (key_length <= 0 || key == NULL) - return 0; + return EXIT_SUCCESS; rem = key_length & 3; key_length >>= 2; diff --git a/libhashkit/ketama.c b/libhashkit/ketama.c index a510e57a..560de300 100644 --- a/libhashkit/ketama.c +++ b/libhashkit/ketama.c @@ -27,9 +27,9 @@ static int continuum_points_cmp(const void *t1, const void *t2) hashkit_continuum_point_st *ct2= (hashkit_continuum_point_st *)t2; if (ct1->value == ct2->value) - return 0; + return EXIT_SUCCESS; else if (ct1->value > ct2->value) - return 1; + return EXIT_FAILURE; else return -1; } @@ -71,7 +71,7 @@ int update_continuum(hashkit_st *hashkit) live_servers= (uint32_t)hashkit->list_size; if (live_servers == 0) - return 0; + return EXIT_SUCCESS; if (hashkit->weight_fn == NULL) { @@ -159,6 +159,6 @@ int update_continuum(hashkit_st *hashkit) qsort(hashkit->continuum, hashkit->continuum_points_count, sizeof(hashkit_continuum_point_st), continuum_points_cmp); - return 0; + return EXIT_SUCCESS; } #endif diff --git a/libmemcached/behavior.c b/libmemcached/behavior.c index 2b6ccdf9..f88f0a77 100644 --- a/libmemcached/behavior.c +++ b/libmemcached/behavior.c @@ -314,18 +314,18 @@ uint64_t memcached_behavior_get(memcached_st *ptr, /* We just try the first host, and if it is down we return zero */ if ((memcached_connect(instance)) != MEMCACHED_SUCCESS) { - return 0; + return EXIT_SUCCESS; } if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS) { - return 0; + return EXIT_SUCCESS; } if (getsockopt(instance->fd, SOL_SOCKET, SO_SNDBUF, &sock_size, &sock_length) < 0) { ptr->cached_errno= errno; - return 0; /* Zero means error */ + return EXIT_SUCCESS; /* Zero means error */ } } @@ -350,18 +350,18 @@ uint64_t memcached_behavior_get(memcached_st *ptr, /* We just try the first host, and if it is down we return zero */ if ((memcached_connect(instance)) != MEMCACHED_SUCCESS) { - return 0; + return EXIT_SUCCESS; } if (memcached_io_wait_for_write(instance) != MEMCACHED_SUCCESS) { - return 0; + return EXIT_SUCCESS; } if (getsockopt(instance->fd, SOL_SOCKET, SO_RCVBUF, &sock_size, &sock_length) < 0) { ptr->cached_errno= errno; - return 0; /* Zero means error */ + return EXIT_SUCCESS; /* Zero means error */ } } @@ -385,7 +385,7 @@ uint64_t memcached_behavior_get(memcached_st *ptr, case MEMCACHED_BEHAVIOR_MAX: default: WATCHPOINT_ASSERT(0); /* Programming mistake if it gets this far */ - return 0; + return EXIT_SUCCESS; } /* NOTREACHED */ diff --git a/libmemcached/hash.c b/libmemcached/hash.c index dda30395..abad4f5b 100644 --- a/libmemcached/hash.c +++ b/libmemcached/hash.c @@ -70,7 +70,7 @@ static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const cha WATCHPOINT_ASSERT(memcached_server_count(ptr)); if (memcached_server_count(ptr) == 1) - return 0; + return EXIT_SUCCESS; if (ptr->flags.hash_with_prefix_key) { @@ -78,7 +78,7 @@ static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const cha char temp[temp_length]; if (temp_length > MEMCACHED_MAX_KEY -1) - return 0; + return EXIT_SUCCESS; strncpy(temp, ptr->prefix_key, ptr->prefix_key_length); strncpy(temp + ptr->prefix_key_length, key, key_length); diff --git a/libmemcached/hosts.c b/libmemcached/hosts.c index 9723f8b6..7034d3ec 100644 --- a/libmemcached/hosts.c +++ b/libmemcached/hosts.c @@ -92,9 +92,9 @@ static int continuum_item_cmp(const void *t1, const void *t2) /* Why 153? Hmmm... */ WATCHPOINT_ASSERT(ct1->value != 153); if (ct1->value == ct2->value) - return 0; + return EXIT_SUCCESS; else if (ct1->value > ct2->value) - return 1; + return EXIT_FAILURE; else return -1; } diff --git a/libmemcached/io.c b/libmemcached/io.c index dedcdaf9..2515dc1e 100644 --- a/libmemcached/io.c +++ b/libmemcached/io.c @@ -314,7 +314,7 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr, and protocol enforcement happens at memcached_response() looking for '\n'. We do not care for UDB which requests 8 bytes at once. Generally, this means that connection went away. Since - for blocking I/O we do not return 0 and for non-blocking case + for blocking I/O we do not return EXIT_SUCCESS and for non-blocking case it will return EGAIN if data is not immediatly available. */ WATCHPOINT_STRING("We had a zero length recv()"); @@ -600,7 +600,7 @@ static ssize_t io_flush(memcached_server_write_instance_st ptr, if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP && ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH)) - return 0; + return EXIT_SUCCESS; /* Looking for memory overflows */ #if defined(DEBUG) diff --git a/libmemcached/protocol/ascii_handler.c b/libmemcached/protocol/ascii_handler.c index 465b7396..802b0859 100644 --- a/libmemcached/protocol/ascii_handler.c +++ b/libmemcached/protocol/ascii_handler.c @@ -34,7 +34,7 @@ static uint16_t parse_ascii_key(char **start) if (len == 0 || len > 240 || (*c != '\0' && *c != '\r' && iscntrl(*c))) { - return 0; + return EXIT_SUCCESS; } return len; @@ -558,7 +558,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client, { /* Keep on reading */ recover_tokenize_command(start, *end); - return 1; + return EXIT_FAILURE; } void *data= (*end) + 1; @@ -658,7 +658,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client, *end += nbytes + 2; - return 0; + return EXIT_SUCCESS; } static int process_cas_command(memcached_protocol_client_st *client, diff --git a/libmemcached/util/pool.c b/libmemcached/util/pool.c index bd4fdf98..7879cc23 100644 --- a/libmemcached/util/pool.c +++ b/libmemcached/util/pool.c @@ -68,7 +68,7 @@ static int grow_pool(memcached_pool_st* pool) pool->mmc[++pool->firstfree] = obj; pool->current_size++; - return 0; + return EXIT_SUCCESS; } memcached_pool_st *memcached_pool_create(memcached_st* mmc, diff --git a/libtest/test.c b/libtest/test.c index 009c4be5..3d11d208 100644 --- a/libtest/test.c +++ b/libtest/test.c @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) if (sasl_client_init(NULL) != SASL_OK) { fprintf(stderr, "Failed to initialize sasl library!\n"); - return 1; + return EXIT_FAILURE; } #endif @@ -357,7 +357,7 @@ cleanup: if (error != TEST_SUCCESS) { fprintf(stderr, "Failure during shutdown.\n"); - stats.failed++; // We do this to make our exit code return 1 + stats.failed++; // We do this to make our exit code return EXIT_FAILURE } } diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index 5b4bcbe2..afdf0830 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -48,7 +48,7 @@ static test_return_t cleanup_pairs(memcached_st *memc) (void)memc; pairs_free(global_pairs); - return 0; + return EXIT_SUCCESS; } static test_return_t generate_pairs(memcached_st *memc) @@ -63,7 +63,7 @@ static test_return_t generate_pairs(memcached_st *memc) global_keys_length[x]= global_pairs[x].key_length; } - return 0; + return EXIT_SUCCESS; } static test_return_t drizzle(memcached_st *memc) @@ -160,7 +160,7 @@ static test_return_t add_test(memcached_st *memc) test_true(rc == MEMCACHED_NOTSTORED); } - return 0; + return EXIT_SUCCESS; } /* @@ -173,7 +173,7 @@ static test_return_t many_adds(memcached_st *memc) { add_test(memc); } - return 0; + return EXIT_SUCCESS; } test_st smash_tests[] ={ diff --git a/tests/cpp_example.cc b/tests/cpp_example.cc index 0b203724..fd0b00f4 100644 --- a/tests/cpp_example.cc +++ b/tests/cpp_example.cc @@ -190,5 +190,5 @@ int main() ++it; } - return 0; + return EXIT_SUCCESS; } diff --git a/tests/start.c b/tests/start.c index ae9497f3..1f5d43e2 100644 --- a/tests/start.c +++ b/tests/start.c @@ -25,5 +25,5 @@ int main(void) server_startup(&construct); - return 0; + return EXIT_SUCCESS; } -- 2.30.2