diff --git a/commandline.c b/commandline.c index c38a1268..5a55844b 100644 --- a/commandline.c +++ b/commandline.c @@ -211,6 +211,10 @@ int parseCommandLine(int argc, const char *const *args) int i; int ambiguous=0; int cli_call=-1; + + fd_clearstats(); + + IN(); for(i=0;command_line_options[i].function;i++) { int j; @@ -277,6 +281,10 @@ int parseCommandLine(int argc, const char *const *args) int result=command_line_options[cli_call].function(argc, args, &command_line_options[cli_call]); /* clean up after ourselves */ overlay_mdp_client_done(); + OUT(); + //TODO debug flag for method profiling + if (1) + fd_showstats(); return result; } diff --git a/keyring.c b/keyring.c index e9afa5d3..e3d1f83f 100644 --- a/keyring.c +++ b/keyring.c @@ -739,7 +739,8 @@ int keyring_decrypt_pkr(keyring_file *k,keyring_context *c, We might find more than one. */ int keyring_enter_pin(keyring_file *k, const char *pin) { - if (!k) return -1; + IN(); + if (!k) RETURN(-1); if (!pin) pin=""; int slot; @@ -777,7 +778,7 @@ int keyring_enter_pin(keyring_file *k, const char *pin) } /* Tell the caller how many identities we found */ - return identitiesFound; + RETURN(identitiesFound); } @@ -1385,15 +1386,16 @@ int keyring_enter_pins(keyring_file *k, const char *pinlist) keyring_file *keyring_open_with_pins(const char *pinlist) { keyring_file *k = NULL; + IN(); if (create_serval_instance_dir() == -1) - return NULL; + RETURN(NULL); char keyringFile[1024]; if (!FORM_SERVAL_INSTANCE_PATH(keyringFile, "serval.keyring")) - return NULL; + RETURN(NULL); if ((k = keyring_open(keyringFile)) == NULL) - return NULL; + RETURN(NULL); keyring_enter_pins(k,pinlist); - return k; + RETURN(k); } /* If no identities, create an initial identity with a phone number. diff --git a/overlay_mdp.c b/overlay_mdp.c index 7b6c46b0..65947b5b 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -1253,6 +1253,8 @@ int overlay_mdp_client_done() int overlay_mdp_client_poll(long long timeout_ms) { fd_set r; + int ret; + IN(); FD_ZERO(&r); FD_SET(mdp_client_socket,&r); if (timeout_ms<0) timeout_ms=0; @@ -1262,10 +1264,11 @@ int overlay_mdp_client_poll(long long timeout_ms) if (timeout_ms>=0) { tv.tv_sec=timeout_ms/1000; tv.tv_usec=(timeout_ms%1000)*1000; - return select(mdp_client_socket+1,&r,NULL,&r,&tv); + ret=select(mdp_client_socket+1,&r,NULL,&r,&tv); } else - return select(mdp_client_socket+1,&r,NULL,&r,NULL); + ret=select(mdp_client_socket+1,&r,NULL,&r,NULL); + RETURN(ret); } int overlay_mdp_recv(overlay_mdp_frame *mdp,int *ttl) diff --git a/rhizome_bundle.c b/rhizome_bundle.c index efe86034..1be341b0 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -84,8 +84,9 @@ int rhizome_manifest_verify(rhizome_manifest *m) int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bufferP) { - if (bufferP>MAX_MANIFEST_BYTES) return WHY("Buffer too big"); - if (!m) return WHY("Null manifest"); + IN(); + if (bufferP>MAX_MANIFEST_BYTES) RETURN(WHY("Buffer too big")); + if (!m) RETURN(WHY("Null manifest")); if (bufferP) { m->manifest_bytes=bufferP; @@ -93,7 +94,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu } else { FILE *f = fopen(filename, "r"); if (f == NULL) - return WHYF("Could not open manifest file %s for reading.", filename); + RETURN(WHYF("Could not open manifest file %s for reading.", filename)); m->manifest_bytes = fread(m->manifestdata, 1, MAX_MANIFEST_BYTES, f); int ret = 0; if (m->manifest_bytes == -1) @@ -101,7 +102,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu if (fclose(f) == EOF) ret = WHY_perror("fclose"); if (ret == -1) - return -1; + RETURN(-1); } m->manifest_all_bytes=m->manifest_bytes; @@ -175,7 +176,7 @@ int rhizome_read_manifest_file(rhizome_manifest *m, const char *filename, int bu m->manifest_bytes=end_of_text; - return 0; + RETURN(0); } int rhizome_hash_file(rhizome_manifest *m,const char *filename,char *hash_out) diff --git a/rhizome_database.c b/rhizome_database.c index 777b65a2..4e170e66 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -658,6 +658,7 @@ int rhizome_finish_sqlstatement(sqlite3_stmt *statement) int rhizome_list_manifests(const char *service, const char *sender_sid, const char *recipient_sid, int limit, int offset) { + IN(); strbuf b = strbuf_alloca(1024); strbuf_sprintf(b, "SELECT id, manifest, version, inserttime FROM manifests ORDER BY inserttime DESC"); if (limit) @@ -665,7 +666,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch if (offset) strbuf_sprintf(b, " OFFSET %u", offset); if (strbuf_overrun(b)) - return WHYF("SQL command too long: ", strbuf_str(b)); + RETURN(WHYF("SQL command too long: ", strbuf_str(b))); sqlite3_stmt *statement; const char *cmdtail; int ret = 0; @@ -751,7 +752,7 @@ int rhizome_list_manifests(const char *service, const char *sender_sid, const ch } } sqlite3_finalize(statement); - return ret; + RETURN(ret); } /* The following function just stores the file (or silently returns if it already exists).