fix new gcc compiler warnings

This commit is contained in:
Sears Russell 2008-11-11 01:15:25 +00:00
parent 8b0251ae4b
commit 484cd7fd38
10 changed files with 68 additions and 37 deletions

View file

@ -5,6 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include <stasis/lhtable.h> #include <stasis/lhtable.h>
#include <assert.h>
int entries; int entries;
int thread_count; int thread_count;
@ -17,7 +18,8 @@ struct LH_ENTRY(table) * t;
char * itoa(int i) { char * itoa(int i) {
char * ret; char * ret;
asprintf(&ret, "%d", i); int err = asprintf(&ret, "%d", i);
assert(err != -1);
return ret; return ret;
} }

View file

@ -81,7 +81,8 @@ namespace rose {
// int column[] = { 3 , 4, 1, 11, 0, 5, 6, 9, 10, 14 }; // 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[] = { 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; static long COUNT = INSERTS / 100;
long int count = COUNT; long int count = COUNT;

View file

@ -222,7 +222,8 @@ int main(int argc, char ** argv) {
if(!silent) { if(!silent) {
printf("Nodes loaded.\n"); printf("Nodes loaded.\n");
fflush(stdout); fflush(stdout);
system("date"); int err = system("date");
(void)err;
} }
rid.slot = 0; rid.slot = 0;
@ -239,7 +240,8 @@ int main(int argc, char ** argv) {
} }
if(!silent) { if(!silent) {
system("date"); int err = system("date");
(void)err;
printf("TransClos returned Tset called %d times\n", numTset); printf("TransClos returned Tset called %d times\n", numTset);
fflush(stdout); fflush(stdout);
@ -284,7 +286,8 @@ int main(int argc, char ** argv) {
} }
if(!silent) { 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); printf("FastTransClos returned Tset called %d times, shortcutted %d, skipped %d pushed %d\n", numTset, numShortcutted, numSkipped, numPushed);
} }
} }

View file

