X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Flibmemcachedprotocol%2Fascii_handler.c;h=a851dac9a237dec395a231b01f9661946fabcdff;hb=0d7a3e0e040ddf840d656b61f41419c252debcde;hp=f5d8e22cbc623f5ba4fe7e418a14666b87e514e3;hpb=0f27cca46a4a529459ca988268972f480a9730c6;p=awesomized%2Flibmemcached diff --git a/src/libmemcachedprotocol/ascii_handler.c b/src/libmemcachedprotocol/ascii_handler.c index f5d8e22c..a851dac9 100644 --- a/src/libmemcachedprotocol/ascii_handler.c +++ b/src/libmemcachedprotocol/ascii_handler.c @@ -1,6 +1,6 @@ /* +--------------------------------------------------------------------+ - | libmemcached - C/C++ Client Library for memcached | + | libmemcached-awesome - C/C++ Client Library for memcached | +--------------------------------------------------------------------+ | Redistribution and use in source and binary forms, with or without | | modification, are permitted under the terms of the BSD license. | @@ -9,7 +9,7 @@ | the terms online at: https://opensource.org/licenses/BSD-3-Clause | +--------------------------------------------------------------------+ | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ | - | Copyright (c) 2020 Michael Wallner | + | Copyright (c) 2020-2021 Michael Wallner https://awesome.co/ | +--------------------------------------------------------------------+ */ @@ -20,6 +20,7 @@ #include #include #include +#include static void print_ascii_command(memcached_protocol_client_st *client) { if (client->is_verbose) { @@ -141,7 +142,7 @@ ascii_raw_response_handler(memcached_protocol_client_st *client, const char *tex return PROTOCOL_BINARY_RESPONSE_EINTERNAL; } - assert(client->output != NULL); + assert(client->output); #if 0 if (client->output == NULL) { @@ -285,7 +286,7 @@ static protocol_binary_response_status ascii_stat_response_handler(const void *c 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, " "); @@ -479,7 +480,7 @@ static void process_arithmetic(memcached_protocol_client_st *client, char **toke uint64_t result; errno = 0; uint64_t delta = strtoull(tokens[2], NULL, 10); - if (errno != 0) { + if (errno) { return; // Error } @@ -558,7 +559,7 @@ static void process_flush(memcached_protocol_client_st *client, char **tokens, i if (ntokens == 2) { errno = 0; timeout = (uint32_t) strtoul(tokens[1], NULL, 10); - if (errno != 0) { + if (errno) { return; // Error } } @@ -598,21 +599,21 @@ static inline int process_storage_command(memcached_protocol_client_st *client, 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; @@ -642,7 +643,7 @@ static inline int process_storage_command(memcached_protocol_client_st *client, 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; @@ -810,7 +811,7 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz 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); } @@ -819,7 +820,7 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz * 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"); @@ -900,7 +901,7 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz 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); } @@ -934,7 +935,7 @@ memcached_ascii_protocol_process_data(memcached_protocol_client_st *client, ssiz } } - if (client->root->callback->post_execute != NULL) { + if (client->root->callback->post_execute) { client->root->callback->post_execute(client, NULL); }