freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddyz77 AT tin.it>
- To: TDS Development Group <freetds AT franklin.oit.unc.edu>
- Subject: Re: element of style
- Date: 24 Aug 2002 11:57:02 +0200
Il sab, 2002-08-24 alle 09:09, James K.Lowden ha scritto:
> Contributors,
>
> There are several places in e.g. tds/convert.c that use comparisons to
> very strange decimal numbers. I'd like to see us use hex instead, when
> we're looking for overflow conditions and such.
Sound right..
Perhaps should best to add a CodingStyle document to FreeTDS...
I know that { should be placed after while/if/switch/for (exception for
functions/struct). But case should be indented from switch or not?
Should we use tab or space (how many?) to indent?
>
> For instance in convert.c, line 2654, I think
>
> if (num > 214748364u)
It's right.
214748364 = 2^31/10
I test number for overflow before multiply it for 10.
So it'll be (0x80000000U/10U)
>
> is a bug (Why 0xccccccc ?). Correct would be:
>
> if (num > 2147483648u)
>
> and clearer would be:
>
> if (num > 0x80000000U) /* uppercase suffixes, please! */
>
> Best, I'm sure, would be to include <limits.h> and apply some autoconf
> magic to define things such that this would work:
>
> if (num > INT_16_MAX)
>
INT_16_MAX is quite different from INT_MAX. We don't know INT_MAX in
every platform but INT_16_MAX is always 0x8000...
The only problem should be INT_64_MAX... is 0x8000000000000000l or
0x8000000000000000ll or 0x8000000000000000i64 ?
There are some defines in inttypes.h to handle this stuff...
Perhaps is better to define because is easy to forgot a zero...
> because by relying on the system header files, we avoid bumping into
> compiler corner cases, valid expressions that some compilers will fail to
> comprehend.
>
> --jkl
>
freddy77
-
element of style,
James K . Lowden, 08/24/2002
- <Possible follow-up(s)>
- Re: element of style, Frediano Ziglio, 08/24/2002
- Re: element of style, Brian Bruns, 08/24/2002
- Re: element of style, Chris Eleveld, 08/24/2002
- Re: element of style, Frediano Ziglio, 08/24/2002
- Re: element of style, Frediano Ziglio, 08/24/2002
- Re: element of style, Brian Bruns, 08/24/2002
- Re: element of style, Brian Bruns, 08/24/2002
- Re: element of style, Frediano Ziglio, 08/24/2002
- Re: element of style, James K . Lowden, 08/24/2002
- Re: element of style, Chris Eleveld, 08/24/2002
Archive powered by MHonArc 2.6.24.