From ea0a81db2fc3f8276b9e4fffb73090b83e50e34e Mon Sep 17 00:00:00 2001 From: brarcher Date: Mon, 23 Jun 2014 04:13:18 +0000 Subject: [PATCH] Case void* to goal container after emalloc() These changes were necessary to get Check to compile with a c++ compiler. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1156 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- src/check.c | 18 +++++++++--------- src/check_list.c | 6 +++--- src/check_log.c | 2 +- src/check_pack.c | 16 ++++++++-------- src/check_run.c | 6 +++--- src/check_str.c | 4 ++-- tests/check_check_master.c | 8 ++++---- tests/check_check_pack.c | 8 ++++---- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/check.c b/src/check.c index caba859..7310846 100644 --- a/src/check.c +++ b/src/check.c @@ -60,7 +60,7 @@ Suite *suite_create(const char *name) { Suite *s; - s = emalloc(sizeof(Suite)); /* freed in suite_free */ + s = (Suite *)emalloc(sizeof(Suite)); /* freed in suite_free */ if(name == NULL) s->name = ""; else @@ -108,7 +108,7 @@ TCase *tcase_create(const char *name) char *env; double timeout_sec = DEFAULT_TIMEOUT; - TCase *tc = emalloc(sizeof(TCase)); /*freed in tcase_free */ + TCase *tc = (TCase *)emalloc(sizeof(TCase)); /*freed in tcase_free */ if(name == NULL) tc->name = ""; @@ -184,7 +184,7 @@ void _tcase_add_test(TCase * tc, TFun fn, const char *name, int _signal, if(tc == NULL || fn == NULL || name == NULL) return; - tf = emalloc(sizeof(TF)); /* freed in tcase_free */ + tf = (TF *)emalloc(sizeof(TF)); /* freed in tcase_free */ tf->fn = fn; tf->loop_start = start; tf->loop_end = end; @@ -198,7 +198,7 @@ static Fixture *fixture_create(SFun fun, int ischecked) { Fixture *f; - f = emalloc(sizeof(Fixture)); + f = (Fixture *)emalloc(sizeof(Fixture)); f->fun = fun; f->ischecked = ischecked; @@ -313,12 +313,12 @@ void _ck_assert_failed(const char *file, int line, const char *expr, ...) SRunner *srunner_create(Suite * s) { - SRunner *sr = emalloc(sizeof(SRunner)); /* freed in srunner_free */ + SRunner *sr = (SRunner *)emalloc(sizeof(SRunner)); /* freed in srunner_free */ sr->slst = check_list_create(); if(s != NULL) check_list_add_end(sr->slst, s); - sr->stats = emalloc(sizeof(TestStats)); /* freed in srunner_free */ + sr->stats = (TestStats *)emalloc(sizeof(TestStats)); /* freed in srunner_free */ sr->stats->n_checked = sr->stats->n_failed = sr->stats->n_errors = 0; sr->resultlst = check_list_create(); sr->log_fname = NULL; @@ -390,7 +390,7 @@ TestResult **srunner_failures(SRunner * sr) TestResult **trarray; List *rlst; - trarray = malloc(sizeof(trarray[0]) * srunner_ntests_failed(sr)); + trarray = (TestResult **)emalloc(sizeof(trarray[0]) * srunner_ntests_failed(sr)); rlst = sr->resultlst; for(check_list_front(rlst); !check_list_at_end(rlst); @@ -411,7 +411,7 @@ TestResult **srunner_results(SRunner * sr) TestResult **trarray; List *rlst; - trarray = malloc(sizeof(trarray[0]) * srunner_ntests_run(sr)); + trarray =(TestResult **) emalloc(sizeof(trarray[0]) * srunner_ntests_run(sr)); rlst = sr->resultlst; for(check_list_front(rlst); !check_list_at_end(rlst); @@ -431,7 +431,7 @@ TestResult *tr_create(void) { TestResult *tr; - tr = emalloc(sizeof(TestResult)); + tr = (TestResult *)emalloc(sizeof(TestResult)); tr_init(tr); return tr; } diff --git a/src/check_list.c b/src/check_list.c index 5483683..98c7853 100644 --- a/src/check_list.c +++ b/src/check_list.c @@ -47,7 +47,7 @@ static void maybe_grow(List * lp) if(lp->n_elts >= lp->max_elts) { lp->max_elts *= LGROW; - lp->data = erealloc(lp->data, lp->max_elts * sizeof(lp->data[0])); + lp->data = (void **)erealloc(lp->data, lp->max_elts * sizeof(lp->data[0])); } } @@ -55,10 +55,10 @@ List *check_list_create(void) { List *lp; - lp = emalloc(sizeof(List)); + lp = (List *)emalloc(sizeof(List)); lp->n_elts = 0; lp->max_elts = LINIT; - lp->data = emalloc(sizeof(lp->data[0]) * LINIT); + lp->data = (void **)emalloc(sizeof(lp->data[0]) * LINIT); lp->current = lp->last = -1; return lp; } diff --git a/src/check_log.c b/src/check_log.c index 8050bdd..a1967e4 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -113,7 +113,7 @@ const char *srunner_tap_fname(SRunner * sr) void srunner_register_lfun(SRunner * sr, FILE * lfile, int close, LFun lfun, enum print_output printmode) { - Log *l = emalloc(sizeof(Log)); + Log *l = (Log *)emalloc(sizeof(Log)); if(printmode == CK_ENV) { diff --git a/src/check_pack.c b/src/check_pack.c index fc4a020..2174c51 100644 --- a/src/check_pack.c +++ b/src/check_pack.c @@ -179,14 +179,14 @@ static char *upack_str(char **buf) if(strsz > 0) { - val = emalloc(strsz + 1); + val = (char *)emalloc(strsz + 1); memcpy(val, *buf, strsz); val[strsz] = 0; *buf += strsz; } else { - val = emalloc(1); + val = (char *)emalloc(1); *val = 0; } @@ -210,7 +210,7 @@ static int pack_ctx(char **buf, CtxMsg * cmsg) int len; len = 4 + 4; - *buf = ptr = emalloc(len); + *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_CTX); pack_int(&ptr, (int)cmsg->ctx); @@ -229,7 +229,7 @@ static int pack_duration(char **buf, DurationMsg * cmsg) int len; len = 4 + 4; - *buf = ptr = emalloc(len); + *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_DURATION); pack_int(&ptr, cmsg->duration); @@ -248,7 +248,7 @@ static int pack_loc(char **buf, LocMsg * lmsg) int len; len = 4 + 4 + (lmsg->file ? strlen(lmsg->file) : 0) + 4; - *buf = ptr = emalloc(len); + *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_LOC); pack_str(&ptr, lmsg->file); @@ -269,7 +269,7 @@ static int pack_fail(char **buf, FailMsg * fmsg) int len; len = 4 + 4 + (fmsg->msg ? strlen(fmsg->msg) : 0); - *buf = ptr = emalloc(len); + *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_FAIL); pack_str(&ptr, fmsg->msg); @@ -402,7 +402,7 @@ static RcvMsg *rcvmsg_create(void) { RcvMsg *rmsg; - rmsg = emalloc(sizeof(RcvMsg)); + rmsg = (RcvMsg *)emalloc(sizeof(RcvMsg)); rmsg->lastctx = CK_CTX_INVALID; rmsg->failctx = CK_CTX_INVALID; rmsg->msg = NULL; @@ -455,7 +455,7 @@ RcvMsg *punpack(FILE * fdes) rmsg = rcvmsg_create(); /* Allcate a buffer */ - buf = emalloc(CK_MAX_MSG_SIZE); + buf = (char *)emalloc(CK_MAX_MSG_SIZE); /* Fill the buffer from the file */ nread = read_buf(fdes, CK_MAX_MSG_SIZE, buf); nparse = nread; diff --git a/src/check_run.c b/src/check_run.c index 449626c..5d8ca3c 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -608,7 +608,7 @@ static void set_fork_info(TestResult * tr, int status, int signal_expected, static char *signal_msg(int signal) { - char *msg = emalloc(MSG_LEN); /* free'd by caller */ + char *msg = (char *)emalloc(MSG_LEN); /* free'd by caller */ if(alarm_received) { @@ -626,7 +626,7 @@ static char *signal_error_msg(int signal_received, int signal_expected) { char *sig_r_str; char *sig_e_str; - char *msg = emalloc(MSG_LEN); /* free'd by caller */ + char *msg = (char *)emalloc(MSG_LEN); /* free'd by caller */ sig_r_str = strdup(strsignal(signal_received)); sig_e_str = strdup(strsignal(signal_expected)); @@ -648,7 +648,7 @@ static char *signal_error_msg(int signal_received, int signal_expected) static char *exit_msg(int exitval) { - char *msg = emalloc(MSG_LEN); /* free'd by caller */ + char *msg = (char *)emalloc(MSG_LEN); /* free'd by caller */ snprintf(msg, MSG_LEN, "Early exit with return value %d", exitval); return msg; diff --git a/src/check_str.c b/src/check_str.c index ad9b380..f557112 100644 --- a/src/check_str.c +++ b/src/check_str.c @@ -82,7 +82,7 @@ char *ck_strdup_printf(const char *fmt, ...) char *p; va_list ap; - p = emalloc(size); + p = (char *)emalloc(size); while(1) { @@ -100,7 +100,7 @@ char *ck_strdup_printf(const char *fmt, ...) else /* glibc 2.0 */ size *= 2; /* twice the old size */ - p = erealloc(p, size); + p = (char *)erealloc(p, size); } } diff --git a/tests/check_check_master.c b/tests/check_check_master.c index 1f4587d..45978bc 100644 --- a/tests/check_check_master.c +++ b/tests/check_check_master.c @@ -285,7 +285,7 @@ START_TEST(test_check_failure_msgs) got_msg = tr_msg(tr); expected_msg = master_tests[i].msg; if (strcmp(got_msg, expected_msg) != 0) { - char *emsg = malloc(MAXSTR); + char *emsg = (char *)malloc(MAXSTR); snprintf(emsg, MAXSTR,"For test %d: Expected %s, got %s", i, expected_msg, got_msg); ck_abort_msg(emsg); @@ -313,7 +313,7 @@ START_TEST(test_check_failure_lnos) ck_assert_msg(tr != NULL, NULL); line_no = master_tests_lineno[i]; if (line_no > 0 && tr_lno(tr) != line_no) { - char *emsg = malloc(MAXSTR); + char *emsg = (char *)malloc(MAXSTR); snprintf(emsg, MAXSTR, "For test %d: Expected lno %d, got %d", i, line_no, tr_lno(tr)); ck_abort_msg(emsg); @@ -362,7 +362,7 @@ START_TEST(test_check_tcnames) const char *tcname; tcname = tr_tcname(tr_all_array[_i]); if (strcmp(tcname, master_tests[_i].tcname) != 0) { - char *emsg = malloc (MAXSTR); + char *emsg = (char *)malloc (MAXSTR); snprintf(emsg, MAXSTR,"Expected %s, got %s", master_tests[_i].tcname, tcname); ck_abort_msg(emsg); @@ -377,7 +377,7 @@ START_TEST(test_check_all_msgs) const char *msg; msg = tr_msg(tr_all_array[_i]); if (strcmp(msg, master_tests[_i].msg) != 0) { - char *emsg = malloc (MAXSTR); + char *emsg = (char *)malloc (MAXSTR); snprintf(emsg, MAXSTR,"Expected %s, got %s", master_tests[_i].msg, msg); ck_abort_msg(emsg); diff --git a/tests/check_check_pack.c b/tests/check_check_pack.c index 80d178f..afadaaa 100644 --- a/tests/check_check_pack.c +++ b/tests/check_check_pack.c @@ -19,7 +19,7 @@ START_TEST(test_pack_fmsg) char *buf; enum ck_msg_type type; - fmsg = emalloc (sizeof (FailMsg)); + fmsg = (FailMsg *)emalloc (sizeof (FailMsg)); fmsg->msg = (char *) "Hello, world!"; pack (CK_MSG_FAIL, &buf, (CheckMsg *) fmsg); @@ -52,7 +52,7 @@ START_TEST(test_pack_loc) char *buf; enum ck_msg_type type; - lmsg = emalloc (sizeof (LocMsg)); + lmsg =(LocMsg *) emalloc (sizeof (LocMsg)); lmsg->file = (char *) "abc123.c"; lmsg->line = 125; @@ -382,11 +382,11 @@ START_TEST(test_ppack_big) RcvMsg *rmsg; cmsg.ctx = CK_CTX_TEST; - lmsg.file = emalloc (BIG_MSG_LEN); + lmsg.file = (char *)emalloc (BIG_MSG_LEN); memset (lmsg.file,'a',BIG_MSG_LEN - 1); lmsg.file[BIG_MSG_LEN - 1] = '\0'; lmsg.line = 10; - fmsg.msg = emalloc (BIG_MSG_LEN); + fmsg.msg = (char *)emalloc (BIG_MSG_LEN); memset (fmsg.msg, 'a', BIG_MSG_LEN - 1); fmsg.msg[BIG_MSG_LEN - 1] = '\0'; result_file = open_tmp_file(&result_file_name); -- 2.40.0