summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbustico2008-05-13 14:02:41 +0000
committerbustico2008-05-13 14:02:41 +0000
commit3708024965cc018303752dc81f4bc80642570c2d (patch)
treeadf47b238890b9aab97fef290f96b0f8f73e3f83 /src
parentefd3b1deb9efef9a16544e343dfca6109bc23e67 (diff)
downloadivy-c-3708024965cc018303752dc81f4bc80642570c2d.zip
ivy-c-3708024965cc018303752dc81f4bc80642570c2d.tar.gz
ivy-c-3708024965cc018303752dc81f4bc80642570c2d.tar.bz2
ivy-c-3708024965cc018303752dc81f4bc80642570c2d.tar.xz
add of __attribute__ on the functions which have printf like api to enable
gcc to check format errors
Diffstat (limited to 'src')
-rw-r--r--src/ivy.h18
-rw-r--r--src/timer.c22
2 files changed, 25 insertions, 15 deletions
diff --git a/src/ivy.h b/src/ivy.h
index 5c98af9..bd107ff 100644
--- a/src/ivy.h
+++ b/src/ivy.h
@@ -22,6 +22,11 @@
extern "C" {
#endif
+
+#ifndef __GNUC__
+# define __attribute__(x) /*NOTHING*/
+#endif
+
/* numero par default du bus */
typedef struct _clnt_lst_dict *IvyClientPtr;
@@ -79,20 +84,25 @@ IvyClientPtr IvyGetApplication( char *name );
char *IvyGetApplicationList(const char *sep);
char **IvyGetApplicationMessages( IvyClientPtr app); /* demande de reception d'un message */
-MsgRcvPtr IvyBindMsg( MsgCallback callback, void *user_data, const char *fmt_regexp, ... ); /* avec sprintf prealable */
-MsgRcvPtr IvyChangeMsg (MsgRcvPtr msg, const char *fmt_regex, ... ); /* avec sprintf prealable */
+MsgRcvPtr IvyBindMsg( MsgCallback callback, void *user_data, const char *fmt_regexp, ... )
+__attribute__((format(printf,3,4))) ; /* avec sprintf prealable */
+
+MsgRcvPtr IvyChangeMsg (MsgRcvPtr msg, const char *fmt_regex, ... )
+__attribute__((format(printf,2,3))); /* avec sprintf prealable */
void IvyUnbindMsg( MsgRcvPtr id );
/* emission d'un message d'erreur */
-void IvySendError( IvyClientPtr app, int id, const char *fmt, ... );
+void IvySendError( IvyClientPtr app, int id, const char *fmt, ... )
+__attribute__((format(printf,3,4))) ; /* avec sprintf prealable */
/* emmission d'un message die pour terminer l'application */
void IvySendDieMsg( IvyClientPtr app );
/* emission d'un message retourne le nb effectivement emis */
-int IvySendMsg( const char *fmt_message, ... ); /* avec sprintf prealable */
+int IvySendMsg( const char *fmt_message, ... )
+__attribute__((format(printf,1,2))); /* avec sprintf prealable */
/* Message Direct Inter-application */
diff --git a/src/timer.c b/src/timer.c
index 9718b22..4b07d27 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -62,14 +62,14 @@ static long currentTime()
}
static void SetNewTimeout( unsigned long current, unsigned long when )
{
- unsigned long time;
- time = (when <= current) ? 0 : when - current;
+ unsigned long ltime;
+ ltime = (when <= current) ? 0 : when - current;
nextTimeout = when;
- selectTimeout.tv_sec = time / MILLISEC;
- selectTimeout.tv_usec = (time - selectTimeout.tv_sec* MILLISEC) * MILLISEC;
+ selectTimeout.tv_sec = ltime / MILLISEC;
+ selectTimeout.tv_usec = (ltime - selectTimeout.tv_sec* MILLISEC) * MILLISEC;
if ( timeoutptr == NULL )
timeoutptr = &selectTimeout;
- /*printf("New timeout %lu\n", time );*/
+ /*printf("New timeout %lu\n", ltime );*/
}
static void AdjTimeout(unsigned long current)
{
@@ -95,7 +95,7 @@ static void AdjTimeout(unsigned long current)
/* API */
-TimerId TimerRepeatAfter( int count, long time, TimerCb cb, void *user_data )
+TimerId TimerRepeatAfter( int count, long ltime, TimerCb cb, void *user_data )
{
unsigned long stamp;
TimerId timer;
@@ -108,8 +108,8 @@ TimerId TimerRepeatAfter( int count, long time, TimerCb cb, void *user_data )
timer->callback = cb;
timer->user_data = user_data;
stamp = currentTime();
- timer->period = time;
- timer->when = stamp + time;
+ timer->period = ltime;
+ timer->when = stamp + ltime;
if ( (timer->when < nextTimeout) || (timeoutptr == NULL))
SetNewTimeout( stamp, timer->when );
IVY_LIST_ADD_END( timers, timer )
@@ -123,14 +123,14 @@ void TimerRemove( TimerId timer )
stamp = currentTime();
AdjTimeout(stamp);
}
-void TimerModify( TimerId timer, long time )
+void TimerModify( TimerId timer, long ltime )
{
unsigned long stamp;
if ( !timer ) return;
stamp = currentTime();
- timer->period = time;
- timer->when = stamp + time;
+ timer->period = ltime;
+ timer->when = stamp + ltime;
AdjTimeout(stamp);
}
/* Interface avec select */