diff --git a/benchmarks/lhtableThreaded.c b/benchmarks/lhtableThreaded.c index 4c926c0..d7548f6 100644 --- a/benchmarks/lhtableThreaded.c +++ b/benchmarks/lhtableThreaded.c @@ -5,6 +5,7 @@ #include #include #include +#include int entries; int thread_count; @@ -17,7 +18,8 @@ struct LH_ENTRY(table) * t; char * itoa(int i) { char * ret; - asprintf(&ret, "%d", i); + int err = asprintf(&ret, "%d", i); + assert(err != -1); return ret; } diff --git a/benchmarks/roseTableTpcCH.h b/benchmarks/roseTableTpcCH.h index 635af48..8527738 100644 --- a/benchmarks/roseTableTpcCH.h +++ b/benchmarks/roseTableTpcCH.h @@ -81,7 +81,8 @@ namespace rose { // int column[] = { 3 , 4, 1, 11, 0, 5, 6, 9, 10, 14 }; // const int column[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - const int column[] = {2, 7, 5, 6, 0, 3, 10}; + const int column[] = {2, 7, 5, 6, 0, 3, 10, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static long COUNT = INSERTS / 100; long int count = COUNT; diff --git a/benchmarks/transitiveClosure.c b/benchmarks/transitiveClosure.c index 2eaf6b1..50f3442 100644 --- a/benchmarks/transitiveClosure.c +++ b/benchmarks/transitiveClosure.c @@ -222,7 +222,8 @@ int main(int argc, char ** argv) { if(!silent) { printf("Nodes loaded.\n"); fflush(stdout); - system("date"); + int err = system("date"); + (void)err; } rid.slot = 0; @@ -239,8 +240,9 @@ int main(int argc, char ** argv) { } if(!silent) { - system("date"); - + int err = system("date"); + (void)err; + printf("TransClos returned Tset called %d times\n", numTset); fflush(stdout); } @@ -284,7 +286,8 @@ int main(int argc, char ** argv) { } if(!silent) { - system("date"); + int err = system("date"); + (void)err; printf("FastTransClos returned Tset called %d times, shortcutted %d, skipped %d pushed %d\n", numTset, numShortcutted, numSkipped, numPushed); } } diff --git a/src/apps/referential/dml.c b/src/apps/referential/dml.c index 423d8b8..ff05de9 100644 --- a/src/apps/referential/dml.c +++ b/src/apps/referential/dml.c @@ -69,7 +69,8 @@ int executeDelete(int xid, recordid tables, char * delete) { static recordid ReferentialDML_lookupTableRid(int xid, ReferentialAlgebra_context_t*context, char * tablename) { expr_list * results = 0; char * line; - asprintf(&line, "query {p ($1,$2,$3) {s ($0=\"%s\") TABLES} }", tablename); + int err = asprintf(&line, "query {p ($1,$2,$3) {s ($0=\"%s\") TABLES} }", tablename); + assert(err != -1); //XXX memory leak! parse(line,&results); diff --git a/src/apps/referential/lang/ast.c b/src/apps/referential/lang/ast.c index 6decc44..910c7fb 100644 --- a/src/apps/referential/lang/ast.c +++ b/src/apps/referential/lang/ast.c @@ -129,19 +129,27 @@ char * pp_create(const create * c){ } char * pp_q_scan(const q_scan* s) { char * ret = 0; - asprintf(&ret, "%s", s->table); - return ret; + if(-1 == asprintf(&ret, "%s", s->table)) + return 0; + else + return ret; } char * pp_insert(const insert * i) { char * ret = 0; - asprintf(&ret, "%s ", i->tbl); - ret = afstrncat(ret, pp_val_tuple(i->t)); - return ret; + if(-1 == asprintf(&ret, "%s ", i->tbl)) { + return 0; + } else { + ret = afstrncat(ret, pp_val_tuple(i->t)); + return ret; + } } char * pp_delete(const delete * d) { char * ret = 0; - asprintf(&ret, "%s ", d->tbl); - ret = afstrncat(ret, pp_val_tuple(d->t)); + if(-1 == asprintf(&ret, "%s ", d->tbl)) { + return 0; + } else { + ret = afstrncat(ret, pp_val_tuple(d->t)); + } return ret; } /*char * pp_pat_tuple(const pat_tuple * p) { @@ -285,35 +293,43 @@ char * pp_union_cmp(const union_cmp * p) { } */ char * pp_val_entry(const val_entry * p) { char * ret = 0; + int err; switch(p->typ) { case ident_typ: { - asprintf(&ret,"%s",p->u.ident); + err = asprintf(&ret,"%s",p->u.ident); } break; case int64_typ: { - asprintf(&ret,"%lld",(long long int)p->u.integ); + err = asprintf(&ret,"%lld",(long long int)p->u.integ); } break; case string_typ: { - asprintf(&ret,"\"%s\"",p->u.str); + err = asprintf(&ret,"\"%s\"",p->u.str); } break; default: abort(); } - return ret; + if(err == -1) + return 0; + else + return ret; } char * pp_col_entry(const col_entry * p) { char * ret = 0; + int err; switch(p->typ) { case colint_typ: { - asprintf(&ret,"$%d",p->u.colnum); + err = asprintf(&ret,"$%d",p->u.colnum); } break; case colstr_typ: { - asprintf(&ret,"$%s",p->u.colstr); + err = asprintf(&ret,"$%s",p->u.colstr); } break; case string_typ: { - asprintf(&ret,"%s",p->u.colstr); + err = asprintf(&ret,"%s",p->u.colstr); } break; default: abort(); } - return ret; + if(err == -1) + return 0; + else + return ret; } char * pp_cmp_entry(const cmp_entry * p) { char * ret = 0; diff --git a/src/apps/referential/tuple.c b/src/apps/referential/tuple.c index e2b4932..ae3b7c2 100644 --- a/src/apps/referential/tuple.c +++ b/src/apps/referential/tuple.c @@ -184,7 +184,8 @@ char * stringTuple(tuple_t t) { if(i) { ret = astrncat(ret, ","); } if(t.type[i] == int64_typ) { char * tok; - asprintf(&tok,"%lld",(long long)t.col[i].int64); + int err = asprintf(&tok,"%lld",(long long)t.col[i].int64); + assert(err != -1); ret = afstrncat(ret,tok); } else if(t.type[i] == string_typ) { ret = astrncat(ret,t.col[i].string); diff --git a/src/libdfa/libdfa.c b/src/libdfa/libdfa.c index 1ccdf95..08b6bbc 100644 --- a/src/libdfa/libdfa.c +++ b/src/libdfa/libdfa.c @@ -553,7 +553,10 @@ void * request(DfaSet * dfaSet, state_name start_state, char * recipient_addr, s initial_sm->message.type = start_state; char * initiator; - asprintf(&initiator, "%s:%d", dfaSet->networkSetup.localhost, dfaSet->networkSetup.localport); + { + int err = asprintf(&initiator, "%s:%d", dfaSet->networkSetup.localhost, dfaSet->networkSetup.localport); + assert(err != -1); + } strcpy(initial_sm->message.initiator, initiator); free(initiator); // printf("Set message initiator to %s\n", initial_sm->message.initiator); fflush(stdout); diff --git a/src/libdfa/messages.c b/src/libdfa/messages.c index 1fc3d47..b2b1e75 100644 --- a/src/libdfa/messages.c +++ b/src/libdfa/messages.c @@ -184,7 +184,10 @@ int __send_message(const NetworkSetup *ns, Message *message, const char *to) { // fprintf(stderr, "Broadcasting to all groups (except group 0).\n"); for(int i = 1; i < ns->broadcast_lists_count+1; i++) { char * new_to; - asprintf(&new_to, "bc:%d", i); + { + int err = asprintf(&new_to, "bc:%d", i); + assert(err != -1); + } int ret = __send_message(ns, message, new_to); free(new_to); if(ret < 0) { diff --git a/test/stasis/check_lhtable.c b/test/stasis/check_lhtable.c index 026d646..39e033d 100644 --- a/test/stasis/check_lhtable.c +++ b/test/stasis/check_lhtable.c @@ -85,8 +85,9 @@ START_TEST(lhtableTest) for(long i = 0; i < NUM_ENTRIES; i+=2) { char * key; - asprintf(&key, "--> %ld <--\n", i); - + if(-1 == asprintf(&key, "--> %ld <--\n", i)) + key = 0; + assert(i == (long)LH_ENTRY(find)(t, key, strlen(key))); LH_ENTRY(remove)(t, keys[i], strlen(keys[i])); assert(!LH_ENTRY(find)(t, keys[i], strlen(keys[i]))); @@ -120,7 +121,7 @@ int64_t myrandom(int64_t x) { #endif char * itoa(int i) { char * ret; - asprintf(&ret, "%d", i); + if(-1 == asprintf(&ret, "%d", i)) ret = 0; return ret; } diff --git a/utilities/logfile_dump.c b/utilities/logfile_dump.c index 7bca506..6762220 100644 --- a/utilities/logfile_dump.c +++ b/utilities/logfile_dump.c @@ -8,51 +8,51 @@ static char * logEntryToString(const LogEntry * le) { char * ret = NULL; - + int err; switch(le->type) { case UPDATELOG: { - asprintf(&ret, "UPDATE\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\tpage={%8lld}\tfuncId=%3d\targSize=%9lld\n", le->LSN, le->prevLSN, le->xid, + err = asprintf(&ret, "UPDATE\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\tpage={%8lld}\tfuncId=%3d\targSize=%9lld\n", le->LSN, le->prevLSN, le->xid, le->update.page, le->update.funcID, (long long)le->update.arg_size ); - } break; case XBEGIN: { - asprintf(&ret, "BEGIN\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); + err = asprintf(&ret, "BEGIN\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); } break; case XCOMMIT: { - asprintf(&ret, "COMMIT\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); + err = asprintf(&ret, "COMMIT\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); } break; case XABORT: { - asprintf(&ret, "ABORT\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); + err = asprintf(&ret, "ABORT\tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); } break; case XPREPARE: { - asprintf(&ret, "PREPARE\tlsn=%9lld\tprevlsn=%9lld\txid=%4d,reclsn=%9lld\n", le->LSN, le->prevLSN, le->xid, getPrepareRecLSN(le)); + err = asprintf(&ret, "PREPARE\tlsn=%9lld\tprevlsn=%9lld\txid=%4d,reclsn=%9lld\n", le->LSN, le->prevLSN, le->xid, getPrepareRecLSN(le)); } break; case XEND: { - asprintf(&ret, "END \tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); + err = asprintf(&ret, "END \tlsn=%9lld\tprevlsn=%9lld\txid=%4d\n", le->LSN, le->prevLSN, le->xid); } break; case CLRLOG: { - asprintf(&ret, "CLR \tlsn=%9lld\tprevlsn=%9lld\txid=%4d\tcompensates={%8lld}\n", le->LSN, le->prevLSN, le->xid, + err = asprintf(&ret, "CLR \tlsn=%9lld\tprevlsn=%9lld\txid=%4d\tcompensates={%8lld}\n", le->LSN, le->prevLSN, le->xid, ((CLRLogEntry*)le)->clr.compensated_lsn); } break; } + assert(err != -1); return ret; }