From bd89957287441872706432d1e283091b4e5cdbc8 Mon Sep 17 00:00:00 2001 From: bustico Date: Thu, 20 Jun 2013 08:38:59 +0000 Subject: fix compilation warning --- debian/changelog | 6 ++++++ src/intervalRegexp.c | 41 +++++++++++++++++++---------------------- src/ivy.c | 10 ++++------ tools/ivyperf.c | 6 ------ tools/ivyprobe.c | 31 +++++++++++++++++++++++++++++-- tools/ivytestready.c | 15 ++++++++++++++- tools/ivythroughput.cpp | 40 +++++++++++++++++++++++++++++++++++----- 7 files changed, 107 insertions(+), 42 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5635b88..e6a5634 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ivy-c (3.14.1) unstable; urgency=low + + * fix compilation warning + + -- Alexandre Bustico Thu, 20 June 2013 10:37:00 +0200 + ivy-c (3.14.0) unstable; urgency=low * complete implementation of ping/pong protocol message diff --git a/src/intervalRegexp.c b/src/intervalRegexp.c index f5554a9..fb5e0f6 100644 --- a/src/intervalRegexp.c +++ b/src/intervalRegexp.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "intervalRegexp.h" @@ -42,17 +43,17 @@ const bool success = 1; const bool fail = 0; -static bool strictPosRegexpGen (char *regexp, size_t buflen, long min, long max, const char* decimalPart, - const char* boundDecimalPart); -static bool genAtRank (char *regexp, size_t buflen, const char *min, const char *max, int rank); -static bool genPreRank (char *preRank, size_t buflen, const char *min, const char *max, int rank); -static bool genRank (char *outRank, size_t buflen, const char *min, const char *max, int rank); -static bool genPostRank (char *postRank, size_t buflen, int rank); -static bool substr (char *substring, size_t buflen, const char* expr, size_t pos, size_t len); -static char* reverse (char *string); -static char* longtoa (char *string, size_t buflen, long n); -static NextMax nextMax (const char *min, const char *max); -static bool perr (const char* func, const char *fmt, ...); +static bool strictPosRegexpGen (char *regexp, size_t buflen, long min, long max, + const char* decimalPart, const char* boundDecimalPart); +static bool genAtRank (char *regexp, size_t buflen, const char *min, const char *max, int rank); +static bool genPreRank (char *preRank, size_t buflen, const char *min, const char *max, int rank); +static bool genRank (char *outRank, size_t buflen, const char *min, const char *max, int rank); +static bool genPostRank (char *postRank, size_t buflen, int rank); +static bool substr (char *substring, size_t buflen, const char* expr, size_t pos, size_t len); +static char* reverse (char *string); +static char* longtoa (char *string, size_t buflen, long n); +static NextMax nextMax (const char *min, const char *max); +static bool perr (const char* func, const char *fmt, ...); @@ -139,12 +140,11 @@ static bool strictPosRegexpGen (char *regexp, size_t buflen, long min, long max, #define maxSubReg 64 #define digitRegSize 128 - char regList[maxSubReg][digitRegSize]; - char locBuf[maxSubReg*digitRegSize] ; - size_t regIndex=0,i; - size_t nbRank; - char maxAsString[32], minAsString[32]; - NextMax nMax; + char regList[maxSubReg][digitRegSize]; + char locBuf[maxSubReg*digitRegSize] ; + size_t regIndex = 0,i; + char maxAsString[32], minAsString[32]; + NextMax nMax; if ((min <= 0) || (max <= 0)) return Perr ("min or max <= 0"); @@ -154,7 +154,6 @@ static bool strictPosRegexpGen (char *regexp, size_t buflen, long min, long max, max--; - nbRank = strlen (longtoa (maxAsString, sizeof (maxAsString), max)); do { nMax = nextMax (longtoa (minAsString, sizeof (minAsString), min), longtoa (maxAsString, sizeof (maxAsString), max)); @@ -421,14 +420,12 @@ static char* longtoa (char *string, size_t buflen, long n) */ static bool perr (const char* func, const char *fmt, ...) { - char err[4096], buffer[2048]; + char buffer[2048]; va_list args; va_start( args, fmt ); vsprintf( buffer, fmt, args ); va_end( args ); - - sprintf (err, "Erreur %s @ %s\n", buffer, func); - fprintf (stderr, err); + fprintf (stderr, "Erreur %s @ %s\n", buffer, func); return (fail); } diff --git a/src/ivy.c b/src/ivy.c index 607c679..a855094 100644 --- a/src/ivy.c +++ b/src/ivy.c @@ -673,10 +673,9 @@ static void Receive( Client client, const void *data, char *line ) clnt->readyToSend++; if ( ready_message && clnt->readyToSend == 2 ) { - int count; - count = ClientCall( clnt, ready_message ); + /* int count = */ ClientCall( clnt, ready_message ); // count = IvySendMsg ("%s", ready_message ); - // printf ("%s sending READY MESSAGE %d\n", clnt->app_name, count); + // printf ("%s sending READY MESSAGE %d\n", clnt->app_name, count); } break; case Msg: @@ -780,10 +779,9 @@ static RWIvyClientPtr SendService( Client client, const char *appname ) clnt->readyToSend++; if ( ready_message && clnt->readyToSend == 2 ) { - int count; - count = ClientCall( clnt, ready_message ); + /* int count = */ ClientCall( clnt, ready_message ); // count = IvySendMsg ("%s", ready_message ); - // printf ("%s sending READY MESSAGE %d\n", clnt->app_name, count); + // printf ("%s sending READY MESSAGE %d\n", clnt->app_name, count); } //printf ("DBG> SendService addAllClient: name=%s; client->client=%p\n", appname, clnt->client); diff --git a/tools/ivyperf.c b/tools/ivyperf.c index 8683692..a7845f0 100644 --- a/tools/ivyperf.c +++ b/tools/ivyperf.c @@ -74,17 +74,11 @@ void Pong (IvyClientPtr app, void *user_data, int argc, char *argv[]) { double current; double ts; - double tr; - double roundtrip1; - double roundtrip2; double roundtrip3; nbMsgReceive++; current = currentTime() - origin ; ts = atof( *argv++ ); - tr = atof( *argv++ ); - roundtrip1 = tr-ts; - roundtrip2 = current - tr; roundtrip3 = current - ts; if ( roundtrip3 > maxRoundTrip ) maxRoundTrip = roundtrip3; if ( roundtrip3 < minRoundTrip ) minRoundTrip = roundtrip3; diff --git a/tools/ivyprobe.c b/tools/ivyprobe.c index 5111358..6e5f3e1 100644 --- a/tools/ivyprobe.c +++ b/tools/ivyprobe.c @@ -88,7 +88,6 @@ void DirectCallback(IvyClientPtr app, void *user_data, int id, char *msg ) void PongCallback (IvyClientPtr app, int roundTripOrTimout) { - int i; if (roundTripOrTimout >= 0) { printf ("%s respond to ping in %.3f ms\n", IvyGetApplicationName(app), roundTripOrTimout/1000.0); @@ -172,7 +171,14 @@ void HandleStdin (Channel channel, IVY_HANDLE fd, void *data) printf("Error compiling '%s', %s, not bound\n", arg, errbuf); } else { IvyBindingFree( binding ); - IvyBindMsg (Callback, NULL, arg); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + IvyBindMsg (Callback, NULL, arg); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } } @@ -236,7 +242,14 @@ void HandleStdin (Channel channel, IVY_HANDLE fd, void *data) } } else { cmd = strtok (buf, "\n"); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif err = IvySendMsg (cmd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif printf("-> Sent to %d peer%s\n", err, err == 1 ? "" : "s"); } } @@ -341,7 +354,14 @@ void BindMsgOfFile( const char * regex_file ) if ( size > 1 ) { line[size-1] = '\0'; /* supress \n */ +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif IvyBindMsg (Callback, NULL, line); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } } } @@ -434,7 +454,14 @@ int main(int argc, char *argv[]) for (; optind < argc; optind++) { printf("Binding to '%s'\n", argv[optind] ); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif IvyBindMsg (Callback, NULL, argv[optind]); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } diff --git a/tools/ivytestready.c b/tools/ivytestready.c index 4f839ef..35e0eae 100755 --- a/tools/ivytestready.c +++ b/tools/ivytestready.c @@ -85,6 +85,10 @@ void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyB } } + + + + int main(int argc, char *argv[]) { @@ -98,8 +102,17 @@ int main(int argc, char *argv[]) } IvyInit (me, ready_message, NULL,NULL,NULL,NULL); - IvySetBindCallback( binCB, 0 ), + IvySetBindCallback( binCB, 0 ); + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif IvyBindMsg (Ready, NULL, ready_bind); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + IvyBindMsg (Question, NULL, "^are you there %s",me); IvyBindMsg (Reply, NULL, "^(yes i am %s)",other); diff --git a/tools/ivythroughput.cpp b/tools/ivythroughput.cpp index 7d6136f..e1734d5 100644 --- a/tools/ivythroughput.cpp +++ b/tools/ivythroughput.cpp @@ -261,7 +261,7 @@ void emetteur (const char* bus, KindOfTest kod, int testDuration, // double origin = currentTime(); - IvySetBindCallback (binCB, (void *) (regexpSize+2)); + IvySetBindCallback (binCB, (void *) (regexpSize+2l)); IvyBindMsg (recepteurReadyCB, (void *) &messages, "^IvyThroughputReceive_(\\d+)\\s+Ready"); @@ -281,6 +281,10 @@ void emetteur (const char* bus, KindOfTest kod, int testDuration, # | | | __/ | (__ | __/ | | \ |_ | __/ | |_| | | | # |_| \___| \___| \___| |_| \__| \___| \__,_| |_| */ +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif void recepteur_tp (const char* bus, KindOfTest kod, unsigned int inst, const ListOfString& regexps, unsigned int exitAfter) { @@ -301,7 +305,7 @@ void recepteur_tp (const char* bus, KindOfTest kod, unsigned int inst, debugInt++; string reg = *iter; if (regexpAreUniq) { ((reg += "(") += stream.str()) += ")?";} - IvyBindMsg (recepteurCB, (void *) inst, reg.c_str()); + IvyBindMsg (recepteurCB, (void *) long(inst), reg.c_str()); } IvyBindMsg (startOfSeqCB, NULL, "^start(OfSequence)"); IvyBindMsg (endOfSeqCB, NULL, "^end(OfSequence)"); @@ -309,13 +313,16 @@ void recepteur_tp (const char* bus, KindOfTest kod, unsigned int inst, if (kod == memoryLeak2) { TimerRepeatAfter (1, exitAfter*1000, exitCB, NULL); } else if (kod == disconnect) { - TimerRepeatAfter (1, exitAfter*1000/3, doNothingAndSuicideCB, (void *) exitAfter); + TimerRepeatAfter (1, exitAfter*1000/3, doNothingAndSuicideCB, (void *) long(exitAfter)); } //usleep (inst * 50 * 1000); IvyStart (bus); IvyMainLoop (); } +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif void recepteur_ml (const char* bus, KindOfTest kod, unsigned int inst, const ListOfString& regexps) @@ -339,7 +346,15 @@ void recepteur_ml (const char* bus, KindOfTest kod, unsigned int inst, debugInt++; string reg = *iter; if (regexpAreUniq) { (reg += " ") += stream.str();} - bindIdList.push_back (IvyBindMsg (recepteurCB, (void *) inst, reg.c_str())); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + bindIdList.push_back (IvyBindMsg (recepteurCB, (void *) long(inst), reg.c_str())); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + } IvyBindMsg (startOfSeqCB, NULL, "^start(OfSequence)"); IvyBindMsg (endOfSeqCB, NULL, "^end(OfSequence)"); @@ -540,7 +555,14 @@ void sendAllMessageCB (TimerId id, void *user_data, unsigned long delta) IvySendMsg ("startOfSequence"); ListOfString::iterator iter; for (iter=messages->begin(); iter != messages->end(); iter++) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif envoyes += IvySendMsg ((*iter).c_str()); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } IvySendMsg ("endOfSequence"); @@ -619,7 +641,15 @@ void desabonneEtReabonneCB (TimerId id, void *user_data, unsigned long delta) ListOfString::const_iterator iter2; for (iter2=mds->regexps->begin(); iter2 != mds->regexps->end(); iter2++) { string reg = *iter2; - mds->bindIdList->push_back (IvyBindMsg (recepteurCB, (void *) mds->inst, reg.c_str())); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-security" +#endif + mds->bindIdList->push_back (IvyBindMsg (recepteurCB, (void *) long(mds->inst), + reg.c_str())); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif } // CHANGE REGEXP -- cgit v1.1