gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Good bits from Marcin's patch3


From: Pawel Kot
Subject: Re: Good bits from Marcin's patch3
Date: Wed, 03 Apr 2002 12:51:17 +0200

Hi Pavel,

>>> address@hidden 3 April 2002 11:55:59 >>>
> These seem to be good bits ("should not hurt non-windoze") from
> Marcin's patch... Okay to commit?

Consult Bozo with the changes and see below.

[What is semantics of snprintf? Is it possible that result is not
0-terminated after snprintf?

AFAIU we have such case in VC6. But the workaround is *NOT* good.
We need to check in the configure if we have correct or broken
implementation (checking the trailing \0). If it's broken, we should use
our own snprintf() implementation. Bozo is working on it AFAIK.

> diff -u -u -r1.4 winserial.c
> --- common/devices/winserial.c        29 Mar 2002 20:51:22 -0000      1.4
> +++ common/devices/winserial.c        3 Apr 2002 09:50:12 -0000
>  #include "misc.h"
> +#include "compat.h"

I think along with this change we should remove #include "compat.h" from the 
misc.h

> Index: include/compat.h
> ===================================================================
> RCS file: /cvsroot/gnokii/gnokii/include/compat.h,v
> retrieving revision 1.6
> diff -u -u -r1.6 compat.h
> --- include/compat.h  3 Apr 2002 01:03:58 -0000       1.6
> +++ include/compat.h  3 Apr 2002 09:50:53 -0000
> @@ -50,11 +50,13 @@
>  /* Convenience macros for operations on timevals.
>     NOTE: `timercmp' does not work for >= or <=.  */
>  # define timerisset(tvp)     ((tvp)->tv_sec || (tvp)->tv_usec)
> -# define timerclear(tvp)     ((tvp)->tv_sec = (tvp)->tv_usec = 0)
> -# define timercmp(a, b, CMP)                                                 
>       \
> -  (((a)->tv_sec == (b)->tv_sec) ?                                          \
> -   ((a)->tv_usec CMP (b)->tv_usec) :                                         
>       \
> -   ((a)->tv_sec CMP (b)->tv_sec))
> +#ifndef WIN32
> +#  define timerclear(tvp)    ((tvp)->tv_sec = (tvp)->tv_usec = 0)
> +#  define timercmp(a, b, CMP)                                                
>       \
> +   (((a)->tv_sec == (b)->tv_sec) ?                                         \
> +    ((a)->tv_usec CMP (b)->tv_usec) :                                        
>       \
> +    ((a)->tv_sec CMP (b)->tv_sec))
> +#endif
>  # define timeradd(a, b, result)                                              
>       \
>    do {                                                                       
>       \
>      (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;                          \

It's not a good fix. It compiles cleanly with cygwin under Windows without
#ifndef WIN32. So adding it is not a WIN32 fix but VC6 workaround. Or
even not this as you have above:
#undef timerisset
#undef timerclear
#undef timercmp
#undef timeradd
#undef timersub
I guess it would break WIN32 with all time operations. The correct fix
would be to define these routines in a compatible way with all platforms.

pkot




reply via email to

[Prev in Thread] Current Thread [Next in Thread]