From 92444017280fe1ed0c11ea71adae86c5c7388d85 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (office)" <j.wuttke@fz-juelich.de> Date: Fri, 19 Mar 2010 16:53:57 +0100 Subject: [PATCH] cleanup, according to warnings --- pub/Makefile.in | 1 + pub/configure | 43 ++++++++++++++++++---------------- pub/configure.ac | 3 ++- pub/src/Makefile.am | 22 ++++++++--------- pub/src/Makefile.in | 23 +++++++++--------- pub/src/curve.cpp | 2 +- pub/src/dualplot.cpp | 8 +++---- pub/src/edif.cpp | 56 ++++++++++++++++++++++++-------------------- pub/src/file_in.cpp | 4 ++-- pub/src/func.h | 8 +++---- pub/src/manip.cpp | 5 ++-- pub/src/mystd.cpp | 2 +- 12 files changed, 95 insertions(+), 82 deletions(-) diff --git a/pub/Makefile.in b/pub/Makefile.in index 2c8b3271..3ea85587 100644 --- a/pub/Makefile.in +++ b/pub/Makefile.in @@ -110,6 +110,7 @@ distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ +AM_CXXFLAGS = @AM_CXXFLAGS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ diff --git a/pub/configure b/pub/configure index de00e0cc..e2b0cbe7 100755 --- a/pub/configure +++ b/pub/configure @@ -810,6 +810,7 @@ build_vendor build_cpu build LIBTOOL +AM_CXXFLAGS am__untar am__tar AMTAR @@ -3161,6 +3162,8 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' +AM_CXXFLAGS="-pedantic -Wall" + # produce config.h to avoid endless -D options # source files may #include "../config.h", should the -D settings ever be used @@ -4831,13 +4834,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4834: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4837: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4837: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4840: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4840: output\"" >&5) + (eval echo "\"\$as_me:4843: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6043,7 +6046,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6046 "configure"' > conftest.$ac_ext + echo '#line 6049 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7573,11 +7576,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7576: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7579: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7580: \$? = $ac_status" >&5 + echo "$as_me:7583: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7912,11 +7915,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7915: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7918: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7919: \$? = $ac_status" >&5 + echo "$as_me:7922: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8017,11 +8020,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8020: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8023: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8024: \$? = $ac_status" >&5 + echo "$as_me:8027: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8072,11 +8075,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8075: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8078: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8079: \$? = $ac_status" >&5 + echo "$as_me:8082: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10456,7 +10459,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10459 "configure" +#line 10462 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10552,7 +10555,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10555 "configure" +#line 10558 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13439,11 +13442,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13442: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13445: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13446: \$? = $ac_status" >&5 + echo "$as_me:13449: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13538,11 +13541,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13541: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13544: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13545: \$? = $ac_status" >&5 + echo "$as_me:13548: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13590,11 +13593,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13593: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13596: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13597: \$? = $ac_status" >&5 + echo "$as_me:13600: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized diff --git a/pub/configure.ac b/pub/configure.ac index 35a48fd4..8c88192e 100644 --- a/pub/configure.ac +++ b/pub/configure.ac @@ -15,7 +15,8 @@ AC_PREREQ(2.65) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/frida2.cpp]) # assure we have the right src dir AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AM_INIT_AUTOMAKE([foreign]) +AC_SUBST(AM_CXXFLAGS,"-pedantic -Wall") # produce config.h to avoid endless -D options # source files may #include "../config.h", should the -D settings ever be used diff --git a/pub/src/Makefile.am b/pub/src/Makefile.am index 72bfa54b..3373bce2 100644 --- a/pub/src/Makefile.am +++ b/pub/src/Makefile.am @@ -1,17 +1,17 @@ BUILT_SOURCES = xax_yacc.h # otherwise we cannot include it into flex AM_YFLAGS = -d -p xax # options passed to yacc AM_LFLAGS = -Pxax -olex.yy.c # options passed to lex -AM_CXXFLAGS = -Wunused - # -Waddress -Warray-bounds -Wc++0x-compat \ - # -Wchar-subscripts -Wcomment -Wformat \ - # -Wmissing-braces -Wparentheses \ - # -Wreorder -Wreturn-type -Wsequence-point \ - # -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch \ - # -Wunknown-pragmas \ - # -Wclobbered -Wempty-body -Wignored-qualifiers \ - # -Wmissing-field-initializers \ - # -Wtype-limits -Wuninitialized \ - # -Wsign-compare -Wuninitialized -Wconversion +AM_CXXFLAGS = -Wunused \ + -Waddress -Warray-bounds -Wc++0x-compat \ + -Wchar-subscripts -Wcomment -Wformat \ + -Wmissing-braces -Wparentheses \ + -Wreorder -Wreturn-type -Wsequence-point \ + -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch \ + -Wunknown-pragmas \ + -Wclobbered -Wempty-body -Wignored-qualifiers \ + -Wmissing-field-initializers \ + -Wtype-limits -Wconversion + # -Wuninitialized -Wsign-compare bin_PROGRAMS = frida2 frida2_SOURCES = \ diff --git a/pub/src/Makefile.in b/pub/src/Makefile.in index 22279bc5..90a6e41b 100644 --- a/pub/src/Makefile.in +++ b/pub/src/Makefile.in @@ -99,6 +99,17 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ +AM_CXXFLAGS = -Wunused \ + -Waddress -Warray-bounds -Wc++0x-compat \ + -Wchar-subscripts -Wcomment -Wformat \ + -Wmissing-braces -Wparentheses \ + -Wreorder -Wreturn-type -Wsequence-point \ + -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch \ + -Wunknown-pragmas \ + -Wclobbered -Wempty-body -Wignored-qualifiers \ + -Wmissing-field-initializers \ + -Wtype-limits -Wconversion + AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -225,7 +236,6 @@ top_srcdir = @top_srcdir@ BUILT_SOURCES = xax_yacc.h # otherwise we cannot include it into flex AM_YFLAGS = -d -p xax # options passed to yacc AM_LFLAGS = -Pxax -olex.yy.c # options passed to lex -AM_CXXFLAGS = -Wunused frida2_SOURCES = \ coord.cpp \ coord.h \ @@ -626,16 +636,7 @@ uninstall-am: uninstall-binPROGRAMS pdf pdf-am ps ps-am tags uninstall uninstall-am \ uninstall-binPROGRAMS - # -Waddress -Warray-bounds -Wc++0x-compat \ - # -Wchar-subscripts -Wcomment -Wformat \ - # -Wmissing-braces -Wparentheses \ - # -Wreorder -Wreturn-type -Wsequence-point \ - # -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch \ - # -Wunknown-pragmas \ - # -Wclobbered -Wempty-body -Wignored-qualifiers \ - # -Wmissing-field-initializers \ - # -Wtype-limits -Wuninitialized \ - # -Wsign-compare -Wuninitialized -Wconversion + # -Wuninitialized -Wsign-compare # frida2_LDADD $(BOOST_REGEX_LIB) # -lyaml-cpp diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp index 1295dd49..428683e1 100644 --- a/pub/src/curve.cpp +++ b/pub/src/curve.cpp @@ -577,7 +577,7 @@ void NCurveFile::Fit( bool _allow_slow_conv ) data.k = fiter.SelNo(); if( !fc->T->has_farg ) throw string( "curve has no formal argument t" ); - if( fc->kd<0 || fc->kd>=NOlm::MOM.size() ) + if( fc->kd>=NOlm::MOM.size() ) throw string( "number of data file out of range" ); if (!(fd=NOlm::MOM[fc->kd].D())) throw string( "is not a data file" ); diff --git a/pub/src/dualplot.cpp b/pub/src/dualplot.cpp index 09e8389b..3af4d865 100644 --- a/pub/src/dualplot.cpp +++ b/pub/src/dualplot.cpp @@ -199,8 +199,8 @@ void CAxis::Ask( string quest ) setAuto(); throw string( "log scale requires range above 0" ); } - if (!logflag && ( inf!=-INFINITY && inf<-3e38 || - sup!=+INFINITY && sup>3e38 ) ) { + if (!logflag && ( ( inf!=-INFINITY && inf<-3e38 ) || + ( sup!=+INFINITY && sup>+3e38 ) ) ) { setAuto(); throw string( "lin scale exceeds typical PS implementation range " "(abs<3e38)" ); @@ -233,7 +233,7 @@ double CAxis::pc( double v ) const //! Constructor for plot window: setup for gnuplot and postscript. CPlot::CPlot( uint _iPlot, bool _logx, bool _logy ) : - iPlot( _iPlot ), maxpoints(12000), X( _logx ), Y( _logy ) + iPlot( _iPlot ), X( _logx ), Y( _logy ), maxpoints(12000) { // Start gnuplot. Use input redirection so that gnuplot receives // commands from a gp_fifo which is created here. @@ -395,7 +395,7 @@ void CPlot::addSpec( bool as_line, int style_no, 0x006666, 0x660066, 0x666600 }; // Checks: uint np=xp.size(); - if ( np<0 ) + if ( !np ) throw string( "PROG ERR NPLot::Line x.size=0" ); if ( np!=yp.size() ) throw string( "PROG ERR NPLot::Line x.size<>y.size" ); diff --git a/pub/src/edif.cpp b/pub/src/edif.cpp index 938a5d03..5cd8f125 100644 --- a/pub/src/edif.cpp +++ b/pub/src/edif.cpp @@ -960,17 +960,21 @@ void NEdif::MakeGrid(void) double NEdif::FindAngleCos(double x1,double y1, //point 1 double x2,double y2, //point 2 double x3,double y3 )//point 3 -{ // (1) ________(2) - // \)cos - // \ - // \(3) - // - // (x1,y1), (x2,y2) - // (x2,y2) and (x3,y3) - // a = x2 - x1, b = y2 - y1 - // c = x3 - x2, d = y3 - y2. - // The so called dot product yields the equation - // Cosine( Theta ) = ( (a x c) + (b x d) )/(Sqrt(a^2 + b^2) x Sqrt(c^2 + d^2) ) = Z. +// Li Huang mar10 +{ + /* + (1) ________(2) + \)cos + \ + \(3) + + (x1,y1), (x2,y2) + (x2,y2) and (x3,y3) + a = x2 - x1, b = y2 - y1 + c = x3 - x2, d = y3 - y2. + The so called dot product yields the equation + Cosine( Theta ) = ( (a x c) + (b x d) )/(Sqrt(a^2 + b^2) x Sqrt(c^2 + d^2) ) = Z. + */ double a,b,c,d,cos; a = x2 - x1; b = y2 - y1; @@ -985,6 +989,7 @@ double NEdif::FindAngleCos(double x1,double y1, //point 1 void NEdif::FindNextPoint( const COlc *fc, double xtm, double ytm, double dx, double* xt, double* yt, uint k, uint j ) +// Li Huang mar10 { uint i = 0; double cos123 = 0; @@ -995,20 +1000,21 @@ void NEdif::FindNextPoint( const COlc *fc, double y2 = *yt; double x3,y3; double x4,y4; - // /)o1__ (3) - // (2)_____________ - // / \)o2 - // / \ - // (1)/ \(4) - // - // (xt,yt)__________(xt+dx,yt+dx) - // / \ - // / \ - // (xtm,ytm)/ \(xt+2*dx,yt+2*dx) - // - // o1 < 1/4 degree && o2 < 1/4 degree - // cos(1/4 degree) = 0.99999 - // + /* + /)o1__ (3) + (2)_____________ + / \)o2 + / \ + (1)/ \(4) + + (xt,yt)__________(xt+dx,yt+dx) + / \ + / \ + (xtm,ytm)/ \(xt+2*dx,yt+2*dx) + + o1 < 1/4 degree && o2 < 1/4 degree + cos(1/4 degree) = 0.99999 + */ do{ x3 = x2 + dx; y3 = fc->T->tree_curve_val_sca( x3, k, j ); diff --git a/pub/src/file_in.cpp b/pub/src/file_in.cpp index 440f98f3..a2e63ba9 100644 --- a/pub/src/file_in.cpp +++ b/pub/src/file_in.cpp @@ -344,7 +344,7 @@ void NFileIn::LoadSpec_01( FILE *F_in, CSpec* sout, int nz ) if ((err=fscanf(F_in, "%4c%u\n", lab, &m))!=2) throw "expecting Z head line, found " + strg(err) + " entries"; if (strncmp(lab, "Z ", 4)) - throw "found [" + strg(lab) + "] in Z head line"; + throw "found [" + string(lab) + "] in Z head line"; if (m!=nz) throw "found " + strg(m) + " Z entries, expecting " + strg(nz); for ( i=0; i<nz; ++i ) { @@ -357,7 +357,7 @@ void NFileIn::LoadSpec_01( FILE *F_in, CSpec* sout, int nz ) if ( (err=fscanf(F_in, "%4c%u\n", lab, &n))!=2 ) throw "expecting XY head line, found " + strg(err) + " entries"; if (strncmp(lab, "XY ", 4) ) - throw "found [" + strg(lab) + "] in XY head line"; + throw "found [" + string(lab) + "] in XY head line"; for (i=0; i<n; i++) { if ((err=fscanf(F_in, "%lg %lg\n", &v, &w))!=2) { diff --git a/pub/src/func.h b/pub/src/func.h index 9aa84315..a0cb7ddd 100644 --- a/pub/src/func.h +++ b/pub/src/func.h @@ -16,13 +16,13 @@ class CFunc { // public (short) interface => TAKE CARE class CCoord coord(class CCoord *co1, class CCoord *co2, class CCoord *co3) const; CFunc( string _s, func_f1 _f1 ) - : s(_s), f1(_f1), narg(1) {}; + : s(_s), narg(1), f1(_f1) {}; CFunc( string _s, func_f2 _f2 ) - : s(_s), f2(_f2), narg(2) {}; + : s(_s), narg(2), f2(_f2) {}; CFunc( string _s, func_f3 _f3 ) - : s(_s), f3(_f3), narg(3) {}; + : s(_s), narg(3), f3(_f3) {}; CFunc( string _s, func_f2tv _f2tv ) - : s(_s), f2tv(_f2tv), narg(2) {}; + : s(_s), narg(2), f2tv(_f2tv) {}; }; namespace NFunctions { // public (short) interface diff --git a/pub/src/manip.cpp b/pub/src/manip.cpp index f4d77fab..72caa1ae 100644 --- a/pub/src/manip.cpp +++ b/pub/src/manip.cpp @@ -97,11 +97,12 @@ void NManip::PtsSelect( string del_or_ret ) Sout.dy.clear(); pLis.evaluate( 0, Sin->size()-1 ); for (uint i=0; i<Sin->size(); i++) { - if ( sel_del ^ pLis.contains(i) ) + if ( sel_del ^ pLis.contains(i) ) { if( Sin->dy.size() ) Sout.push_xyd( Sin->x[i], Sin->y[i], Sin->dy[i] ); else Sout.push_xy( Sin->x[i], Sin->y[i] ); + } } if ( Sout.size() ) fout.VS.push_back( Sout ); @@ -443,7 +444,7 @@ void NManip::PtsGroupWeighted() ytmp[iy].push_back( Sin->y[2+iy] ); if ( j+1==fin->VS.size() || - nz>=2 && fin->VS[j+1].z[nz-2]!=Sin->z[nz-2] ) { + ( nz>=2 && fin->VS[j+1].z[nz-2]!=Sin->z[nz-2] ) ) { // reached end-of-file or end-of-relevant-z-group // sort, group, save, possibly start new spectrum n = xtmp.size(); diff --git a/pub/src/mystd.cpp b/pub/src/mystd.cpp index 5342d34e..817e425b 100644 --- a/pub/src/mystd.cpp +++ b/pub/src/mystd.cpp @@ -505,7 +505,7 @@ FILE* mystd::glob_fopen( const string& text, const string& pre, int mystd::freadln( FILE *fd, string *s ) { - char c = fgetc(fd); + char c = (char) fgetc(fd); if( c==EOF ) return -1; if( c=='\n' ){ -- GitLab