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: BORBELY Zoltan
Subject: Re: Good bits from Marcin's patch3
Date: Wed, 3 Apr 2002 12:39:27 +0200
User-agent: Mutt/1.2.5.1i

Hello,

On Wed, Apr 03, 2002 at 11:55:59AM +0200, Pavel Machek wrote:
> These seem to be good bits ("should not hurt non-windoze") from
> Marcin's patch... Okay to commit?

Please don't commit it! All of the parts are applied or rejected.

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

It's a broken behaviour (yes, VC on the wrong side). C99 states snprintf()
_will_ terminate the buffer.

> --- common/devices/winserial.c        29 Mar 2002 20:51:22 -0000      1.4
> +++ common/devices/winserial.c        3 Apr 2002 09:50:12 -0000
> @@ -33,6 +33,7 @@
>  #include <memory.h>
>  
>  #include "misc.h"
> +#include "compat.h"
>  #include "gsm-error.h"

Unnecessary, misc.h currently includes compat.h


>                       snprintf(data->Model, GNOKII_MIN(n, 
> GSM_MAX_MODEL_LENGTH), "%s", message + 27);
> +                     data->Model[GNOKII_MIN(n, GSM_MAX_MODEL_LENGTH)-1]=0;

We should rely on snprintf instead of it. If we choose this way, we should
check the whole gnokii source. I have found a (maybe) GPL compatible snprintf
implementation. It will solve the problem.

The license of this implementation states:

/*
 * Copyright Patrick Powell 1995
 * This code is based on code written by Patrick Powell (address@hidden)
 * It may be used for any purpose as long as this notice remains intact
 * on all source code distributions
 */

and wget (which is an officional gnu project) includes this file (and samba
too). So we can include it, but we must tweak the configure.in first :-)


> --- include/compat.h  3 Apr 2002 01:03:58 -0000       1.6
> +++ include/compat.h  3 Apr 2002 09:50:53 -0000
[...]
> -# define timerclear(tvp)     ((tvp)->tv_sec = (tvp)->tv_usec = 0)
> +#ifndef WIN32
> +#  define timerclear(tvp)    ((tvp)->tv_sec = (tvp)->tv_usec = 0)

Fixed in cvs too.


Bye,
Bozo



reply via email to

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