@ -69,7 +69,8 @@ int executeDelete(int xid, recordid tables, char * delete) {
static recordid ReferentialDML_lookupTableRid(int xid, ReferentialAlgebra_context_t*context, char * tablename) { static recordid ReferentialDML_lookupTableRid(int xid, ReferentialAlgebra_context_t*context, char * tablename) {
expr_list * results = 0; expr_list * results = 0;
char * line; 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! //XXX memory leak!
parse(line,&results); parse(line,&results);

View file

@ -129,19 +129,27 @@ char * pp_create(const create * c){
} }
char * pp_q_scan(const q_scan* s) { char * pp_q_scan(const q_scan* s) {
char * ret = 0; char * ret = 0;
asprintf(&ret, "%s", s->table); if(-1 == asprintf(&ret, "%s", s->table))
return ret; return 0;
else
return ret;
} }
char * pp_insert(const insert * i) { char * pp_insert(const insert * i) {
char * ret = 0; char * ret = 0;
asprintf(&ret, "%s ", i->tbl); if(-1 == asprintf(&ret, "%s ", i->tbl)) {
ret = afstrncat(ret, pp_val_tuple(i->t)); return 0;
return ret; } else {
ret = afstrncat(ret, pp_val_tuple(i->t));
return ret;
}
} }
char * pp_delete(const delete * d) { char * pp_delete(const delete * d) {
char * ret = 0; char * ret = 0;
asprintf(&ret, "%s ", d->tbl); if(-1 == asprintf(&ret, "%s ", d->tbl)) {
ret = afstrncat(ret, pp_val_tuple(d->t)); return 0;
} else {
ret = afstrncat(ret, pp_val_tuple(d->t));
}
return ret; return ret;
} }
/*char * pp_pat_tuple(const pat_tuple * p) { /*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 * pp_val_entry(const val_entry * p) {
char * ret = 0; char * ret = 0;
int err;
switch(p->typ) { switch(p->typ) {
case ident_typ: { case ident_typ: {
asprintf(&ret,"%s",p->u.ident); err = asprintf(&ret,"%s",p->u.ident);
} break; } break;
case int64_typ: { case int64_typ: {
asprintf(&ret,"%lld",(long long int)p->u.integ); err = asprintf(&ret,"%lld",(long long int)p->u.integ);
} break; } break;
case string_typ: { case string_typ: {
asprintf(&ret,"\"%s\"",p->u.str); err = asprintf(&ret,"\"%s\"",p->u.str);
} break; } break;
default: abort(); default: abort();
} }
return ret; if(err == -1)
return 0;
else
return ret;
} }
char * pp_col_entry(const col_entry * p) { char * pp_col_entry(const col_entry * p) {
char * ret = 0; char * ret = 0;
int err;
switch(p->typ) { switch(p->typ) {
case colint_typ: { case colint_typ: {
asprintf(&ret,"$%d",p->u.colnum); err = asprintf(&ret,"$%d",p->u.colnum);
} break; } break;
case colstr_typ: { case colstr_typ: {
asprintf(&ret,"$%s",p->u.colstr); err = asprintf(&ret,"$%s",p->u.colstr);
} break; } break;
case string_typ: { case string_typ: {
asprintf(&ret,"%s",p->u.colstr); err = asprintf(&ret,"%s",p->u.colstr);
} break; } break;
default: abort(); default: abort();
} }
return ret; if(err == -1)
return 0;
else
return ret;
} }
char * pp_cmp_entry(const cmp_entry * p) { char * pp_cmp_entry(const cmp_entry * p) {
char * ret = 0; char * ret = 0;

View file

@ -184,7 +184,8 @@ char * stringTuple(tuple_t t) {
if(i) { ret = astrncat(ret, ","); } if(i) { ret = astrncat(ret, ","); }
if(t.type[i] == int64_typ) { if(t.type[i] == int64_typ) {
char * tok; 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); ret = afstrncat(ret,tok);
} else if(t.type[i] == string_typ) { } else if(t.type[i] == string_typ) {
ret = astrncat(ret,t.col[i].string); ret = astrncat(ret,t.col[i].string);

View file

@ -553,7 +553,10 @@ void * request(DfaSet * dfaSet, state_name start_state, char * recipient_addr, s
initial_sm->message.type = start_state; initial_sm->message.type = start_state;
char * initiator; 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); strcpy(initial_sm->message.initiator, initiator);
free(initiator); free(initiator);
// printf("Set message initiator to %s\n", initial_sm->message.initiator); fflush(stdout); // printf("Set message initiator to %s\n", initial_sm->message.initiator); fflush(stdout);

View file

@ -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"); // fprintf(stderr, "Broadcasting to all groups (except group 0).\n");
for(int i = 1; i < ns->broadcast_lists_count+1; i++) { for(int i = 1; i < ns->broadcast_lists_count+1; i++) {
char * new_to; 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); int ret = __send_message(ns, message, new_to);
free(new_to); free(new_to);
if(ret < 0) { if(ret < 0) {

View file

@ -85,7 +85,8 @@ START_TEST(lhtableTest)
for(long i = 0; i < NUM_ENTRIES; i+=2) { for(long i = 0; i < NUM_ENTRIES; i+=2) {
char * key; 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))); assert(i == (long)LH_ENTRY(find)(t, key, strlen(key)));
LH_ENTRY(remove)(t, keys[i], strlen(keys[i])); LH_ENTRY(remove)(t, keys[i], strlen(keys[i]));
@ -120,7 +121,7 @@ int64_t myrandom(int64_t x) {
#endif #endif
char * itoa(int i) { char * itoa(int i) {
char * ret; char * ret;
asprintf(&ret, "%d", i); if(-1 == asprintf(&ret, "%d", i)) ret = 0;
return ret; return ret;
} }

View file

@ -8,51 +8,51 @@
static char * logEntryToString(const LogEntry * le) { static char * logEntryToString(const LogEntry * le) {
char * ret = NULL; char * ret = NULL;
int err;
switch(le->type) { switch(le->type) {
case UPDATELOG: 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 ); le->update.page, le->update.funcID, (long long)le->update.arg_size );
} }
break; break;
case XBEGIN: 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; break;
case XCOMMIT: 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; break;
case XABORT: 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; break;
case XPREPARE: 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; break;
case XEND: 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; break;
case CLRLOG: 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); ((CLRLogEntry*)le)->clr.compensated_lsn);
} }
break; break;
} }
assert(err != -1);
return ret; return ret;
} }