Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Re: servercrash (1.13.1-devel)
Home

[Freeciv-Dev] Re: servercrash (1.13.1-devel)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Short <jshort@xxxxxxxxxxxxxx>
Cc: Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: servercrash (1.13.1-devel)
From: rf13@xxxxxxxxxxxxxxxxx
Date: Thu, 26 Sep 2002 05:19:50 -0700

On Wed, Sep 25, 2002 at 12:24:40PM -0400, Jason Short wrote:
> 
> 
> On Wed, 25 Sep 2002 rf13@xxxxxxxxxxxxxxxxx wrote:
> 
> > On Tue, Sep 24, 2002 at 02:20:00PM -0500, Jason Short wrote:
> > > Thomas Strub wrote:
> > >
> > > > civserver: dataio.c:342: dio_put_bit_string: Assertion `bytes < 255'
> > > > failed.
> > >
> > > void dio_put_bit_string(struct data_out *dout, const char *value)
> > > {
> >
> > >    size_t bits = strlen(value)
> >
> > bits = 0 in the error case
> >
> > > , bytes = (bits - 1) / 8 + 1;
> >
> > bytes = -1/8 + 1 (you may expect that this will be 1 but it isn't if
> > it is calculated in size_t (an unsigned type). Then it is 2^32/8+1 =
> > 2^24+1 = 16777217. Solution change the type of bytes to int.
> 
> Wouldn' it also work to say
> 
>   bytes = (bits + 7) / 8;

Yes this  looks equivalent.
 
> ?  This seems cleaner.

Grep for '-.*1.*/.*[+].*1' and you will see that the form I mention is
used in the code. I don't know how to grep for your form to see which
is more used.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx


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