Skip to content

Commit d0366df

Browse files
committed
Use cb_assert instead of assert
Change-Id: If6b3170af815c324b26ff44bea3b950deed774fd Reviewed-on: http://review.couchbase.org/49431 Tested-by: buildbot <[email protected]> Reviewed-by: Steve Yen <[email protected]>
1 parent 4a93775 commit d0366df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1307
-1314
lines changed

conflate/adhoc_commands.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4-
#include <assert.h>
4+
#include <platform/cbassert.h>
55

66
#include <libconflate/conflate.h>
77
#include "conflate_internal.h"
@@ -66,7 +66,7 @@ static enum conflate_mgmt_cb_result process_set_private(void *opaque,
6666
(void)r;
6767

6868
/* Only direct stat requests are handled. */
69-
assert(direct);
69+
cb_assert(direct);
7070

7171
if (key && value) {
7272
if (conflate_save_private(handle, key, value,
@@ -93,7 +93,7 @@ static enum conflate_mgmt_cb_result process_get_private(void *opaque,
9393
(void)cmd;
9494

9595
/* Only direct stat requests are handled. */
96-
assert(direct);
96+
cb_assert(direct);
9797

9898
if (key) {
9999
/* Initialize the form so there's always one there */
@@ -127,7 +127,7 @@ static enum conflate_mgmt_cb_result process_delete_private(void *opaque,
127127
(void)r;
128128

129129
/* Only direct stat requests are handled. */
130-
assert(direct);
130+
cb_assert(direct);
131131

132132
if (key) {
133133
if (conflate_delete_private(handle, key, handle->conf->save_path)) {

conflate/conflate.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <assert.h>
1+
#include <platform/cbassert.h>
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <string.h>
@@ -15,7 +15,7 @@ void run_conflate(void *);
1515

1616
conflate_config_t* dup_conf(conflate_config_t c) {
1717
conflate_config_t *rv = calloc(sizeof(conflate_config_t), 1);
18-
assert(rv);
18+
cb_assert(rv);
1919

2020
rv->jid = safe_strdup(c.jid);
2121
rv->pass = safe_strdup(c.pass);
@@ -36,7 +36,7 @@ conflate_config_t* dup_conf(conflate_config_t c) {
3636

3737
void init_conflate(conflate_config_t *conf)
3838
{
39-
assert(conf);
39+
cb_assert(conf);
4040
memset(conf, 0x00, sizeof(conflate_config_t));
4141
conf->log = conflate_stderr_logger;
4242
conf->initialization_marker = (void*)INITIALIZATION_MAGIC;
@@ -48,12 +48,12 @@ bool start_conflate(conflate_config_t conf) {
4848

4949
/* Don't start if we don't believe initialization has occurred. */
5050
if (conf.initialization_marker != (void*)INITIALIZATION_MAGIC) {
51-
assert(conf.initialization_marker == (void*)INITIALIZATION_MAGIC);
51+
cb_assert(conf.initialization_marker == (void*)INITIALIZATION_MAGIC);
5252
return false;
5353
}
5454

5555
handle = calloc(1, sizeof(conflate_handle_t));
56-
assert(handle);
56+
cb_assert(handle);
5757

5858
if (strncmp(HTTP_PREFIX, conf.host, strlen(HTTP_PREFIX))) {
5959
run_func = &run_rest_conflate;

conflate/kvpair.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4-
#include <assert.h>
4+
#include <platform/cbassert.h>
55

66
#include <libconflate/conflate.h>
77

88
kvpair_t* mk_kvpair(const char* k, char** v)
99
{
1010
kvpair_t* rv = calloc(1, sizeof(kvpair_t));
11-
assert(rv);
11+
cb_assert(rv);
1212

1313
rv->key = safe_strdup(k);
1414
if (v) {
@@ -19,16 +19,16 @@ kvpair_t* mk_kvpair(const char* k, char** v)
1919
} else {
2020
rv->allocated_values = 4;
2121
rv->values = calloc(4, sizeof(char*));
22-
assert(rv->values);
22+
cb_assert(rv->values);
2323
}
2424

2525
return rv;
2626
}
2727

2828
void add_kvpair_value(kvpair_t* pair, const char* value)
2929
{
30-
assert(pair);
31-
assert(value);
30+
cb_assert(pair);
31+
cb_assert(value);
3232

3333
/* The last item in the values list must be null as it acts a sentinal */
3434
if (pair->allocated_values == 0 ||
@@ -40,7 +40,7 @@ void add_kvpair_value(kvpair_t* pair, const char* value)
4040

4141
pair->values = realloc(pair->values,
4242
sizeof(char*) * pair->allocated_values);
43-
assert(pair->values);
43+
cb_assert(pair->values);
4444
}
4545

4646
pair->values[pair->used_values++] = safe_strdup(value);
@@ -70,7 +70,7 @@ void walk_kvpair(kvpair_t *pair, void *opaque, kvpair_visitor_t visitor)
7070

7171
kvpair_t* find_kvpair(kvpair_t* pair, const char* key)
7272
{
73-
assert(key);
73+
cb_assert(key);
7474

7575
while (pair && strcmp(pair->key, key) != 0) {
7676
pair = pair->next;
@@ -83,7 +83,7 @@ char *get_simple_kvpair_val(kvpair_t *pair, const char *key)
8383
{
8484
char *rv = NULL;
8585
kvpair_t *found;
86-
assert(key);
86+
cb_assert(key);
8787
found = find_kvpair(pair, key);
8888

8989
if (found) {
@@ -96,7 +96,7 @@ char *get_simple_kvpair_val(kvpair_t *pair, const char *key)
9696
kvpair_t *dup_kvpair(kvpair_t *pair)
9797
{
9898
kvpair_t *copy;
99-
assert(pair);
99+
cb_assert(pair);
100100
copy = mk_kvpair(pair->key, pair->values);
101101
if (pair->next) {
102102
copy->next = dup_kvpair(pair->next);

conflate/persist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4-
#include <assert.h>
4+
#include <platform/cbassert.h>
55

66
#include <libconflate/conflate.h>
77
#include "conflate_internal.h"

conflate/rest.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <assert.h>
1+
#include <platform/cbassert.h>
22
#include <stdlib.h>
33
#include <stdio.h>
44
#include <sys/types.h>
@@ -37,9 +37,9 @@ struct response_buffer *cur_response_buffer = NULL;
3737
static struct response_buffer *mk_response_buffer(size_t size) {
3838
struct response_buffer *r =
3939
(struct response_buffer *) calloc(1, sizeof(struct response_buffer));
40-
assert(r);
40+
cb_assert(r);
4141
r->data = malloc(size);
42-
assert(r->data);
42+
cb_assert(r->data);
4343
r->bytes_used = 0;
4444
r->buffer_size = size;
4545
r->next = NULL;
@@ -102,7 +102,7 @@ static char *assemble_complete_response(struct response_buffer *response_head) {
102102

103103
/* create buffer */
104104
response = malloc(response_size + 1);
105-
assert(response);
105+
cb_assert(response);
106106

107107
/* populate buffer */
108108
cur_buffer = response_head;
@@ -120,8 +120,8 @@ static char *assemble_complete_response(struct response_buffer *response_head) {
120120

121121
static bool pattern_ends_with(const char *pattern, const char *target, size_t target_size) {
122122
size_t pattern_size;
123-
assert(target);
124-
assert(pattern);
123+
cb_assert(target);
124+
cb_assert(pattern);
125125

126126
pattern_size = strlen(pattern);
127127
if (target_size < pattern_size) {
@@ -210,23 +210,23 @@ static void setup_handle(CURL *handle, char *url, char *userpass,
210210
CURLcode c;
211211

212212
c = curl_easy_setopt(handle, CURLOPT_SOCKOPTFUNCTION, setup_curl_sock);
213-
assert(c == CURLE_OK);
213+
cb_assert(c == CURLE_OK);
214214
c = curl_easy_setopt(handle, CURLOPT_WRITEDATA, chandle);
215-
assert(c == CURLE_OK);
215+
cb_assert(c == CURLE_OK);
216216
c = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, response_handler);
217-
assert(c == CURLE_OK);
217+
cb_assert(c == CURLE_OK);
218218
c = curl_easy_setopt(handle, CURLOPT_URL, url);
219-
assert(c == CURLE_OK);
219+
cb_assert(c == CURLE_OK);
220220

221221
if (userpass != NULL) {
222222
c = curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
223-
assert(c == CURLE_OK);
223+
cb_assert(c == CURLE_OK);
224224
c = curl_easy_setopt(handle, CURLOPT_USERPWD, userpass);
225-
assert(c == CURLE_OK);
225+
cb_assert(c == CURLE_OK);
226226
}
227227

228228
c = curl_easy_setopt(handle, CURLOPT_HTTPGET, 1);
229-
assert(c == CURLE_OK);
229+
cb_assert(c == CURLE_OK);
230230
}
231231
}
232232

@@ -270,10 +270,10 @@ void run_rest_conflate(void *arg) {
270270

271271
/* init curl */
272272
c = curl_global_init(curl_init_flags);
273-
assert(c == CURLE_OK);
273+
cb_assert(c == CURLE_OK);
274274

275275
curl_handle = curl_easy_init();
276-
assert(curl_handle);
276+
cb_assert(curl_handle);
277277

278278
curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, &curl_error_string);
279279

@@ -290,7 +290,7 @@ void run_rest_conflate(void *arg) {
290290
if (handle->conf->jid && strlen(handle->conf->jid)) {
291291
size_t buff_size = strlen(handle->conf->jid) + strlen(handle->conf->pass) + 2;
292292
userpass = (char *) malloc(buff_size);
293-
assert(userpass);
293+
cb_assert(userpass);
294294
snprintf(userpass, buff_size, "%s:%s", handle->conf->jid, handle->conf->pass);
295295
userpass[buff_size - 1] = '\0';
296296
}

conflate/util.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include <stdio.h>
22
#include <stdlib.h>
3-
#include <assert.h>
3+
#include <platform/cbassert.h>
44
#include <string.h>
55

66
#include <libconflate/conflate.h>
77

88
char* safe_strdup(const char* in) {
99
int len = strlen(in);
1010
char *rv = calloc(len + 1, sizeof(char));
11-
assert(rv);
11+
cb_assert(rv);
1212
memcpy(rv, in, len);
1313
return rv;
1414
}

conflate/xmpp.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4-
#include <assert.h>
4+
#include <platform/cbassert.h>
55

66
#include <libconflate/conflate.h>
77
#include "conflate_internal.h"
@@ -25,27 +25,27 @@ void conflate_init_form(conflate_form_result *r)
2525

2626
void conflate_next_fieldset(conflate_form_result *r) {
2727
(void)r;
28-
assert(0);
28+
cb_assert(0);
2929
}
3030

3131
void conflate_add_field(conflate_form_result *r, const char *k, const char *v) {
3232
(void)r;
3333
(void)k;
3434
(void)v;
35-
assert(0);
35+
cb_assert(0);
3636
}
3737

3838
void conflate_add_field_multi(conflate_form_result *r, const char *k,
3939
const char **v) {
4040
(void)r;
4141
(void)k;
4242
(void)v;
43-
assert(0);
43+
cb_assert(0);
4444
}
4545

4646
void* run_conflate(void *arg) {
4747
(void)arg;
48-
assert(0);
48+
cb_assert(0);
4949
return NULL;
5050
}
5151

@@ -55,7 +55,7 @@ void conflate_register_mgmt_cb(const char *cmd, const char *desc,
5555
conflate_mgmt_cb_t cb)
5656
{
5757
struct command_def *c = calloc(1, sizeof(struct command_def));
58-
assert(c);
58+
cb_assert(c);
5959

6060
c->name = safe_strdup(cmd);
6161
c->description = safe_strdup(desc);

libmemcached/libhashkit/digest.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ uint32_t libhashkit_digest(const char *key, size_t key_length, hashkit_hash_algo
5151
#ifdef HAVE_DEBUG
5252
fprintf(stderr, "hashkit_hash_t was extended but libhashkit_generate_value was not updated\n");
5353
fflush(stderr);
54-
assert(0);
54+
cb_assert(0);
5555
#endif
5656
break;
5757
}

0 commit comments

Comments
 (0)