Update of /cvsroot/monetdb/sql/src/backends/monet4
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24832/src/backends/monet4
Modified Files:
sql_server.mx
Log Message:
Tyring to fix the code that triggers some of the 120
"conversion from <type1> to <type2>, possible loss of data"
warnings with the Microsoft compiler on Windows (cf.,
http://monetdb.cwi.nl/testing/projects/monetdb/Current/sql/.Mic.32.32.d.1-Windows5.1..2008.08.29_00-09-02/make.out.html
):
added explicite downcasts, triggering assertions in case of overflows.
(Check the effect tomorrow at
http://monetdb.cwi.nl/testing/projects/monetdb/Current/sql/.Mic.32.32.d.1-Windows5.1/make.out.html
and
http://monetdb.cwi.nl/testing/projects/monetdb/Current/sql/.Mic.64.64.d.1-Windows5.2/make.out.html
)
Most of the remaining warnings are due to the fact that
member "ival" of struct "symbdata" in src/server/sql_symbol.mx
is defined as "lng" but often used as / assigned to "int"
(without cast or overflow check).
I will try to find a proper solution for this together with
Niels and/or Sjoerd...
U sql_server.mx
Index: sql_server.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet4/sql_server.mx,v
retrieving revision 1.201
retrieving revision 1.202
diff -u -d -r1.201 -r1.202
--- sql_server.mx 17 Jul 2008 13:28:37 -0000 1.201
+++ sql_server.mx 29 Aug 2008 17:03:45 -0000 1.202
@@ -971,17 +971,23 @@
} else if (*r > 0 && *r < *s) {
int dff = *s - *r;
lng rnd = scales[dff]>>1;
+ lng lres;
if (*v > 0)
- *res = (((*v + rnd)/scales[dff])*scales[dff]);
+ lres = (((*v + rnd)/scales[dff])*scales[dff]);
else
- *res = (((*v - rnd)/scales[dff])*scales[dff]);
+ lres = (((*v - rnd)/scales[dff])*scales[dff]);
+ assert((lng) [EMAIL PROTECTED] <= lres && lres <= (lng) [EMAIL
PROTECTED]);
+ *res = lres;
} else if (*r <= 0 && -*r + *s > 0) {
int dff = -*r + *s;
lng rnd = scales[dff]>>1;
+ lng lres;
if (*v > 0)
- *res = (((*v + rnd)/scales[dff])*scales[dff]);
+ lres = (((*v + rnd)/scales[dff])*scales[dff]);
else
- *res = (((*v - rnd)/scales[dff])*scales[dff]);
+ lres = (((*v - rnd)/scales[dff])*scales[dff]);
+ assert((lng) [EMAIL PROTECTED] <= lres && lres <= (lng) [EMAIL
PROTECTED]);
+ *res = lres;
} else {
*res = *v;
}
@@ -1069,19 +1075,19 @@
*res = @1_nil;
} else if (*r < 0) {
int d = -*r;
- @1 rnd = scales[d]>>1;
+ @1 rnd = (@1) (scales[d]>>1);
if (*v > 0)
- *res = (floor(((*v +
rnd)/((@1)(scales[d]))))*scales[d]);
+ *res = (@1) (floor(((*v +
rnd)/((@1)(scales[d]))))*scales[d]);
else
- *res = (floor(((*v +
rnd)/((@1)(scales[d]))))*scales[d]);
+ *res = (@1) (floor(((*v +
rnd)/((@1)(scales[d]))))*scales[d]);
} else if (*r > 0) {
int d = *r;
if (*v > 0)
- *res = (floor(*v*(@1)scales[d]+.5)/scales[d]);
+ *res = (@1) (floor(*v*(@1)scales[d]+.5)/scales[d]);
else
- *res = (floor(*v*(@1)scales[d]+.5)/scales[d]);
+ *res = (@1) (floor(*v*(@1)scales[d]+.5)/scales[d]);
} else {
*res = *v;
}
@@ -1174,7 +1180,7 @@
@= simpledowncast
int @[EMAIL PROTECTED]( @1 *res, @2 *v )
{
- lng val = *v;
+ @3 val = *v;
/* shortcut nil */
if (*v == @2_nil) {
@@ -1183,11 +1189,11 @@
}
/* see if the number fits in the data type */
- if (val >= [EMAIL PROTECTED] && val <= [EMAIL PROTECTED]) {
+ if (val >= (@3) [EMAIL PROTECTED] && val <= (@3) [EMAIL PROTECTED])
{
*res = (@1)val;
return GDK_SUCCEED;
} else {
- GDKerror("convert: value (" LLFMT ") exceeds limits of type
@1\n",val);
+ GDKerror("convert: value (" @4 ") exceeds limits of type
@1\n",val);
return GDK_FAIL;
}
}
@@ -1273,7 +1279,7 @@
@:numcastup(lng,lng)@
@= fnumcastdown
-@:simpledowncast(@1,@2)@
+@:simpledowncast(@1,@2,dbl,"%f")@
/* when casting a floating point to an decimal we like to preserve the
* precision. This means we first scale the float before converting.
@@ -1396,7 +1402,7 @@
@c
@= numcastdown
-@:simpledowncast(@1,@2)@
+@:simpledowncast(@1,@2,lng,LLFMT)@
int
@[EMAIL PROTECTED]( @1 *res, int *s1, @2 *v )
@@ -1481,6 +1487,7 @@
if (interval_from_str( s, *sk, *ek, &res ) < 0)
return GDK_FAIL;
+ assert((lng) GDK_int_min <= res && res <= (lng) GDK_int_max);
*ret = (int) res;
return GDK_SUCCEED;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins