Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24832/src/server
Modified Files:
sql_atom.mx sql_env.mx sql_mvc.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_mvc.mx
Index: sql_mvc.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_mvc.mx,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -d -r1.208 -r1.209
--- sql_mvc.mx 25 Aug 2008 13:36:16 -0000 1.208
+++ sql_mvc.mx 29 Aug 2008 17:03:46 -0000 1.209
@@ -580,7 +580,7 @@
m->argfixed = 0;
m->sym = NULL;
- m->role_id = m->user_id = m->last_id = -1;
+ m->last_id = m->role_id = m->user_id = -1;
m->timezone = 0;
m->clientid = clientid;
@@ -642,7 +642,7 @@
m->argc = 0;
m->sym = NULL;
- m->role_id = m->user_id = m->last_id = -1;
+ m->last_id = m->role_id = m->user_id = -1;
m->emode = m_normal;
m->emod = mod_none;
if (m->reply_size != 100)
U sql_atom.mx
Index: sql_atom.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_atom.mx,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- sql_atom.mx 11 Aug 2008 19:08:45 -0000 1.59
+++ sql_atom.mx 29 Aug 2008 17:03:46 -0000 1.60
@@ -124,7 +124,7 @@
printf("atom_int %d\n", a->data.vtype);
assert(0);
}
- a->d = val;
+ a->d = (dbl) val;
a->data.len = 0;
if (atom_debug)
fprintf(stderr, "atom_int(%s,"LLFMT")\n",
tpe->type->sqlname, val);
@@ -187,8 +187,10 @@
a->tpe = *tpe;
if (tpe->type->localtype == TYPE_dbl)
a->data.val.dval = val;
- else
- a->data.val.fval = val;
+ else {
+ assert((dbl) GDK_flt_min <= val && val <= (dbl) GDK_flt_max);
+ a->data.val.fval = (flt) val;
+ }
a->data.vtype = tpe->type->localtype;
a->data.len = 0;
if (atom_debug)
@@ -559,12 +561,18 @@
a->data.vtype = tp->type->localtype;
if (a->data.vtype == TYPE_lng)
a->data.val.lval *= mul;
- else if (a->data.vtype == TYPE_int)
- a->data.val.ival *= mul;
- else if (a->data.vtype == TYPE_sht)
- a->data.val.shval *= mul;
- else if (a->data.vtype == TYPE_bte)
- a->data.val.btval *= mul;
+ else if (a->data.vtype == TYPE_int) {
+ assert((lng) GDK_int_min <= (lng)
a->data.val.ival * mul && (lng) a->data.val.ival * mul <= (lng) GDK_int_max);
+ a->data.val.ival *= (int) mul;
+ }
+ else if (a->data.vtype == TYPE_sht) {
+ assert((lng) GDK_sht_min <= (lng)
a->data.val.shval * mul && (lng) a->data.val.shval * mul <= (lng) GDK_sht_max);
+ a->data.val.shval *= (sht) mul;
+ }
+ else if (a->data.vtype == TYPE_bte) {
+ assert((lng) GDK_bte_min <= (lng)
a->data.val.btval * mul && (lng) a->data.val.btval * mul <= (lng) GDK_bte_max);
+ a->data.val.btval *= (bte) mul;
+ }
return 1;
}
if (at->type->eclass == EC_NUM && tp->type->eclass == EC_DEC &&
@@ -611,12 +619,18 @@
a->data.vtype = tp->type->localtype;
if (a->data.vtype == TYPE_lng)
a->data.val.lval *= mul;
- else if (a->data.vtype == TYPE_int)
- a->data.val.ival *= mul;
- else if (a->data.vtype == TYPE_sht)
- a->data.val.shval *= mul;
- else if (a->data.vtype == TYPE_bte)
- a->data.val.btval *= mul;
+ else if (a->data.vtype == TYPE_int) {
+ assert((lng) GDK_int_min <= (lng)
a->data.val.ival * mul && (lng) a->data.val.ival * mul <= (lng) GDK_int_max);
+ a->data.val.ival *= (int) mul;
+ }
+ else if (a->data.vtype == TYPE_sht) {
+ assert((lng) GDK_sht_min <= (lng)
a->data.val.shval * mul && (lng) a->data.val.shval * mul <= (lng) GDK_sht_max);
+ a->data.val.shval *= (sht) mul;
+ }
+ else if (a->data.vtype == TYPE_bte) {
+ assert((lng) GDK_bte_min <= (lng)
a->data.val.btval * mul && (lng) a->data.val.btval * mul <= (lng) GDK_bte_max);
+ a->data.val.btval *= (bte) mul;
+ }
return 1;
}
if ((at->type->eclass == EC_DEC ||
@@ -653,8 +667,10 @@
}
if (tp->type->localtype == TYPE_dbl)
a->data.val.dval = a->d;
- else
- a->data.val.fval = a->d;
+ else {
+ assert((dbl) GDK_flt_min <= a->d && a->d <=
(dbl) GDK_flt_max);
+ a->data.val.fval = (flt) a->d;
+ }
a->tpe = *tp;
a->data.vtype = tp->type->localtype;
return 1;
U sql_env.mx
Index: sql_env.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_env.mx,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- sql_env.mx 12 Jul 2008 09:16:56 -0000 1.69
+++ sql_env.mx 29 Aug 2008 17:03:46 -0000 1.70
@@ -82,8 +82,11 @@
str
sql_update_var(mvc *m, char *name)
{
+ lng sgn;
if (strcmp(name, "debug") == 0) {
- m->debug = stack_get_number(m, "debug");
+ sgn = stack_get_number(m, "debug");
+ assert((lng) GDK_int_min <= sgn && sgn <= (lng) GDK_int_max);
+ m->debug = sgn;
} else if (strcmp(name, "current_schema") == 0) {
char *schema = stack_get_string(m, "current_schema");
@@ -97,9 +100,13 @@
return sql_message( "Role (%s) missing\n", role);
}
} else if (strcmp(name, "current_timezone") == 0) {
- m->timezone = stack_get_number(m, "current_timezone") / 60;
+ sgn = stack_get_number(m, "current_timezone") / 60;
+ assert((lng) GDK_int_min <= sgn && sgn <= (lng) GDK_int_max);
+ m->timezone = sgn;
} else if (strcmp(name, "cache") == 0) {
- m->cache = stack_get_number(m, "cache");
+ sgn = stack_get_number(m, "cache");
+ assert((lng) GDK_int_min <= sgn && sgn <= (lng) GDK_int_max);
+ m->cache = sgn;
}
return NULL;
}
-------------------------------------------------------------------------
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