From 881576212cc454a24da022ce9818237922856f52 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Thu, 10 May 2012 14:07:11 +0930 Subject: [PATCH] Fix all trivial compiler warnings --- audio_msm_g1.c | 1 + batman.c | 4 +++- commandline.c | 2 ++ dna.c | 6 +++--- gateway.c | 3 ++- lsif.c | 4 +--- monitor.c | 16 ++++++++++++---- overlay.c | 10 +++++----- overlay_buffer.c | 10 +++++----- overlay_interface.c | 1 + overlay_mdp.c | 2 +- overlay_packetformats.c | 1 - packetformats.c | 4 ++-- rhizome_database.c | 6 +++--- serval.h | 8 ++++++++ server.c | 4 +--- sqlite-amalgamation-3070900/encode.c | 1 + vomp.c | 1 + 18 files changed, 52 insertions(+), 32 deletions(-) diff --git a/audio_msm_g1.c b/audio_msm_g1.c index aef74069..a58ca2c7 100644 --- a/audio_msm_g1.c +++ b/audio_msm_g1.c @@ -368,6 +368,7 @@ int audio_msm_g1_stop() { audio_msm_g1_stop_play(); audio_msm_g1_stop_record(); + return 0; } int audio_msm_g1_start() diff --git a/batman.c b/batman.c index 34dc284b..f767be7a 100644 --- a/batman.c +++ b/batman.c @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "serval.h" struct reachable_peer { @@ -170,7 +171,8 @@ int readBatmanPeerFile(char *file_path,struct in_addr peers[],int *peer_count,in { struct in_addr i; if (!p.addr_len) break; - i.s_addr=*(unsigned int *)&p.addr[0]; + union { char c[4]; uint32_t ui32; } *u = (void*)&p.addr[0]; + i.s_addr = u->ui32; if (*peer_count +#include +#include #include #include #include diff --git a/dna.c b/dna.c index 9262bfa9..9501388f 100644 --- a/dna.c +++ b/dna.c @@ -347,7 +347,7 @@ int setVerbosity(const char *optarg) { int main(int argc, char **argv) { int c; - char *pin=NULL; + //char *pin=NULL; char *did=NULL; char *sid=NULL; char *keyring_file=NULL; @@ -362,7 +362,7 @@ int main(int argc, char **argv) memabuseInit(); srandomdev(); - server_save_argv(argc, argv); + server_save_argv(argc, (const char*const*)argv); if (argv[1]&&argv[1][0]!='-') { /* First argument doesn't start with a dash, so assume it is for the new command line @@ -451,7 +451,7 @@ int main(int argc, char **argv) if (additionalPeer(optarg)) exit(-3); break; case 'P': /* Supply pin */ - pin=strdup(optarg); + //pin=strdup(optarg); clientMode=1; break; case 'd': /* Ask by DID */ diff --git a/gateway.c b/gateway.c index b23cc2dd..eb23fcec 100644 --- a/gateway.c +++ b/gateway.c @@ -17,9 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "serval.h" +#include #include #include +#include "serval.h" char *asterisk_extensions_conf="/data/data/org.servalproject/asterisk/etc/asterisk/gatewayextensions.conf"; char *asterisk_binary="/data/data/org.servalproject/asterisk/sbin/asterisk"; diff --git a/lsif.c b/lsif.c index 77346202..c8f9aaa4 100644 --- a/lsif.c +++ b/lsif.c @@ -59,9 +59,7 @@ #define SIOCGIFBRDADDR OSIOCGIFBRDADDR #endif -int overlay_interface_register(unsigned char *name, - struct sockaddr_in local, - struct sockaddr_in broadcast); +#include "serval.h" /* for when all other options fail, as can happen on Android, if the permissions for the socket-based method are broken. diff --git a/monitor.c b/monitor.c index 9c93cb67..36759615 100644 --- a/monitor.c +++ b/monitor.c @@ -89,6 +89,7 @@ int monitor_setup_sockets() int dud=0; int r=bind(monitor_named_socket, (struct sockaddr *)&name, len); if (r) { dud=1; r=0; WHY_perror("bind"); } + DEBUG("listen"); //XXX r=listen(monitor_named_socket,MAX_MONITOR_SOCKETS); if (r) { dud=1; r=0; WHY_perror("listen"); } @@ -182,13 +183,16 @@ int monitor_poll() /* Check for new connections */ fcntl(monitor_named_socket,F_SETFL, fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK); - while(( + while ( #ifdef HAVE_LINUX_IF_H - s=accept4(monitor_named_socket,ignored_address,&ignored_length,O_NONBLOCK) + (DEBUG("accept4"), 1) && //XXX + (s = accept4(monitor_named_socket,ignored_address,&ignored_length,O_NONBLOCK)) #else - s=accept(monitor_named_socket,&ignored_address,&ignored_length) + (DEBUG("accept"), 1) && //XXX + (s = accept(monitor_named_socket,&ignored_address,&ignored_length)) #endif -)>-1) { + != -1 + ) { WHYF("ignored_length=%d",ignored_length); int res = fcntl(s,F_SETFL, O_NONBLOCK); if (res) { close(s); continue; } @@ -226,6 +230,7 @@ int monitor_poll() fcntl(monitor_named_socket,F_SETFL, fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK); } + DEBUG_perror("accept"); //XXX /* Read from any open connections */ int i; @@ -248,8 +253,10 @@ int monitor_poll() break; } errno=0; + DEBUG("read"); //XXX bytes=read(c->socket,&c->line[c->line_length],1); if (bytes<1) { + DEBUG_perror("read"); //XXX switch(errno) { case EAGAIN: case EINTR: case ENOTRECOVERABLE: /* transient errors */ @@ -285,6 +292,7 @@ int monitor_poll() break; case MONITOR_STATE_DATA: errno=0; + DEBUG("read"); //XXX bytes=read(c->socket, &c->buffer[c->data_offset], c->data_expected-c->data_offset); diff --git a/overlay.c b/overlay.c index 1ae05cc4..489be970 100644 --- a/overlay.c +++ b/overlay.c @@ -78,8 +78,6 @@ keyring_file *keyring=NULL; int overlayServerMode() { - long long server_pid_time_ms = overlay_gettime_ms(); - /* In overlay mode we need to listen to all of our sockets, and also to send periodic traffic. This means we need to */ fprintf(stderr,"Running in overlay mode.\n"); @@ -128,7 +126,7 @@ int overlayServerMode() /* Work out how long we can wait before we need to tick */ long long ms=overlay_time_until_next_tick(); memabuseCheck(); - int filesPresent=0; + //int filesPresent=0; fds[0].fd=sock; fds[0].events=POLLIN; fdcount=1; rhizome_server_get_fds(fds,&fdcount,128); @@ -156,8 +154,10 @@ int overlayServerMode() fds[fdcount].revents=0; fdcount++; } - if (overlay_interfaces[i].fileP) - { filesPresent=1; if (ms>5) ms=5; } + if (overlay_interfaces[i].fileP) { + //filesPresent=1; + if (ms>5) ms=5; + } } /* Progressively update link scores to neighbours etc, and find out how long before diff --git a/overlay_buffer.c b/overlay_buffer.c index 7c9922dd..ff7c78c4 100644 --- a/overlay_buffer.c +++ b/overlay_buffer.c @@ -203,12 +203,12 @@ unsigned int ob_get_int(overlay_buffer *b,int offset) if ((offset+sizeof(unsigned int))>b->length) return WHY("passed offset too large"); // Some platforms require alignment - if (((unsigned long long)&b->bytes[offset])&3) { - unsigned char bb[4]; - bcopy(&b->bytes[offset],&bb[0],4); - return ntohl(*(unsigned int *)&bb[0]); + if (((uintptr_t)&b->bytes[offset])&3) { + union { unsigned char uc[4]; uint32_t ui32; } bb; + bcopy(&b->bytes[offset], &bb.uc[0], 4); + return ntohl(bb.ui32); } else - return ntohl(*((unsigned int *)&b->bytes[offset])); + return ntohl(*((uint32_t*)&b->bytes[offset])); } int ob_append_rfs(overlay_buffer *b,int l) diff --git a/overlay_interface.c b/overlay_interface.c index 5c4fdbba..576a50bb 100644 --- a/overlay_interface.c +++ b/overlay_interface.c @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "serval.h" #ifdef HAVE_IFADDRS_H diff --git a/overlay_mdp.c b/overlay_mdp.c index a99204fc..fda3d43a 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -296,7 +296,7 @@ int overlay_saw_mdp_containing_frame(int interface,overlay_frame *f,long long no bcopy(&f->source[0],&mdp.in.src.sid[0],SID_SIZE); int len=f->payload->length; - unsigned char *b; + unsigned char *b = NULL; unsigned char plain_block[len+16]; if (len<10) return WHY("Invalid MDP frame"); diff --git a/overlay_packetformats.c b/overlay_packetformats.c index 44b189bb..a884755c 100644 --- a/overlay_packetformats.c +++ b/overlay_packetformats.c @@ -262,7 +262,6 @@ int overlay_add_selfannouncement(int interface,overlay_buffer *b) unsigned char c; unsigned char *sid=overlay_get_my_sid(); - unsigned long long now=overlay_gettime_ms(); /* Header byte */ c=OF_TYPE_SELFANNOUNCE; diff --git a/packetformats.c b/packetformats.c index e2f1f5c2..4140b119 100644 --- a/packetformats.c +++ b/packetformats.c @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. int process_packet(unsigned char *packet,int len, int recvttl,struct sockaddr *sender,int sender_len) { - int authenticatedP=0; + //int authenticatedP=0; char did[128]; char sid[128]; unsigned char *transaction_id=&packet[OFS_TRANSIDFIELD]; @@ -49,7 +49,7 @@ int process_packet(unsigned char *packet,int len, else { /* No attempt at authentication was made */ - authenticatedP=0; + //authenticatedP=0; if (debug&DEBUG_SECURITY) fprintf(stderr,"No PIN was supplied.\n"); } diff --git a/rhizome_database.c b/rhizome_database.c index 06f17c8a..577da2b2 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -186,14 +186,14 @@ int rhizome_make_space(int group_priority, long long bytes) { /* Make sure we can drop this blob, and if so drop it, and recalculate number of bytes required */ const unsigned char *id; - long long length; + //long long length; /* Get values */ if (sqlite3_column_type(statement, 0)==SQLITE_TEXT) id=sqlite3_column_text(statement, 0); else { fprintf(stderr,"Incorrect type in id column of files table.\n"); continue; } - if (sqlite3_column_type(statement, 1)==SQLITE_INTEGER) length=sqlite3_column_int(statement, 1); + if (sqlite3_column_type(statement, 1)==SQLITE_INTEGER) ;//length=sqlite3_column_int(statement, 1); else { fprintf(stderr,"Incorrect type in length column of files table.\n"); continue; } @@ -205,7 +205,7 @@ int rhizome_make_space(int group_priority, long long bytes) } sqlite3_finalize(statement); - long long equal_priority_larger_file_space_used = sqlite_exec_int64("SELECT COUNT(length) FROM FILES WHERE highestpriority=%d and length>%lld",group_priority,bytes); + //long long equal_priority_larger_file_space_used = sqlite_exec_int64("SELECT COUNT(length) FROM FILES WHERE highestpriority=%d and length>%lld",group_priority,bytes); /* XXX Get rid of any equal priority files that are larger than this one */ /* XXX Get rid of any higher priority files that are not relevant in this time or location */ diff --git a/serval.h b/serval.h index 96a73596..e6e6661b 100755 --- a/serval.h +++ b/serval.h @@ -1403,6 +1403,13 @@ int overlay_mdp_getmyaddr(int index,unsigned char *sid); int overlay_mdp_bind(unsigned char *localaddr,int port); int overlay_route_node_info(overlay_mdp_frame *mdp, struct sockaddr_un *addr,int addrlen); +int overlay_interface_register(unsigned char *name, + struct sockaddr_in local, + struct sockaddr_in broadcast); +int overlay_queue_dump(overlay_txqueue *q); +int overlay_broadcast_ensemble(int interface_number, + struct sockaddr_in *recipientaddr /* NULL == broadcast */, + unsigned char *bytes,int len); int app_vomp_status(int argc, const char *const *argv, struct command_line_option *o); int app_vomp_dial(int argc, const char *const *argv, struct command_line_option *o); @@ -1446,3 +1453,4 @@ int encodeAndDispatchRecordedAudio(int fd,int callSessionToken, int recordCodec, unsigned char *sampleData, int sampleBytes); +int scrapeProcNetRoute(); diff --git a/server.c b/server.c index 0df050f4..ae5f336c 100644 --- a/server.c +++ b/server.c @@ -448,7 +448,6 @@ int processRequest(unsigned char *packet,int len, unsigned char *transaction_id,int recvttl, char *did,char *sid) { /* Find HLR entry by DID or SID, unless creating */ - int ofs; int records_searched=0; int prev_pofs=0; @@ -510,7 +509,7 @@ int processRequest(unsigned char *packet,int len, if (instrumentation_file) { if (!i_f) { if (strcmp(instrumentation_file,"-")) i_f=fopen(instrumentation_file,"a"); else i_f=stdout; } - if (i_f) fprintf(i_f,"%ld:%08x:%d:%d\n",time(0),*(unsigned int *)&sender->sa_data[0],field,value); + if (i_f) fprintf(i_f,"%ld:%02x%02x%02x%02x:%d:%d\n",time(0),sender->sa_data[0],sender->sa_data[1],sender->sa_data[2],sender->sa_data[3],field,value); if (i_f) fflush(i_f); } } @@ -545,7 +544,6 @@ int processRequest(unsigned char *packet,int len, if (debug&DEBUG_DNAREQUESTS) fprintf(stderr,"Processing ACTION_GET (var_id=%02x, instance=%02x, pofs=0x%x, len=%d)\n",var_id,instance,pofs,len); - ofs=0; if (debug&DEBUG_HLR) fprintf(stderr,"Looking for identities with sid='%s' / did='%s'\n",(sid&&sid[0])?sid:"null",did?did:"null"); /* Keyring only has DIDs in it for now. diff --git a/sqlite-amalgamation-3070900/encode.c b/sqlite-amalgamation-3070900/encode.c index 6c643329..07aa091d 100644 --- a/sqlite-amalgamation-3070900/encode.c +++ b/sqlite-amalgamation-3070900/encode.c @@ -134,6 +134,7 @@ int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out){ memset(cnt, 0, sizeof(cnt)); for(i=n-1; i>=0; i--){ cnt[in[i]]++; } m = n; + e = 0; for(i=1; i<256; i++){ int sum; if( i=='\'' ) continue; diff --git a/vomp.c b/vomp.c index 326efbf2..0877d208 100644 --- a/vomp.c +++ b/vomp.c @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. int vomp_call_count=0; int vomp_active_call=-1; vomp_call_state vomp_call_states[VOMP_MAX_CALLS]; +int dump_vomp_status(); /* which codecs we support (set by registered listener) */ unsigned char vomp_local_codec_list[256];