/* Define the function for all platforms to avoid #ifdefs in each program */
#if defined(_WIN32)
WSADATA wsaData;
- if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
+ if (WSAStartup(MAKEWORD(2, 0), &wsaData)) {
fprintf(stderr, "Socket Initialization Error. Program aborted\n");
exit(EXIT_FAILURE);
}
printf(" -%c, --%s%c\n", long_options[x].val, long_options[x].name,
long_options[x].has_arg ? '=' : ' ');
- if ((help_message = (char *) ms_lookup_help(long_options[x].val)) != NULL) {
+ if ((help_message = (char *) ms_lookup_help(long_options[x].val))) {
printf(" %s\n", help_message);
}
}
optarg[strlen(optarg) - 1] = '\0';
errno = 0;
ret = strtoll(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
fprintf(stderr, "strtoll(optarg,..): %s\n", strerror(errno));
exit(1);
}
case OPT_CONCURRENCY: /* --concurrency or -c */
errno = 0;
ms_setting.nconns = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.nconns <= 0 || errno != 0) {
+ if (ms_setting.nconns <= 0 || errno) {
fprintf(stderr, "Concurrency must be greater than 0.:-)\n");
exit(1);
}
case OPT_EXECUTE_NUMBER: /* --execute_number or -x */
errno = 0;
ms_setting.exec_num = (int) strtol(optarg, (char **) NULL, 10);
- if (ms_setting.exec_num <= 0 || errno != 0) {
+ if (ms_setting.exec_num <= 0 || errno) {
fprintf(stderr, "Execute number must be greater than 0.:-)\n");
exit(1);
}
case OPT_THREAD_NUMBER: /* --threads or -T */
errno = 0;
ms_setting.nthreads = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.nthreads <= 0 || errno != 0) {
+ if (ms_setting.nthreads <= 0 || errno) {
fprintf(stderr, "Threads number must be greater than 0.:-)\n");
exit(1);
}
case OPT_FIXED_LTH: /* --fixed_size or -X */
errno = 0;
ms_setting.fixed_value_size = (size_t) strtoull(optarg, (char **) NULL, 10);
- if ((ms_setting.fixed_value_size <= 0 || errno != 0)
+ if ((ms_setting.fixed_value_size <= 0 || errno)
|| (ms_setting.fixed_value_size > MAX_VALUE_SIZE))
{
fprintf(stderr, "Value size must be between 0 and 1M.:-)\n");
case OPT_GETS_DIVISION: /* --division or -d */
errno = 0;
ms_setting.mult_key_num = (int) strtol(optarg, (char **) NULL, 10);
- if (ms_setting.mult_key_num <= 0 || errno != 0) {
+ if (ms_setting.mult_key_num <= 0 || errno) {
fprintf(stderr, "Multi-get key number must be greater than 0.:-)\n");
exit(1);
}
case OPT_SOCK_PER_CONN: /* --conn_sock or -n */
errno = 0;
ms_setting.sock_per_conn = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.sock_per_conn <= 0 || errno != 0) {
+ if (ms_setting.sock_per_conn <= 0 || errno) {
fprintf(stderr,
"Number of socks of each concurrency "
"must be greater than 0.:-)\n");
case OPT_REP_WRITE_SRV: /* --rep_write or -p */
errno = 0;
ms_setting.rep_write_srv = (uint32_t) strtoul(optarg, (char **) NULL, 10);
- if (ms_setting.rep_write_srv <= 0 || errno != 0) {
+ if (ms_setting.rep_write_srv <= 0 || errno) {
fprintf(stderr,
"Number of replication writing server must be greater "
"than 0.:-)\n");
}
}
- if (ms_setting.nconns % (uint32_t) ms_setting.nthreads != 0) {
+ if (ms_setting.nconns % (uint32_t) ms_setting.nthreads) {
fprintf(stderr, "Concurrency must be the multiples of threads count.\n");
return -1;
}
- if (ms_setting.win_size % UNIT_ITEMS_COUNT != 0) {
+ if (ms_setting.win_size % UNIT_ITEMS_COUNT) {
fprintf(stderr, "Window size must be the multiples of 1024.\n\n");
return -1;
}
c->udppkt = (ms_udppkt_t *) malloc(MAX_UDP_PACKET * sizeof(ms_udppkt_t));
if ((c->rudpbuf == NULL) || (c->udppkt == NULL)) {
- if (c->rudpbuf != NULL)
+ if (c->rudpbuf)
free(c->rudpbuf);
- if (c->udppkt != NULL)
+ if (c->udppkt)
free(c->udppkt);
fprintf(stderr, "malloc()\n");
return -1;
*/
static int ms_conn_init(ms_conn_t *c, const int init_state, const int read_buffer_size,
const bool is_udp) {
- assert(c != NULL);
+ assert(c);
c->rbuf = c->wbuf = 0;
c->iov = 0;
|| (c->tcpsfd == NULL)
|| ((ms_setting.mult_key_num > 1) && (c->mlget_task.mlget_item == NULL)))
{
- if (c->rbuf != NULL)
+ if (c->rbuf)
free(c->rbuf);
- if (c->wbuf != NULL)
+ if (c->wbuf)
free(c->wbuf);
- if (c->iov != NULL)
+ if (c->iov)
free(c->iov);
- if (c->msglist != NULL)
+ if (c->msglist)
free(c->msglist);
- if (c->mlget_task.mlget_item != NULL)
+ if (c->mlget_task.mlget_item)
free(c->mlget_task.mlget_item);
- if (c->tcpsfd != NULL)
+ if (c->tcpsfd)
free(c->tcpsfd);
fprintf(stderr, "malloc()\n");
return -1;
}
/* initialize udp */
- if (ms_conn_udp_init(c, is_udp) != 0) {
+ if (ms_conn_udp_init(c, is_udp)) {
return -1;
}
int ret_sfd;
uint32_t srv_idx = 0;
- assert(c != NULL);
- assert(c->tcpsfd != NULL);
+ assert(c);
+ assert(c->tcpsfd);
for (i = 0; i < c->total_sfds; i++) {
ret_sfd = 0;
if (ms_network_connect(c, ms_setting.servers[srv_idx].srv_host_name,
ms_setting.servers[srv_idx].srv_port, ms_setting.udp, &ret_sfd)
- != 0)
+)
{
break;
}
ret_sfd = 0;
if (ms_network_connect(c, ms_setting.servers[srv_idx].srv_host_name,
ms_setting.servers[srv_idx].srv_port, true, &ret_sfd)
- != 0)
+)
{
c->udpsfd = 0;
} else {
}
}
- if (c->udpsfd != 0) {
+ if (c->udpsfd) {
close(c->udpsfd);
}
* @return int, if success, return EXIT_SUCCESS, else return -1
*/
int ms_setup_conn(ms_conn_t *c) {
- if (ms_item_win_init(c) != 0) {
+ if (ms_item_win_init(c)) {
return -1;
}
- if (ms_conn_init(c, conn_write, DATA_BUFFER_SIZE, ms_setting.udp) != 0) {
+ if (ms_conn_init(c, conn_write, DATA_BUFFER_SIZE, ms_setting.udp)) {
return -1;
}
- if (ms_conn_sock_init(c) != 0) {
+ if (ms_conn_sock_init(c)) {
return -1;
}
- if (ms_conn_event_init(c) != 0) {
+ if (ms_conn_event_init(c)) {
return -1;
}
*/
void ms_conn_free(ms_conn_t *c) {
ms_thread_t *ms_thread = pthread_getspecific(ms_thread_key);
- if (c != NULL) {
- if (c->hdrbuf != NULL)
+ if (c) {
+ if (c->hdrbuf)
free(c->hdrbuf);
- if (c->msglist != NULL)
+ if (c->msglist)
free(c->msglist);
- if (c->rbuf != NULL)
+ if (c->rbuf)
free(c->rbuf);
- if (c->wbuf != NULL)
+ if (c->wbuf)
free(c->wbuf);
- if (c->iov != NULL)
+ if (c->iov)
free(c->iov);
- if (c->mlget_task.mlget_item != NULL)
+ if (c->mlget_task.mlget_item)
free(c->mlget_task.mlget_item);
- if (c->rudpbuf != NULL)
+ if (c->rudpbuf)
free(c->rudpbuf);
- if (c->udppkt != NULL)
+ if (c->udppkt)
free(c->udppkt);
- if (c->item_win != NULL)
+ if (c->item_win)
free(c->item_win);
- if (c->tcpsfd != NULL)
+ if (c->tcpsfd)
free(c->tcpsfd);
if (--ms_thread->nactive_conn == 0) {
*/
static void ms_conn_close(ms_conn_t *c) {
ms_thread_t *ms_thread = pthread_getspecific(ms_thread_key);
- assert(c != NULL);
+ assert(c);
/* delete the event, the socket and the connection */
event_del(&c->event);
unsigned int old_size;
/* Start with the default size. */
- if (getsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &old_size, &intsize) != 0) {
+ if (getsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &old_size, &intsize)) {
fprintf(stderr, "getsockopt(SO_SNDBUF)\n");
return;
}
snprintf(port_buf, NI_MAXSERV, "%d", srv_port);
error = getaddrinfo(srv_host_name, port_buf, &hints, &ai);
- if (error != 0) {
+ if (error) {
if (error != EAI_SYSTEM)
fprintf(stderr, "getaddrinfo(): %s.\n", gai_strerror(error));
else
return -1;
}
- if (ret_sfd != NULL) {
+ if (ret_sfd) {
*ret_sfd = sfd;
}
uint32_t i = 0;
for (i = 0; i < c->total_sfds; i++) {
- if (c->tcpsfd[i] != 0) {
+ if (c->tcpsfd[i]) {
break;
}
}
uint32_t srv_conn_cnt = 0;
struct timeval cur_time;
- assert(c != NULL);
+ assert(c);
if ((c->total_sfds == 1) || (c->total_sfds == c->alive_sfds)) {
return EXIT_SUCCESS;
* Usage example:
*
* while(ms_tokenize_command(command, ncommand, tokens, max_tokens) > 0) {
- * for(int ix = 0; tokens[ix].length != 0; ix++) {
+ * for(int ix = 0; tokens[ix].length; ix++) {
* ...
* }
* ncommand = tokens[ix].value - command;
char *s, *e;
int ntokens = 0;
- assert(command != NULL && tokens != NULL && max_tokens > 1);
+ assert(command && tokens && max_tokens > 1);
for (s = e = command; ntokens < max_tokens - 1; ++e) {
if (*e == ' ') {
int64_t value_len;
char *buffer = command;
- assert(c != NULL);
+ assert(c);
/**
* for command get, we store the returned value into local buffer
ms_tokenize_command(command, tokens, MAX_TOKENS);
errno = 0;
value_len = strtol(tokens[VALUELEN_TOKEN].value, NULL, 10);
- if (errno != 0) {
+ if (errno) {
printf("<%d ERROR %s\n", c->sfd, strerror(errno));
}
memcpy(&c->currcmd.key_prefix, tokens[KEY_TOKEN].value, sizeof(c->currcmd.key_prefix));
* @param timeout, whether it's timeout
*/
void ms_reset_conn(ms_conn_t *c, bool timeout) {
- assert(c != NULL);
+ assert(c);
if (c->udp) {
if ((c->packets > 0) && (c->packets < MAX_UDP_PACKET)) {
return EXIT_SUCCESS;
} else {
#ifdef NEED_ALIGN
- if (((long) (c->rcurr)) % 8 != 0) {
+ if (((long) (c->rcurr)) % 8) {
/* must realign input buffer */
memmove(c->rbuf, c->rcurr, c->rbytes);
c->rcurr = c->rbuf;
} else {
char *el, *cont;
- assert(c != NULL);
+ assert(c);
assert(c->rcurr <= (c->rbuf + c->rsize));
if (c->rbytes == 0)
unsigned char *header = NULL;
/* no enough data */
- assert(c != NULL);
- assert(buf != NULL);
+ assert(c);
+ assert(buf);
assert(c->rudpbytes >= UDP_HEADER_SIZE);
/* calculate received packets count */
for (int i = c->ordcurr; i < c->recvpkt; i++) {
/* there is some data to copy */
- if ((c->udppkt[i].data != NULL) && (c->udppkt[i].copybytes < c->udppkt[i].rbytes)) {
+ if ((c->udppkt[i].data) && (c->udppkt[i].copybytes < c->udppkt[i].rbytes)) {
header = c->udppkt[i].header;
len = c->udppkt[i].rbytes - c->udppkt[i].copybytes;
if (len > rbytes - wbytes) {
int res;
int64_t avail;
- assert(c != NULL);
+ assert(c);
if ((c->rcurr != c->rbuf)
&& (!c->readval || (c->rvbytes > c->rsize - (c->rcurr - c->rbuf))
|| (c->readval && (c->rcurr - c->rbuf > c->rbytes))))
{
- if (c->rbytes != 0) /* otherwise there's nothing to copy */
+ if (c->rbytes) /* otherwise there's nothing to copy */
memmove(c->rbuf, c->rcurr, (size_t) c->rbytes);
c->rcurr = c->rbuf;
}
}
}
} else {
- if ((c->curr_task.item->value_size != vlen) || (memcmp(orignval, value, (size_t) vlen) != 0))
+ if ((c->curr_task.item->value_size != vlen) || (memcmp(orignval, value, (size_t) vlen)))
{
atomic_add_size(&ms_stats.vef_failed, 1);
c->curr_task.finish_verify = true;
- if (mlget_item != NULL) {
+ if (mlget_item) {
mlget_item->finish_verify = true;
}
}
* @param c, pointer of the concurrency
*/
static void ms_ascii_complete_nread(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
assert(c->rbytes >= c->rvbytes);
assert(c->protocol == ascii_prot);
if (c->rvbytes > 2) {
* @param c, pointer of the concurrency
*/
static void ms_bin_complete_nread(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
assert(c->rbytes >= c->rvbytes);
assert(c->protocol == binary_prot);
* @param c, pointer of the concurrency
*/
static void ms_complete_nread(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
assert(c->rbytes >= c->rvbytes);
assert(c->protocol == ascii_prot || c->protocol == binary_prot);
static int ms_add_msghdr(ms_conn_t *c) {
struct msghdr *msg;
- assert(c != NULL);
+ assert(c);
if (c->msgsize == c->msgused) {
msg = realloc(c->msglist, (size_t) c->msgsize * 2 * sizeof(struct msghdr));
* @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_ensure_iov_space(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
if (c->iovused >= c->iovsize) {
int i, iovnum;
int leftover;
bool limit_to_mtu;
- assert(c != NULL);
+ assert(c);
do {
m = &c->msglist[c->msgused - 1];
}
#endif
- if (ms_ensure_iov_space(c) != 0)
+ if (ms_ensure_iov_space(c))
return -1;
/* If the fragment is too big to fit in the datagram, split it up */
int i;
unsigned char *hdr;
- assert(c != NULL);
+ assert(c);
c->request_id = ms_get_udp_request_id();
* TRANSMIT_HARD_ERROR Can't write (c->state is set to conn_closing)
*/
static int ms_transmit(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
if ((c->msgcurr < c->msgused) && (c->msglist[c->msgcurr].msg_iovlen == 0)) {
/* Finished writing the current msg; advance to the next. */
* @param c, pointer of the concurrency
*/
static void ms_conn_shrink(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
if (c->udp)
return;
* @param state, connection state
*/
static void ms_conn_set_state(ms_conn_t *c, int state) {
- assert(c != NULL);
+ assert(c);
if (state != c->state) {
if (state == conn_read) {
* @return bool, if success, return true, else return false
*/
static bool ms_update_event(ms_conn_t *c, const int new_flags) {
- assert(c != NULL);
+ assert(c);
struct event_base *base = c->event.ev_base;
if ((c->ev_flags == new_flags) && (ms_setting.rep_write_srv == 0)
static void ms_drive_machine(ms_conn_t *c) {
bool stop = false;
- assert(c != NULL);
+ assert(c);
while (!stop) {
switch (c->state) {
break;
}
} else {
- if (ms_try_read_line(c) != 0) {
+ if (ms_try_read_line(c)) {
break;
}
}
- if (ms_try_read_network(c) != 0) {
+ if (ms_try_read_network(c)) {
break;
}
break;
}
- if (!c->ctnwrite && (ms_exec_task(c) != 0)) {
+ if (!c->ctnwrite && (ms_exec_task(c))) {
ms_conn_set_state(c, conn_closing);
break;
}
if (ms_setting.reconnect
&& (!ms_global.time_out || ((ms_setting.run_time == 0) && (c->remain_exec_num > 0))))
{
- if (ms_reconn(c) != 0) {
+ if (ms_reconn(c)) {
ms_conn_close(c);
stop = true;
break;
void ms_event_handler(const int fd, const short which, void *arg) {
ms_conn_t *c = (ms_conn_t *) arg;
- assert(c != NULL);
+ assert(c);
c->which = which;
* @return int, if success, return EXIT_SUCCESS, else return -1
*/
static int ms_update_conn_sock_event(ms_conn_t *c) {
- assert(c != NULL);
+ assert(c);
switch (c->currcmd.cmd) {
case CMD_SET:
}
c->sfd = c->tcpsfd[c->cur_idx];
- assert(c->sfd != 0);
+ assert(c->sfd);
c->change_sfd = true;
}
value_offset = item->value_offset;
}
- if ((ms_add_iov(c, "set ", 4) != 0)
- || (ms_add_iov(c, (char *) &item->key_prefix, (int) KEY_PREFIX_SIZE) != 0)
+ if ((ms_add_iov(c, "set ", 4))
+ || (ms_add_iov(c, (char *) &item->key_prefix, (int) KEY_PREFIX_SIZE))
|| (ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset],
item->key_size - (int) KEY_PREFIX_SIZE)
- != 0)
- || (ms_add_iov(c, buffer, write_len) != 0)
- || (ms_add_iov(c, &ms_setting.char_block[value_offset], item->value_size) != 0)
- || (ms_add_iov(c, "\r\n", 2) != 0) || (c->udp && (ms_build_udp_headers(c) != 0)))
+)
+ || (ms_add_iov(c, buffer, write_len))
+ || (ms_add_iov(c, &ms_setting.char_block[value_offset], item->value_size))
+ || (ms_add_iov(c, "\r\n", 2)) || (c->udp && (ms_build_udp_headers(c))))
{
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) {
- assert(c != NULL);
+ assert(c);
c->currcmd.cmd = CMD_SET;
c->currcmd.isfinish = false;
c->currcmd.retstat = MCD_FAILURE;
- if (ms_update_conn_sock_event(c) != 0) {
+ if (ms_update_conn_sock_event(c)) {
return -1;
}
c->msgcurr = 0;
c->msgused = 0;
c->iovused = 0;
- if (ms_add_msghdr(c) != 0) {
+ if (ms_add_msghdr(c)) {
fprintf(stderr, "Out of memory preparing request.");
return -1;
}
/* binary protocol */
if (c->protocol == binary_prot) {
- if (ms_build_bin_write_buf_set(c, item) != 0) {
+ if (ms_build_bin_write_buf_set(c, item)) {
return -1;
}
} else {
- if (ms_build_ascii_write_buf_set(c, item) != 0) {
+ if (ms_build_ascii_write_buf_set(c, item)) {
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) {
- if ((ms_add_iov(c, "get ", 4) != 0)
- || (ms_add_iov(c, (char *) &item->key_prefix, (int) KEY_PREFIX_SIZE) != 0)
+ if ((ms_add_iov(c, "get ", 4))
+ || (ms_add_iov(c, (char *) &item->key_prefix, (int) KEY_PREFIX_SIZE))
|| (ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset],
item->key_size - (int) KEY_PREFIX_SIZE)
- != 0)
- || (ms_add_iov(c, "\r\n", 2) != 0) || (c->udp && (ms_build_udp_headers(c) != 0)))
+)
+ || (ms_add_iov(c, "\r\n", 2)) || (c->udp && (ms_build_udp_headers(c))))
{
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) {
- assert(c != NULL);
+ assert(c);
c->currcmd.cmd = CMD_GET;
c->currcmd.isfinish = false;
c->currcmd.retstat = MCD_FAILURE;
- if (ms_update_conn_sock_event(c) != 0) {
+ if (ms_update_conn_sock_event(c)) {
return -1;
}
c->msgcurr = 0;
c->msgused = 0;
c->iovused = 0;
- if (ms_add_msghdr(c) != 0) {
+ if (ms_add_msghdr(c)) {
fprintf(stderr, "Out of memory preparing request.");
return -1;
}
/* binary protocol */
if (c->protocol == binary_prot) {
- if (ms_build_bin_write_buf_get(c, item) != 0) {
+ if (ms_build_bin_write_buf_get(c, item)) {
return -1;
}
} else {
- if (ms_build_ascii_write_buf_get(c, item) != 0) {
+ if (ms_build_ascii_write_buf_get(c, item)) {
return -1;
}
}
static int ms_build_ascii_write_buf_mlget(ms_conn_t *c) {
ms_task_item_t *item;
- if (ms_add_iov(c, "get", 3) != 0) {
+ if (ms_add_iov(c, "get", 3)) {
return -1;
}
for (int i = 0; i < c->mlget_task.mlget_num; i++) {
item = c->mlget_task.mlget_item[i].item;
- assert(item != NULL);
- if ((ms_add_iov(c, " ", 1) != 0)
- || (ms_add_iov(c, (char *) &item->key_prefix, (int) KEY_PREFIX_SIZE) != 0)
+ assert(item);
+ if ((ms_add_iov(c, " ", 1))
+ || (ms_add_iov(c, (char *) &item->key_prefix, (int) KEY_PREFIX_SIZE))
|| (ms_add_iov(c, &ms_setting.char_block[item->key_suffix_offset],
item->key_size - (int) KEY_PREFIX_SIZE)
- != 0))
+))
{
return -1;
}
}
- if ((ms_add_iov(c, "\r\n", 2) != 0) || (c->udp && (ms_build_udp_headers(c) != 0))) {
+ if ((ms_add_iov(c, "\r\n", 2)) || (c->udp && (ms_build_udp_headers(c)))) {
return -1;
}
int ms_mcd_mlget(ms_conn_t *c) {
ms_task_item_t *item;
- assert(c != NULL);
+ assert(c);
assert(c->mlget_task.mlget_num >= 1);
c->currcmd.cmd = CMD_GET;
c->currcmd.isfinish = false;
c->currcmd.retstat = MCD_FAILURE;
- if (ms_update_conn_sock_event(c) != 0) {
+ if (ms_update_conn_sock_event(c)) {
return -1;
}
c->msgcurr = 0;
c->msgused = 0;
c->iovused = 0;
- if (ms_add_msghdr(c) != 0) {
+ if (ms_add_msghdr(c)) {
fprintf(stderr, "Out of memory preparing request.");
return -1;
}
/* binary protocol */
if (c->protocol == binary_prot) {
- if (ms_build_bin_write_buf_mlget(c) != 0) {
+ if (ms_build_bin_write_buf_mlget(c)) {
return -1;
}
} else {
- if (ms_build_ascii_write_buf_mlget(c) != 0) {
+ if (ms_build_ascii_write_buf_mlget(c)) {
return -1;
}
}
static int ms_bin_process_response(ms_conn_t *c) {
const char *errstr = NULL;
- assert(c != NULL);
+ assert(c);
uint32_t bodylen = c->binary_header.response.bodylen;
uint8_t opcode = c->binary_header.response.opcode;
break;
} /* switch */
- if (errstr != NULL) {
+ if (errstr) {
fprintf(stderr, "%s\n", errstr);
}
}
uint32_t body_len) {
protocol_binary_request_header *header;
- assert(c != NULL);
+ assert(c);
header = (protocol_binary_request_header *) c->wcurr;
for (int i = 0; i < c->mlget_task.mlget_num; i++) {
item = c->mlget_task.mlget_item[i].item;
- assert(item != NULL);
+ assert(item);
ms_add_bin_header(c, PROTOCOL_BINARY_CMD_GET, 0, (uint16_t) item->key_size,
(uint32_t) item->key_size);
break;
}
(*line)[cur_len] = '\0';
- if (cur_len != 0)
+ if (cur_len)
return (ssize_t) cur_len;
return result;
}
* @return if success, return EXIT_FAILURE, else return EXIT_SUCCESS
*/
static int ms_is_line_data(char *line) {
- assert(line != NULL);
+ assert(line);
char *begin_ptr = line;
fclose(f);
- if (line != NULL) {
+ if (line) {
free(line);
}
} /* ms_parse_cfg_file */
offset = 0;
/* initialize value distribution */
- if (ms_setting.fixed_value_size != 0) {
+ if (ms_setting.fixed_value_size) {
for (int i = 0; i < units * UNIT_ITEMS_COUNT; i++) {
ms_setting.distr[i].value_size = ms_setting.fixed_value_size;
}
ms_parse_cfg_file(ms_setting.cfg_file);
/* run time mode */
- if ((ms_setting.exec_num == 0) && (ms_setting.run_time != 0)) {
+ if ((ms_setting.exec_num == 0) && (ms_setting.run_time)) {
ms_setting.exec_num = (int64_t) MAX_EXEC_NUM;
} else {
/* execute number mode */
* clean up the global setting structure
*/
void ms_setting_cleanup() {
- if (ms_setting.distr != NULL) {
+ if (ms_setting.distr) {
free(ms_setting.distr);
}
- if (ms_setting.char_block != NULL) {
+ if (ms_setting.char_block) {
free(ms_setting.char_block);
}
- if (ms_setting.srv_str != NULL) {
+ if (ms_setting.srv_str) {
free(ms_setting.srv_str);
}
- if (ms_setting.cfg_file != NULL) {
+ if (ms_setting.cfg_file) {
free(ms_setting.cfg_file);
}
- if (ms_setting.servers != NULL) {
+ if (ms_setting.servers) {
free(ms_setting.servers);
}
- if (ms_setting.key_distr != NULL) {
+ if (ms_setting.key_distr) {
free(ms_setting.key_distr);
}
- if (ms_setting.value_distr != NULL) {
+ if (ms_setting.value_distr) {
free(ms_setting.value_distr);
}
} /* ms_setting_cleanup */
stat->dist[ms_local_log2(total_time)]++;
stat->squares += (double) (total_time * total_time);
- if (total_time != 0) {
+ if (total_time) {
stat->log_product += log((double) total_time);
}
} /* ms_record_event */
for (uint32_t i = 0; i < array_size(stat->dist); i++) {
events += stat->dist[i];
- if (stat->dist[i] != 0) {
+ if (stat->dist[i]) {
max_non_zero = (int) i;
}
}
printf(" Log2 Dist:");
for (int i = 0; i <= max_non_zero - 4; i += 4) {
- if ((stat->dist[i + 0] != 0) || (stat->dist[i + 1] != 0) || (stat->dist[i + 2] != 0)
- || (stat->dist[i + 3] != 0))
+ if ((stat->dist[i + 0]) || (stat->dist[i + 1]) || (stat->dist[i + 2])
+ || (stat->dist[i + 3]))
{
min_non_zero = i;
break;
static bool ms_need_overwrite_item(ms_task_t *task) {
ms_task_item_t *item = task->item;
- assert(item != NULL);
+ assert(item);
assert(task->cmd == CMD_SET);
/**
static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task) {
ms_task_item_t *item = task->item;
- assert(item != NULL);
+ assert(item);
if (task->cmd == CMD_SET) {
/* If did set operation too fast, skip some */
static void ms_task_data_verify_init(ms_task_t *task) {
ms_task_item_t *item = task->item;
- assert(item != NULL);
+ assert(item);
assert(task->cmd == CMD_GET);
/**
static void ms_task_expire_verify_init(ms_task_t *task) {
ms_task_item_t *item = task->item;
- assert(item != NULL);
+ assert(item);
assert(task->cmd == CMD_GET);
assert(item->exp_time > 0);
if (c == NULL) {
return;
}
- assert(c != NULL);
+ assert(c);
for (int i = 0; i < c->mlget_task.mlget_num; i++) {
mlget_item = &c->mlget_task.mlget_item[i];
if ((c == NULL) || (item == NULL)) {
return;
}
- assert(c != NULL);
- assert(item != NULL);
+ assert(c);
+ assert(item);
orignval = &ms_setting.char_block[item->value_offset];
orignkey = &ms_setting.char_block[item->key_suffix_offset];
if ((c == NULL) || (item == NULL)) {
return;
}
- assert(c != NULL);
- assert(item != NULL);
+ assert(c);
+ assert(item);
if (c->precmd.cmd == CMD_SET) {
switch (c->precmd.retstat) {
if (c == NULL) {
return;
}
- assert(c != NULL);
+ assert(c);
gettimeofday(&c->end_time, NULL);
uint64_t time_diff = (uint64_t) ms_time_diff(&c->start_time, &c->end_time);
if (c == NULL) {
return;
}
- assert(c != NULL);
+ assert(c);
item = ms_get_cur_opt_item(c);
if (item == NULL) {
return;
}
- assert(item != NULL);
+ assert(item);
ms_update_set_result(c, item);
if (!ms_global.finish_warmup) {
ms_warmup_server(c);
} else {
- if (ms_run_getset_task(c) != 0) {
+ if (ms_run_getset_task(c)) {
return -1;
}
}
for (uint32_t i = 0; i < thread_ctx->nconns; i++) {
ms_thread->conn[i].conn_idx = i;
- if (ms_setup_conn(&ms_thread->conn[i]) != 0) {
+ if (ms_setup_conn(&ms_thread->conn[i])) {
/* only output this error once */
if (atomic_add_32_nv(&cnt, 1) == 0) {
fprintf(stderr, "Initializing connection failed.\n");
ms_set_thread_cpu_affinity(thread_ctx->thd_idx % ms_setting.ncpu);
}
- if (ms_setup_thread(thread_ctx) != 0) {
+ if (ms_setup_thread(thread_ctx)) {
exit(1);
}
pthread_attr_init(&attr);
- if ((ret = pthread_create(&thread, &attr, func, arg)) != 0) {
+ if ((ret = pthread_create(&thread, &attr, func, arg))) {
fprintf(stderr, "Can't create thread: %s.\n", strerror(ret));
exit(1);
}
/* cleanup some resource of threads when all the threads exit */
void ms_thread_cleanup() {
- if (ms_thread_ctx != NULL) {
+ if (ms_thread_ctx) {
free(ms_thread_ctx);
}
pthread_key_delete(ms_thread_key);
hints.ai_socktype = SOCK_STREAM;
int error = getaddrinfo(hostname, port, &hints, &ai);
- if (error != 0) {
+ if (error) {
if (error != EAI_SYSTEM) {
fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(error));
} else {
static memcached_socket_t connect_server(const char *hostname, const char *port) {
struct addrinfo *ai = lookuphost(hostname, port);
sock = INVALID_SOCKET;
- if (ai != NULL) {
+ if (ai) {
if ((sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) != INVALID_SOCKET) {
if (connect(sock, ai->ai_addr, ai->ai_addrlen) == SOCKET_ERROR) {
fprintf(stderr, "Failed to connect socket: %s\n", strerror(get_socket_errno()));
off_t key_offset = sizeof(protocol_binary_request_no_extras) + 8;
memcpy(cmd->bytes + key_offset, key, keylen);
- if (dta != NULL)
+ if (dta)
memcpy(cmd->bytes + key_offset + keylen, dta, dtalen);
}
off_t key_offset = sizeof(protocol_binary_request_no_extras);
- if (key != NULL)
+ if (key)
memcpy(cmd->bytes + key_offset, key, keylen);
- if (dta != NULL)
+ if (dta)
memcpy(cmd->bytes + key_offset + keylen, dta, dtalen);
}
cmd->flush.message.header.request.opcode = cc;
cmd->flush.message.header.request.opaque = 0xdeadbeef;
- if (exptime != 0 || use_extra) {
+ if (exptime || use_extra) {
cmd->flush.message.header.request.extlen = 4;
cmd->flush.message.body.expiration = htonl(exptime);
cmd->flush.message.header.request.bodylen = 4;
verify(rsp->plain.message.header.response.keylen == 0);
verify(rsp->plain.message.header.response.extlen == 0);
verify(rsp->plain.message.header.response.bodylen == 0);
- verify(rsp->plain.message.header.response.cas != 0);
+ verify(rsp->plain.message.header.response.cas);
break;
case PROTOCOL_BINARY_CMD_FLUSH:
case PROTOCOL_BINARY_CMD_NOOP:
verify(rsp->plain.message.header.response.keylen == 0);
verify(rsp->plain.message.header.response.extlen == 0);
verify(rsp->plain.message.header.response.bodylen == 8);
- verify(rsp->plain.message.header.response.cas != 0);
+ verify(rsp->plain.message.header.response.cas);
break;
case PROTOCOL_BINARY_CMD_STAT:
case PROTOCOL_BINARY_CMD_VERSION:
verify(rsp->plain.message.header.response.keylen == 0);
verify(rsp->plain.message.header.response.extlen == 0);
- verify(rsp->plain.message.header.response.bodylen != 0);
+ verify(rsp->plain.message.header.response.bodylen);
verify(rsp->plain.message.header.response.cas == 0);
break;
case PROTOCOL_BINARY_CMD_GETQ:
verify(rsp->plain.message.header.response.keylen == 0);
verify(rsp->plain.message.header.response.extlen == 4);
- verify(rsp->plain.message.header.response.cas != 0);
+ verify(rsp->plain.message.header.response.cas);
break;
case PROTOCOL_BINARY_CMD_GETK:
case PROTOCOL_BINARY_CMD_GETKQ:
- verify(rsp->plain.message.header.response.keylen != 0);
+ verify(rsp->plain.message.header.response.keylen);
verify(rsp->plain.message.header.response.extlen == 4);
- verify(rsp->plain.message.header.response.cas != 0);
+ verify(rsp->plain.message.header.response.cas);
break;
default:
execute(recv_packet(&rsp));
verify(
validate_response_header(&rsp, PROTOCOL_BINARY_CMD_STAT, PROTOCOL_BINARY_RESPONSE_SUCCESS));
- } while (rsp.plain.message.header.response.keylen != 0);
+ } while (rsp.plain.message.header.response.keylen);
return TEST_PASS;
}
static enum test_return receive_response(const char *msg) {
char buffer[80];
execute(receive_line(buffer, sizeof(buffer)));
- if (strcmp(msg, buffer) != 0) {
+ if (strcmp(msg, buffer)) {
fprintf(stderr, "[%s]\n", buffer);
}
verify(strcmp(msg, buffer) == 0);
execute(receive_line(buffer, sizeof(buffer)));
verify(strncmp(buffer, "VALUE ", 6) == 0);
char *end = strchr(buffer + 6, ' ');
- verify(end != NULL);
+ verify(end);
if (end) {
*end = '\0';
}
*key = strdup(buffer + 6);
- verify(*key != NULL);
+ verify(*key);
char *ptr = end + 1;
errno = 0;
verify(errno == 0);
verify(ptr != end);
verify(val == 0);
- verify(end != NULL);
+ verify(end);
errno = 0;
*ndata = (ssize_t) strtoul(end, &end, 10); /* size */
verify(errno == 0);
verify(ptr != end);
- verify(end != NULL);
+ verify(end);
while (end and *end != '\n' and isspace(*end)) ++end;
verify(end and *end == '\n');
*value = static_cast<char *>(malloc((size_t) *ndata));
- verify(*value != NULL);
+ verify(*value);
execute(retry_read(*value, (size_t) *ndata));
verify(errno == 0);
verify(ptr != end);
verify(val == 0);
- verify(end != NULL);
+ verify(end);
errno = 0;
val = strtoul(end, &end, 10); /* size */
verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
- verify(end != NULL);
+ verify(end);
while (end and *end != '\n' and isspace(*end)) {
++end;
}
static enum test_return ascii_get_item(const char *key, const char *value, bool exist) {
char buffer[1024];
size_t datasize = 0;
- if (value != NULL) {
+ if (value) {
datasize = strlen(value);
}
verify(errno == 0);
verify(ptr != end);
verify(val == 0);
- verify(end != NULL);
+ verify(end);
errno = 0;
val = strtoul(end, &end, 10); /* size */
verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
- verify(end != NULL);
+ verify(end);
errno = 0;
*cas = strtoul(end, &end, 10); /* cas */
verify(errno == 0);
verify(ptr != end);
verify(val == datasize);
- verify(end != NULL);
+ verify(end);
while (end and *end != '\n' and isspace(*end)) {
++end;
unsigned long *cas) {
char buffer[1024];
size_t datasize = 0;
- if (value != NULL) {
+ if (value) {
datasize = strlen(value);
}
char buffer[1024];
do {
execute(receive_line(buffer, sizeof(buffer)));
- } while (strcmp(buffer, "END\r\n") != 0);
+ } while (strcmp(buffer, "END\r\n"));
return TEST_PASS_RECONNECT;
}
return EXIT_FAILURE;
}
- for (int ii = 0; testcases[ii].description != NULL; ++ii) {
- if (testname != NULL && strcmp(testcases[ii].description, testname) != 0) {
+ for (int ii = 0; testcases[ii].description; ++ii) {
+ if (testname && strcmp(testcases[ii].description, testname)) {
continue;
}
if (prompt) {
fprintf(stdout, "\nPress <return> when you are ready? ");
char buffer[80] = {0};
- if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
+ if (fgets(buffer, sizeof(buffer), stdin)) {
if (strncmp(buffer, "skip", 4) == 0) {
fprintf(stdout, "%-40s%s\n", testcases[ii].description, status_msg[TEST_SKIP]);
fflush(stdout);
/* Check for various possible errors */
- if ((errno == ERANGE and (val == LONG_MAX or val == LONG_MIN)) or (errno != 0 && val == 0)) {
+ if ((errno == ERANGE and (val == LONG_MAX or val == LONG_MIN)) or (errno && val == 0)) {
*error = true;
return 0;
}
char *nptr;
unsigned long value = strtoul(argv[optind], &nptr, 10);
- if ((errno != 0) or (nptr == argv[optind] and value == 0)
+ if ((errno) or (nptr == argv[optind] and value == 0)
or (value == ULONG_MAX and errno == ERANGE) or (value == 0 and errno == EINVAL))
{
std::cerr << "strtoul() was unable to parse given value" << std::endl;
case OPT_EXPIRE: /* --expire */
errno = 0;
opt_expire = (time_t) strtoll(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::endl;
exit(EXIT_FAILURE);
}
case OPT_EXPIRE: /* --expire */
errno = 0;
opt_expire = time_t(strtoll(optarg, (char **) NULL, 10));
- if (errno != 0) {
+ if (errno) {
std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::endl;
exit(EXIT_FAILURE);
}
case OPT_EXPIRE: /* --expire */
errno = 0;
opt_expire = (time_t) strtoll(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::endl;
exit(EXIT_FAILURE);
}
}
/* now you create the thread */
- if (pthread_create(threads + x, NULL, run_task, (void *) context) != 0) {
+ if (pthread_create(threads + x, NULL, run_task, (void *) context)) {
fprintf(stderr, "Could not create thread\n");
exit(1);
}
case OPT_SLAP_CONCURRENCY:
errno = 0;
opt_concurrency = (unsigned int) strtoul(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
fprintf(stderr, "Invalid value for concurrency: %s\n", optarg);
exit(EXIT_FAILURE);
}
case OPT_SLAP_EXECUTE_NUMBER:
errno = 0;
opt_execute_number = (unsigned int) strtoul(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
fprintf(stderr, "Invalid value for execute: %s\n", optarg);
exit(EXIT_FAILURE);
}
case OPT_SLAP_INITIAL_LOAD:
errno = 0;
opt_createial_load = (unsigned int) strtoul(optarg, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
fprintf(stderr, "Invalid value for initial load: %s\n", optarg);
exit(EXIT_FAILURE);
}
case OPT_EXPIRE:
errno = 0;
expiration = time_t(strtoul(optarg, (char **) NULL, 10));
- if (errno != 0) {
+ if (errno) {
fprintf(stderr, "Invalid value for --expire: %s\n", optarg);
exit(EXIT_FAILURE);
}
}
// If Zero, my hero, we just fail to a generic MEMCACHED_TIMEOUT error
- if (err != 0) {
+ if (err) {
return memcached_set_errno(
*server, err, MEMCACHED_AT,
memcached_literal_param("getsockopt() found the error from poll() after connect() "
char str_port[MEMCACHED_NI_MAXSERV] = {0};
errno = 0;
int length = snprintf(str_port, MEMCACHED_NI_MAXSERV, "%u", uint32_t(server->port()));
- if (length >= MEMCACHED_NI_MAXSERV or length <= 0 or errno != 0) {
+ if (length >= MEMCACHED_NI_MAXSERV or length <= 0 or errno) {
return memcached_set_error(*server, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
memcached_literal_param("snprintf(NI_MAXSERV)"));
}
#ifdef HAVE_FCNTL
// If SOCK_CLOEXEC exists then we don't need to call the following
if (SOCK_CLOEXEC == 0) {
- if (FD_CLOEXEC != 0) {
+ if (FD_CLOEXEC) {
int flags;
do {
flags = fcntl(server->fd, F_GETFD, 0);
do {
int type = SOCK_STREAM;
- if (SOCK_CLOEXEC != 0) {
+ if (SOCK_CLOEXEC) {
type |= SOCK_CLOEXEC;
}
- if (SOCK_NONBLOCK != 0) {
+ if (SOCK_NONBLOCK) {
type |= SOCK_NONBLOCK;
}
/* Create the socket */
while (server->address_info_next and server->fd == INVALID_SOCKET) {
int type = server->address_info_next->ai_socktype;
- if (SOCK_CLOEXEC != 0) {
+ if (SOCK_CLOEXEC) {
type |= SOCK_CLOEXEC;
}
- if (SOCK_NONBLOCK != 0) {
+ if (SOCK_NONBLOCK) {
type |= SOCK_NONBLOCK;
}
// We now test if it is something other then a syntax error, if it we
// return a generic message
- if (strcmp(error_arg, "syntax error") != 0) {
+ if (strcmp(error_arg, "syntax error")) {
memcached_set_parser_error(*memc, MEMCACHED_AT,
"Error occured during parsing (%s): last_token=%s(%d)", error_arg,
last_token_str, last_token);
for (uint32_t x = 0; x < memcached_server_count(memc); ++x) {
memcached_instance_st *instance = memcached_instance_fetch(memc, x);
- if (instance->write_buffer_offset != 0) {
+ if (instance->write_buffer_offset) {
if (instance->fd == INVALID_SOCKET
and (ret = memcached_connect(instance)) != MEMCACHED_SUCCESS) {
WATCHPOINT_ERROR(ret);
ptr->state.is_parsing = true;
for (uint32_t x = 0; x < count; ++x, ++original_host_size) {
- WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
+ WATCHPOINT_ASSERT(list[x].hostname[0]);
// We have extended the array, and now we will find it, and use it.
memcached_instance_st *instance = memcached_instance_fetch(ptr, original_host_size);
// We use original_host_size since size will now point to the first new
// instance allocated.
for (uint32_t x = 0; x < number_of_hosts; ++x, ++original_host_size) {
- WATCHPOINT_ASSERT(list[x]._hostname[0] != 0);
+ WATCHPOINT_ASSERT(list[x]._hostname[0]);
// We have extended the array, and now we will find it, and use it.
memcached_instance_st *instance = memcached_instance_fetch(ptr, original_host_size);
** We might be able to process some of the response messages if we
** have a callback set up
*/
- if (instance->root->callbacks != NULL) {
+ if (instance->root->callbacks) {
/*
* We might have responses... try to read them out and fire
* callbacks
errno = 0;
port = (in_port_t) strtoul(ptr, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
memcached_server_free(servers);
return NULL;
}
ptr2++;
errno = 0;
weight = uint32_t(strtoul(ptr2, (char **) NULL, 10));
- if (errno != 0) {
+ if (errno) {
memcached_server_free(servers);
return NULL;
}
break;
}
- if (ptr->root->callbacks != NULL) {
+ if (ptr->root->callbacks) {
memcached_callback_st cb = *ptr->root->callbacks;
if (memcached_success(rc)) {
for (uint32_t y = 0; y < cb.number_of_callback; y++) {
errno = 0;
result->item_flags = (uint32_t) strtoul(next_ptr, &string_ptr, 10);
- if (errno != 0 or end_ptr == string_ptr) {
+ if (errno or end_ptr == string_ptr) {
goto read_error;
}
errno = 0;
value_length = (size_t) strtoull(next_ptr, &string_ptr, 10);
- if (errno != 0 or end_ptr == string_ptr) {
+ if (errno or end_ptr == string_ptr) {
goto read_error;
}
result->item_cas = strtoull(next_ptr, &string_ptr, 10);
}
- if (errno != 0 or end_ptr < string_ptr) {
+ if (errno or end_ptr < string_ptr) {
goto read_error;
}
char *endptr;
errno = 0;
long int version = strtol(response_ptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
or version == 0) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
result->numeric_value = UINT64_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
memcached_literal_param("Numeric response was out of range"));
- } else if (errno != 0) {
+ } else if (errno) {
result->numeric_value = UINT64_MAX;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
memcached_literal_param("Numeric response was out of range"));
} break;
case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: {
- if (header.response.keylen != 0 || bodylen + 1 > buffer_length) {
+ if (header.response.keylen || bodylen + 1 > buffer_length) {
return MEMCACHED_UNKNOWN_READ_FAILURE;
} else {
if ((rc = memcached_safe_read(instance, buffer, bodylen)) != MEMCACHED_SUCCESS) {
char *endptr;
errno = 0;
long int version = strtol(version_buffer, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX
or version == 0) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
endptr++;
errno = 0;
version = strtol(endptr, &endptr, 10);
- if (errno != 0 or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
+ if (errno or version == LONG_MIN or version == LONG_MAX or version > UINT8_MAX) {
instance->major_version = instance->minor_version = instance->micro_version = UINT8_MAX;
return memcached_set_error(
*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
}
rc = MEMCACHED_SUCCESS;
- if (header.response.status != 0) {
+ if (header.response.status) {
switch (header.response.status) {
case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT:
rc = MEMCACHED_NOTFOUND;
}
int pthread_error;
- if ((pthread_error = pthread_once(&sasl_startup_once, sasl_startup_function)) != 0) {
+ if ((pthread_error = pthread_once(&sasl_startup_once, sasl_startup_function))) {
return memcached_set_errno(*server, pthread_error, MEMCACHED_AT);
}
/* Increment count for hosts */
uint32_t count = 1;
- if (ptr != NULL) {
+ if (ptr) {
count += memcached_server_list_count(ptr);
}
} else if (strcmp("pid", key) == 0) {
errno = 0;
int64_t temp = strtoll(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("uptime", key)) {
errno = 0;
memc_stat->uptime = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("time", key)) {
errno = 0;
memc_stat->time = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("version", key)) {
} else if (not strcmp("pointer_size", key)) {
errno = 0;
memc_stat->pointer_size = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("rusage_user", key)) {
errno = 0;
memc_stat->rusage_user_seconds = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
errno = 0;
memc_stat->rusage_user_microseconds = strtoul(walk_ptr, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("rusage_system", key)) {
errno = 0;
memc_stat->rusage_system_seconds = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
errno = 0;
memc_stat->rusage_system_microseconds = strtoul(walk_ptr, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("curr_items", key)) {
errno = 0;
memc_stat->curr_items = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("total_items", key)) {
errno = 0;
memc_stat->total_items = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("bytes_read", key)) {
errno = 0;
memc_stat->bytes_read = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("bytes_written", key)) {
errno = 0;
memc_stat->bytes_written = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("bytes", key)) {
errno = 0;
memc_stat->bytes = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("curr_connections", key)) {
errno = 0;
memc_stat->curr_connections = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("total_connections", key)) {
errno = 0;
memc_stat->total_connections = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("connection_structures", key)) {
errno = 0;
memc_stat->connection_structures = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("cmd_get", key)) {
errno = 0;
memc_stat->cmd_get = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("cmd_set", key)) {
errno = 0;
memc_stat->cmd_set = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("get_hits", key)) {
errno = 0;
memc_stat->get_hits = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("get_misses", key)) {
errno = 0;
memc_stat->get_misses = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("evictions", key)) {
errno = 0;
memc_stat->evictions = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("limit_maxbytes", key)) {
errno = 0;
memc_stat->limit_maxbytes = strtoull(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if (not strcmp("threads", key)) {
errno = 0;
memc_stat->threads = strtoul(value, (char **) NULL, 10);
- if (errno != 0) {
+ if (errno) {
return MEMCACHED_FAILURE;
}
} else if ((strcmp("delete_misses", key) == 0 or /* New stats in the 1.3 beta */
int msg_num = get_msg_num_from_request_id(cur_req);
int thread_id = get_thread_id_from_request_id(cur_req);
- if (((++msg_num) & UDP_REQUEST_ID_THREAD_MASK) != 0)
+ if (((++msg_num) & UDP_REQUEST_ID_THREAD_MASK))
msg_num = 0;
header->request_id = htons((uint16_t)(thread_id | msg_num));
return PROTOCOL_BINARY_RESPONSE_EINTERNAL;
}
- assert(client->output != NULL);
+ assert(client->output);
#if 0
if (client->output == NULL)
{
uint32_t bodylen) {
memcached_protocol_client_st *client = (void *) cookie;
- if (key != NULL) {
+ if (key) {
ascii_raw_response_handler(client, "STAT ");
client->root->spool(client, key, keylen);
ascii_raw_response_handler(client, " ");
uint64_t result;
errno = 0;
uint64_t delta = strtoull(tokens[2], NULL, 10);
- if (errno != 0) {
+ if (errno) {
return; // Error
}
if (ntokens == 2) {
errno = 0;
timeout = (uint32_t) strtoul(tokens[1], NULL, 10);
- if (errno != 0) {
+ if (errno) {
return; // Error
}
}
errno = 0;
uint32_t flags = (uint32_t) strtoul(tokens[2], NULL, 10);
- if (errno != 0) {
+ if (errno) {
/* return error */
ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
uint32_t timeout = (uint32_t) strtoul(tokens[3], NULL, 10);
- if (errno != 0) {
+ if (errno) {
/* return error */
ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
}
unsigned long nbytes = strtoul(tokens[4], NULL, 10);
- if (errno != 0) {
+ if (errno) {
/* return error */
ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
case CAS_CMD:
errno = 0;
cas = strtoull(tokens[5], NULL, 10);
- if (errno != 0) {
+ if (errno) {
/* return error */
ascii_raw_response_handler(client, "CLIENT_ERROR: bad key\r\n");
return -1;
client->ascii_command = ascii_to_cmd(ptr, (size_t)(*length));
/* we got all data available, execute the callback! */
- if (client->root->callback->pre_execute != NULL) {
+ if (client->root->callback->pre_execute) {
client->root->callback->pre_execute(client, NULL);
}
* just handle them immediately
*/
if (client->ascii_command == GET_CMD || client->ascii_command == GETS_CMD) {
- if (client->root->callback->interface.v1.get != NULL) {
+ if (client->root->callback->interface.v1.get) {
ascii_process_gets(client, ptr, end);
} else {
ascii_raw_response_handler(client, "SERVER_ERROR: Command not implemented\n");
if (ntokens != 1 || client->mute) {
send_command_usage(client);
} else {
- if (client->root->callback->interface.v1.quit != NULL) {
+ if (client->root->callback->interface.v1.quit) {
client->root->callback->interface.v1.quit(client);
}
}
}
- if (client->root->callback->post_execute != NULL) {
+ if (client->root->callback->post_execute) {
client->root->callback->post_execute(client, NULL);
}
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.add != NULL) {
+ if (client->root->callback->interface.v1.add) {
uint16_t keylen = ntohs(header->request.keylen);
uint32_t datalen = ntohl(header->request.bodylen) - keylen - 8;
protocol_binary_request_add *request = (void *) header;
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.decrement != NULL) {
+ if (client->root->callback->interface.v1.decrement) {
uint16_t keylen = ntohs(header->request.keylen);
protocol_binary_request_decr *request = (void *) header;
uint64_t init = memcached_ntohll(request->message.body.initial);
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.delete_object != NULL) {
+ if (client->root->callback->interface.v1.delete_object) {
uint16_t keylen = ntohs(header->request.keylen);
void *key = (header + 1);
uint64_t cas = memcached_ntohll(header->request.cas);
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.flush_object != NULL) {
+ if (client->root->callback->interface.v1.flush_object) {
protocol_binary_request_flush *flush_object = (void *) header;
uint32_t timeout = 0;
if (htonl(header->request.bodylen) == 4) {
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.get != NULL) {
+ if (client->root->callback->interface.v1.get) {
uint16_t keylen = ntohs(header->request.keylen);
void *key = (header + 1);
rval = client->root->callback->interface.v1.get(cookie, key, keylen, get_response_handler);
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.increment != NULL) {
+ if (client->root->callback->interface.v1.increment) {
uint16_t keylen = ntohs(header->request.keylen);
protocol_binary_request_incr *request = (void *) header;
uint64_t init = memcached_ntohll(request->message.body.initial);
noop_command_handler(const void *cookie, protocol_binary_request_header *header,
memcached_binary_protocol_raw_response_handler response_handler) {
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.noop != NULL) {
+ if (client->root->callback->interface.v1.noop) {
client->root->callback->interface.v1.noop(cookie);
}
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.append != NULL) {
+ if (client->root->callback->interface.v1.append) {
uint16_t keylen = ntohs(header->request.keylen);
uint32_t datalen = ntohl(header->request.bodylen) - keylen;
char *key = (void *) (header + 1);
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.prepend != NULL) {
+ if (client->root->callback->interface.v1.prepend) {
uint16_t keylen = ntohs(header->request.keylen);
uint32_t datalen = ntohl(header->request.bodylen) - keylen;
char *key = (char *) (header + 1);
quit_command_handler(const void *cookie, protocol_binary_request_header *header,
memcached_binary_protocol_raw_response_handler response_handler) {
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.quit != NULL) {
+ if (client->root->callback->interface.v1.quit) {
client->root->callback->interface.v1.quit(cookie);
}
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.replace != NULL) {
+ if (client->root->callback->interface.v1.replace) {
uint16_t keylen = ntohs(header->request.keylen);
uint32_t datalen = ntohl(header->request.bodylen) - keylen - 8;
protocol_binary_request_replace *request = (void *) header;
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.set != NULL) {
+ if (client->root->callback->interface.v1.set) {
uint16_t keylen = ntohs(header->request.keylen);
uint32_t datalen = ntohl(header->request.bodylen) - keylen - 8;
protocol_binary_request_replace *request = (void *) header;
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.stat != NULL) {
+ if (client->root->callback->interface.v1.stat) {
uint16_t keylen = ntohs(header->request.keylen);
rval = client->root->callback->interface.v1.stat(cookie, (void *) (header + 1), keylen,
protocol_binary_response_status rval;
memcached_protocol_client_st *client = (void *) cookie;
- if (client->root->callback->interface.v1.version != NULL) {
+ if (client->root->callback->interface.v1.version) {
rval = client->root->callback->interface.v1.version(cookie, version_response_handler);
} else {
rval = PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND;
}
/* we got all data available, execute the callback! */
- if (client->root->callback->pre_execute != NULL) {
+ if (client->root->callback->pre_execute) {
client->root->callback->pre_execute(client, header);
}
switch (client->root->callback->interface_version) {
case 0:
- if (client->root->callback->interface.v0.comcode[cc] != NULL) {
+ if (client->root->callback->interface.v0.comcode[cc]) {
rval = client->root->callback->interface.v0.comcode[cc](client, header,
binary_raw_response_handler);
}
break;
case 1:
- if (comcode_v0_v1_remap[cc] != NULL) {
+ if (comcode_v0_v1_remap[cc]) {
rval = comcode_v0_v1_remap[cc](client, header, binary_raw_response_handler);
}
break;
abort();
}
- if (rval == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND && client->root->callback->unknown != NULL) {
+ if (rval == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND && client->root->callback->unknown) {
rval = client->root->callback->unknown(client, header, binary_raw_response_handler);
}
rval = binary_raw_response_handler(client, header, (void *) &response);
}
- if (client->root->callback->post_execute != NULL) {
+ if (client->root->callback->post_execute) {
client->root->callback->post_execute(client, header);
}
object = get_object(ret);
} else {
object = ret = malloc(cache->bufsize);
- if (ret != NULL) {
+ if (ret) {
object = get_object(ret);
- if (cache->constructor != NULL && cache->constructor(object, NULL, 0) != 0) {
+ if (cache->constructor && cache->constructor(object, NULL, 0)) {
free(ret);
object = NULL;
}
pthread_mutex_unlock(&cache->mutex);
#ifndef NDEBUG
- if (object != NULL) {
+ if (object) {
/* add a simple form of buffer-check */
uint64_t *pre = ret;
*pre = redzone_pattern;
/* validate redzone... */
if (memcmp(((char *) ptr) + cache->bufsize - (2 * sizeof(redzone_pattern)), &redzone_pattern,
sizeof(redzone_pattern))
- != 0)
+)
{
raise(SIGABRT);
cache_error = 1;
}
/* Do we have pending data to send? */
- while (client->output != NULL) {
+ while (client->output) {
ssize_t len =
client->root->send(client, client->sock, client->output->data + client->output->offset,
client->output->nbytes - client->output->offset);
*/
struct memcached_protocol_st *memcached_protocol_create_instance(void) {
struct memcached_protocol_st *ret = calloc(1, sizeof(*ret));
- if (ret != NULL) {
+ if (ret) {
ret->recv = default_recv;
ret->send = default_send;
ret->drain = drain_output;
struct memcached_protocol_client_st *
memcached_protocol_create_client(struct memcached_protocol_st *instance, memcached_socket_t sock) {
struct memcached_protocol_client_st *ret = calloc(1, sizeof(memcached_protocol_client_st));
- if (ret != NULL) {
+ if (ret) {
ret->root = instance;
ret->sock = sock;
ret->work = determine_protocol;
ensure(response->response.keylen == 0);
ensure(response->response.extlen == 0);
ensure(response->response.bodylen == 0);
- ensure(response->response.cas != 0);
+ ensure(response->response.cas);
break;
case PROTOCOL_BINARY_CMD_FLUSH:
case PROTOCOL_BINARY_CMD_NOOP:
ensure(response->response.keylen == 0);
ensure(response->response.extlen == 0);
ensure(ntohl(response->response.bodylen) == 8);
- ensure(response->response.cas != 0);
+ ensure(response->response.cas);
break;
case PROTOCOL_BINARY_CMD_STAT:
case PROTOCOL_BINARY_CMD_VERSION:
ensure(response->response.keylen == 0);
ensure(response->response.extlen == 0);
- ensure(response->response.bodylen != 0);
+ ensure(response->response.bodylen);
ensure(response->response.cas == 0);
break;
case PROTOCOL_BINARY_CMD_GETQ:
ensure(response->response.keylen == 0);
ensure(response->response.extlen == 4);
- ensure(response->response.cas != 0);
+ ensure(response->response.cas);
break;
case PROTOCOL_BINARY_CMD_GETK:
case PROTOCOL_BINARY_CMD_GETKQ:
- ensure(response->response.keylen != 0);
+ ensure(response->response.keylen);
ensure(response->response.extlen == 4);
- ensure(response->response.cas != 0);
+ ensure(response->response.cas);
break;
default:
}
int error;
- if ((error = pthread_mutex_destroy(&mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_destroy() %s(%d)", strerror(error), error);
+ if ((error = pthread_mutex_destroy(&mutex))) {
+ assert_vmsg(error, "pthread_mutex_destroy() %s(%d)", strerror(error), error);
}
- if ((error = pthread_cond_destroy(&cond)) != 0) {
- assert_vmsg(error != 0, "pthread_cond_destroy() %s", strerror(error));
+ if ((error = pthread_cond_destroy(&cond))) {
+ assert_vmsg(error, "pthread_cond_destroy() %s", strerror(error));
}
delete[] server_pool;
rc = MEMCACHED_SUCCESS;
int error;
- if ((error = pthread_mutex_lock(&mutex)) != 0) {
+ if ((error = pthread_mutex_lock(&mutex))) {
rc = MEMCACHED_IN_PROGRESS;
return NULL;
}
time_to_wait.tv_nsec = relative_time.tv_nsec;
int thread_ret;
- if ((thread_ret = pthread_cond_timedwait(&cond, &mutex, &time_to_wait)) != 0) {
+ if ((thread_ret = pthread_cond_timedwait(&cond, &mutex, &time_to_wait))) {
int unlock_error;
- if ((unlock_error = pthread_mutex_unlock(&mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ if ((unlock_error = pthread_mutex_unlock(&mutex))) {
+ assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error));
}
if (thread_ret == ETIMEDOUT) {
}
} else if (grow_pool(this) == false) {
int unlock_error;
- if ((unlock_error = pthread_mutex_unlock(&mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ if ((unlock_error = pthread_mutex_unlock(&mutex))) {
+ assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error));
}
return NULL;
}
} while (ret == NULL);
- if ((error = pthread_mutex_unlock(&mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ if ((error = pthread_mutex_unlock(&mutex))) {
+ assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error));
}
return ret;
if (firstfree == 0 and current_size == size) {
/* we might have people waiting for a connection.. wake them up :-) */
- if ((error = pthread_cond_broadcast(&cond)) != 0) {
- assert_vmsg(error != 0, "pthread_cond_broadcast() %s", strerror(error));
+ if ((error = pthread_cond_broadcast(&cond))) {
+ assert_vmsg(error, "pthread_cond_broadcast() %s", strerror(error));
}
}
- if ((error = pthread_mutex_unlock(&mutex)) != 0) {
+ if ((error = pthread_mutex_unlock(&mutex))) {
}
return true;
/* update the master */
memcached_return_t rc = memcached_behavior_set(pool->master, flag, data);
if (memcached_failed(rc)) {
- if ((error = pthread_mutex_unlock(&pool->mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ if ((error = pthread_mutex_unlock(&pool->mutex))) {
+ assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error));
}
return rc;
}
}
}
- if ((error = pthread_mutex_unlock(&pool->mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ if ((error = pthread_mutex_unlock(&pool->mutex))) {
+ assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error));
}
return rc;
*value = memcached_behavior_get(pool->master, flag);
- if ((error = pthread_mutex_unlock(&pool->mutex)) != 0) {
- assert_vmsg(error != 0, "pthread_mutex_unlock() %s", strerror(error));
+ if ((error = pthread_mutex_unlock(&pool->mutex))) {
+ assert_vmsg(error, "pthread_mutex_unlock() %s", strerror(error));
}
return MEMCACHED_SUCCESS;
}
#if 0
- if (pthread_equal(thread, pthread_self()) != 0 and (pthread_kill(thread, 0) == ESRCH) == true)
+ if (pthread_equal(thread, pthread_self()) and (pthread_kill(thread, 0) == ESRCH) == true)
{
void *retval;
pthread_join(thread, &retval);
set_shutdown(SHUTDOWN_RUNNING);
int error;
- if ((error= pthread_sigmask(SIG_BLOCK, &set, NULL)) != 0)
+ if ((error= pthread_sigmask(SIG_BLOCK, &set, NULL)))
{
std::cerr << "pthread_sigmask() died during pthread_sigmask(" << strerror(error) << ")" << std::endl;
return false;
}
- if ((error= pthread_create(&thread, NULL, &sig_thread, this)) != 0)
+ if ((error= pthread_create(&thread, NULL, &sig_thread, this)))
{
std::cerr << "pthread_create() died during pthread_create(" << strerror(error) << ")" << std::endl;
return false;