Changeset: 163ca6fe5738 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=163ca6fe5738
Modified Files:
clients/mapiclient/mclient.c
clients/odbc/driver/ODBCConvert.c
gdk/gdk_atoms.mx
gdk/gdk_batop.mx
gdk/gdk_rangejoin.mx
monetdb5/mal/mal_atom.c
monetdb5/mal/mal_function.c
monetdb5/mal/mal_interpreter.mx
monetdb5/mal/mal_parser.mx
monetdb5/mal/mal_properties.c
monetdb5/modules/kernel/aggr_be_avg.mx
monetdb5/modules/kernel/aggr_be_count.mx
monetdb5/modules/kernel/aggr_be_minmax.mx
monetdb5/modules/kernel/aggr_be_prod.mx
monetdb5/modules/kernel/aggr_be_sum.mx
monetdb5/modules/kernel/aggr_bge_avg.mx
monetdb5/modules/kernel/aggr_bge_count.mx
monetdb5/modules/kernel/aggr_bge_minmax.mx
monetdb5/modules/kernel/aggr_bge_prod.mx
monetdb5/modules/kernel/aggr_bge_sum.mx
sql/backends/monet5/sql_scenario.c
sql/common/sql_types.c
sql/server/rel_dump.c
sql/server/rel_exp.c
sql/server/rel_optimizer.c
sql/server/rel_prop.c
sql/server/rel_select.c
sql/server/sql_datetime.c
sql/server/sql_statement.c
sql/storage/store.c
tools/merovingian/client/monetdb.c
tools/mserver/mserver5.c
Branch: Dec2011
Log Message:
Fixed a lot of complaints from Clang-3.0.
This fixes as much of bug 3042 as is reasonable.
Many changes are to use the C preprocessor to disable pieces of code
instead of using the C construct if (0) ...
Also, don't put code after functions that don't return.
diffs (truncated from 1168 to 300 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -2878,9 +2878,10 @@ main(int argc, char **argv)
current `c' is based on and see if we recognize
it: if -? or --help, exit with 0, else with -1 */
usage(argv[0], strcmp(argv[optind - 1], "-?") == 0 ||
strcmp(argv[optind - 1], "--help") == 0 ? 0 : -1);
- break;
+ /* not reached */
default:
usage(argv[0], -1);
+ /* not reached */
}
}
#ifdef HAVE_ICONV
diff --git a/clients/odbc/driver/ODBCConvert.c
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -1894,7 +1894,7 @@ ODBCFetch(ODBCStmt *stmt,
addStmtError(stmt, "07006", NULL, 0);
return SQL_ERROR;
}
- break;
+ /* break; -- not reached */
case SQL_C_BIT:
if (ardrec && row > 0)
ptr = (SQLPOINTER) ((char *) ptr + row * (bind_type ==
SQL_BIND_BY_COLUMN ? sizeof(unsigned char) : bind_type));
diff --git a/gdk/gdk_atoms.mx b/gdk/gdk_atoms.mx
--- a/gdk/gdk_atoms.mx
+++ b/gdk/gdk_atoms.mx
@@ -1269,17 +1269,16 @@ int
@:atommem(@1,sizeof(@1))@
while (GDKisspace(*p))
- p++;
+ p++;
if (p[0] == 'n' && p[1] == 'i' && p[2] == 'l') {
**dst = @1_nil;
p += 3;
} else {
if (!num10(*p) ) {
- if ( *p == '-') {
+ if (*p == '-') {
sign = -1;
p++;
- } else
- if ( *p == '+') {
+ } else if (*p == '+') {
p++;
} else {
/* all else is an error */
@@ -1296,10 +1295,13 @@ int
if (p - q > @2 || (p - q == @2 && strncmp(q, "@3", @2) > 0)){
**dst = @1_nil;
sign = -1;
- } else sign = 1;
- if (p[0] == 'L' && p[1] == 'L' && sizeof(@1) == 8) {
+ } else
+ sign = 1;
+#if @4 == 8
+ if (p[0] == 'L' && p[1] == 'L') {
p += 2;
}
+#endif
}
return sign * (int) (p - src);
}
@@ -1319,19 +1321,19 @@ static int @1Write(@1 *a, stream *s, siz
@
@c
-@:numfromstr(bte,3,127)@
+@:numfromstr(bte,3,127,1)@
@:atomtostr(bte,"%hhd",bte)@
@:atom_io(bte,Bte,bte)@
-@:numfromstr(sht,5,32767)@
+@:numfromstr(sht,5,32767,2)@
@:atomtostr(sht,"%hd",sht)@
@:atom_io(sht,Sht,sht)@
-@:numfromstr(int,10,2147483647)@
+@:numfromstr(int,10,2147483647,SIZEOF_INT)@
@:atomtostr(int,"%d",int)@
@:atom_io(int,Int,int)@
-@:numfromstr(lng,19,9223372036854775807)@
+@:numfromstr(lng,19,9223372036854775807,SIZEOF_LNG)@
@:atomtostr(lng,LLFMT,lng)@
@:atom_io(lng,Lng,lng)@
diff --git a/gdk/gdk_batop.mx b/gdk/gdk_batop.mx
--- a/gdk/gdk_batop.mx
+++ b/gdk/gdk_batop.mx
@@ -1548,7 +1548,6 @@ BATsample(BAT *b, BUN size)
}
}
}
- break;
@
@c
BAT *
diff --git a/gdk/gdk_rangejoin.mx b/gdk/gdk_rangejoin.mx
--- a/gdk/gdk_rangejoin.mx
+++ b/gdk/gdk_rangejoin.mx
@@ -313,11 +313,11 @@ break;
BUN g = MAX(ll-lp, 1024*1024);
BATsetcount(bn, o);
if (limit) {
- *limit = o *
(lc<rc)?((rp-rc)/MAX(1,rc)):((lp-lc)/MAX(1,lc));
+ *limit = o && lc < rc ? (rp - rc) / MAX(1, rc) :
(lp - lc) / MAX(1, lc);
break;
- }
+ }
if (BATextend(bn, BATcapacity(bn)+g) == NULL)
- goto failed;
+ goto failed;
}
bnh = (oid*)Hloc(bn, bnf);
bnt = (oid*)Tloc(bn, bnf);
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -199,9 +199,7 @@ int malAtomProperty(MalBlkPtr mb, InstrP
}
break;
case 's':
- if (idcmp("storage", name) || pci->argc != 1)
- return 0;
- else {
+ if (idcmp("storage", name) == 0 && pci->argc == 1) {
BATatoms[tpe].storage = (*(long (*)(void))pci->fcn)();
setAtomName(pci);
return 1;
@@ -222,9 +220,7 @@ int malAtomProperty(MalBlkPtr mb, InstrP
}
break;
case 'v':
- if (idcmp("varsized", name) || pci->argc != 1)
- return 0;
- else {
+ if (idcmp("varsized", name) == 0 && pci->argc == 1) {
BATatoms[tpe].varsized = (*(long (*)(void))pci->fcn)();
setAtomName(pci);
return 1;
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -992,13 +992,15 @@ showInFlow(MalBlkPtr mb, int pc, int var
int i, k;
/* find last use, needed for operations with side effects */
- for (i = pc -1; i >= 0; i-- ){
+ for (i = pc -1; i >= 0; i--) {
p = getInstrPtr(mb, i);
- for (k = 0; k < p->argc; k++)
- if (p->argv[k] == varid )
- mnstr_printf(f, "n%d -> n%d\n",i, pc);
+ for (k = 0; k < p->argc; k++) {
+ if (p->argv[k] == varid ) {
+ mnstr_printf(f, "n%d -> n%d\n", i, pc);
return;
}
+ }
+ }
}
/*
diff --git a/monetdb5/mal/mal_interpreter.mx b/monetdb5/mal/mal_interpreter.mx
--- a/monetdb5/mal/mal_interpreter.mx
+++ b/monetdb5/mal/mal_interpreter.mx
@@ -2577,8 +2577,10 @@ void releaseBAT(MalBlkPtr mb, MalStkPtr
mb->profiler[ppc].ticks = 0;
mb->profiler[ppc].clock = stk->clock;
/* emit the instruction upon start as well */
- if (@2 && malProfileMode)
+#if @2
+ if (malProfileMode)
profilerEvent(cntxt->idx, mb, stk,
stkpc,"start");
+#endif
#ifdef HAVE_TIMES
times(&stk->timer);
mb->profiler[ppc].timer = stk->timer;
diff --git a/monetdb5/mal/mal_parser.mx b/monetdb5/mal/mal_parser.mx
--- a/monetdb5/mal/mal_parser.mx
+++ b/monetdb5/mal/mal_parser.mx
@@ -1178,12 +1178,12 @@ during the final phase reshuffle the ret
setPolymorphic(curInstr,type,TRUE);
setVarType(curBlk,varid,type);
@:propList(varid)@
- } else
- if( @1){
+ } else {
+#if @1
parseError(cntxt,"Argument defined twice\n");
typeElm(cntxt,getVarType(curBlk,varid));
@:propList(varid)@
- } else {
+#else
advance(cntxt,l);
type= typeElm(cntxt,getVarType(curBlk,varid));
if( type != getVarType(curBlk,varid))
@@ -1192,6 +1192,7 @@ during the final phase reshuffle the ret
setPolymorphic(curInstr,type,TRUE);
setVarType(curBlk,varid,type);
@:propList(varid)@
+#endif
}
} else if( currChar(cntxt)== ':' ){
type= typeElm(cntxt,TYPE_any);
diff --git a/monetdb5/mal/mal_properties.c b/monetdb5/mal/mal_properties.c
--- a/monetdb5/mal/mal_properties.c
+++ b/monetdb5/mal/mal_properties.c
@@ -353,11 +353,11 @@ PropertyOperatorString( prop_op_t op )
switch(op) {
case op_lt: return "<";
case op_lte: return "<=";
+ default:
case op_eq: return "=";
case op_gte: return ">=";
case op_gt: return ">";
case op_ne: return "!=";
}
- return "=";
}
diff --git a/monetdb5/modules/kernel/aggr_be_avg.mx
b/monetdb5/modules/kernel/aggr_be_avg.mx
--- a/monetdb5/modules/kernel/aggr_be_avg.mx
+++ b/monetdb5/modules/kernel/aggr_be_avg.mx
@@ -70,7 +70,8 @@ All Rights Reserved.
*/
@= aggrX3_avg
ALGODEBUG THRprintf(GDKout,
"#aggrX3_avg(@1,@2,@3,@4,@5,@6,@7,@8,@9);\n");
- if (@1 && range > 0) {
+#if @1
+ if (range > 0) {
/* create tmp. sums array */
sums = (dbl*) GDKzalloc(range*sizeof(dbl));
if (sums == NULL) {
@@ -79,24 +80,33 @@ All Rights Reserved.
return GDK_FAIL;
}
}
- if (@2 && BATprepareHash(bn)) {
+#endif
+#if @2
+ if (BATprepareHash(bn)) {
GDKerror("aggrX3_avg(@1,@2,@3,@4,@5,@6,@7,@8,@9):
BATprepareHash(bn) failed");
- if (@1 && sums)
+#if @1
+ if (sums)
GDKfree(sums);
+#endif
BBPreclaim(bn);
return GDK_FAIL;
}
+#endif
cnt = (BUN*) GDKzalloc(slots*sizeof(cnt[0]));
if (cnt == NULL) {
GDKerror("aggrX3_avg(@1,@2,@3,@4,@5,@6,@7,@8,@9): cnt =
GDKzalloc("OIDFMT"*"SZFMT") failed", slots, sizeof(cnt[0]));
- if (@1 && sums)
+#if @1
+ if (sums)
GDKfree(sums);
+#endif
BBPreclaim(bn);
return GDK_FAIL;
}
/* scan b, adding sums, and incrementing counts */
bhsb = b->hseqbase - 1;
- if (!(@1 && sums))
+#if @1
+ if (!sums)
+#endif
BATaccessBegin(bn,USE_HEAD|USE_HHASH|USE_TAIL,BAThordered(b)&BAThordered(e)&1?MMAP_SEQUENTIAL:MMAP_WILLNEED);
if (b_use)
BATaccessBegin(b,b_use,MMAP_SEQUENTIAL);
@@ -133,11 +143,13 @@ All Rights Reserved.
}
if (b_use)
BATaccessEnd(b,b_use,MMAP_SEQUENTIAL);
- if (!(@1 && sums))
+#if @1
+ if (!sums)
+#endif
BATaccessEnd(bn,USE_HEAD|USE_HHASH|USE_TAIL,BAThordered(b)&BAThordered(e)&1?MMAP_SEQUENTIAL:MMAP_WILLNEED);
/* postprocess by dividing sums by counts */
- if (@1) {
- if (sums) {
+#if @1
+ if (sums) {
/* sums in sums-array */
BATaccessBegin(bn,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
BATloop(bn, p, q) {
@@ -151,8 +163,9 @@ All Rights Reserved.
}
BATaccessEnd(bn,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
GDKfree(sums);
- }
- } else {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list