From 74011541dc026a1d5d7fa4349eb34f6b9b32f542 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 16 Mar 2012 16:47:23 +0000 Subject: [PATCH] force -Wall to encourage cleaner coding... --- CMakeLists.txt | 7 +++ Common/GmshSocket.h | 2 +- Common/onelab.h | 1 + Fltk/fileDialogs.cpp | 80 ++++++++++++++-------------- Fltk/onelabWindow.cpp | 14 ++--- Post/PViewFactory.cpp | 4 +- Post/PViewFactory.h | 5 +- contrib/mmg3d/build/sources/memory.h | 27 +++++----- 8 files changed, 75 insertions(+), 65 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec6529dd6e..19e4d89942 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1053,6 +1053,13 @@ elseif(MSVC) set_target_properties(gmsh PROPERTIES LINK_FLAGS "/STACK:16777216") endif(WIN32 AND NOT MSVC OR CYGWIN) +# force full warnings to encourage everybody to write clean(er) code +include(CheckCxxCompilerFlag) +check_cxx_compiler_flag("-Wall" WALL) +if(WALL) + set_target_properties(gmsh lib shared PROPERTIES COMPILE_FLAGS "-Wall") +endif(WALL) + find_program(BISON bison) find_program(FLEX flex) if(BISON AND FLEX) diff --git a/Common/GmshSocket.h b/Common/GmshSocket.h index 9cf007fa6a..82f56e9eb4 100644 --- a/Common/GmshSocket.h +++ b/Common/GmshSocket.h @@ -376,7 +376,7 @@ class GmshServer : public GmshSocket{ } if(!_portno){ // retrieve name if randomly assigned port socklen_t addrlen = sizeof(addr_in); - int rc = getsockname(tmpsock, (struct sockaddr *)&addr_in, &addrlen); + getsockname(tmpsock, (struct sockaddr *)&addr_in, &addrlen); _portno = ntohs(addr_in.sin_port); int pos = _sockname.find(':'); // remove trailing ' ' or '0' char tmp[256]; diff --git a/Common/onelab.h b/Common/onelab.h index ea4c3bbe6f..c2da22c1cf 100644 --- a/Common/onelab.h +++ b/Common/onelab.h @@ -584,6 +584,7 @@ namespace onelab{ for(std::set<parameter*>::iterator it = ps.begin(); it != ps.end(); it++) if(client.empty() || (*it)->hasClient(client)) (*it)->setChanged(changed); + return true; } // serialize the parameter space (optinally only serialize those parameters // that depend on the given client) diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index ea7cc22588..f4b145f793 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -55,9 +55,9 @@ class flFileChooser : public Fl_File_Chooser { Fl_File_Input *_in; public: flFileChooser(const char *d, const char *p, int t, const char *title) - : Fl_File_Chooser(d, p, t, title) - { - _win = dynamic_cast<Fl_Window*>(newButton->parent()->parent()); + : Fl_File_Chooser(d, p, t, title) + { + _win = dynamic_cast<Fl_Window*>(newButton->parent()->parent()); _in = dynamic_cast<Fl_File_Input *>(previewButton->parent()->parent()->resizable()); } void show() @@ -95,7 +95,7 @@ int fileChooser(FILE_CHOOSER_TYPE type, const char *message, #if defined(HAVE_NATIVE_FILE_CHOOSER) if(!fc) fc = new Fl_Native_File_Chooser(); switch(type){ - case FILE_CHOOSER_MULTI: + case FILE_CHOOSER_MULTI: fc->type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE); break; case FILE_CHOOSER_CREATE: fc->type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE); break; @@ -123,13 +123,13 @@ int fileChooser(FILE_CHOOSER_TYPE type, const char *message, Fl_File_Chooser::show_label = "Format:"; Fl_File_Chooser::all_files_label = "All files (*)"; if(!fc) { - fc = new flFileChooser(getenv("PWD") ? "." : CTX::instance()->homeDir.c_str(), + fc = new flFileChooser(getenv("PWD") ? "." : CTX::instance()->homeDir.c_str(), thefilter, Fl_File_Chooser::SINGLE, message); - fc->position(CTX::instance()->fileChooserPosition[0], + fc->position(CTX::instance()->fileChooserPosition[0], CTX::instance()->fileChooserPosition[1]); } switch(type){ - case FILE_CHOOSER_MULTI: + case FILE_CHOOSER_MULTI: fc->type(Fl_File_Chooser::MULTI); break; case FILE_CHOOSER_CREATE: fc->type(Fl_File_Chooser::CREATE); break; @@ -208,7 +208,7 @@ int genericBitmapFileDialog(const char *name, const char *title, int format) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->window->label(title); dialog->b[0]->value(CTX::instance()->print.text); dialog->b[1]->value(CTX::instance()->print.background); @@ -247,7 +247,7 @@ int latexFileDialog(const char *name) Fl_Button *ok, *cancel; }; static _latexFileDialog *dialog = NULL; - + if(!dialog){ dialog = new _latexFileDialog; int h = 3 * WB + 2 * BH, w = 2 * BB + 3 * WB, y = WB; @@ -262,7 +262,7 @@ int latexFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->b->value(CTX::instance()->print.texAsEquation); dialog->window->show(); @@ -330,7 +330,7 @@ int jpegFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->s[0]->value(CTX::instance()->print.jpegQuality); dialog->s[1]->value(CTX::instance()->print.jpegSmoothing); dialog->b[0]->value(CTX::instance()->print.text); @@ -405,7 +405,7 @@ int mpegFileDialog(const char *name) dialog->v[1]->maximum(100); dialog->v[1]->step(1); dialog->v[1]->align(FL_ALIGN_RIGHT); - + dialog->c[0] = new Fl_Check_Button (WB, y, 2 * BB + WB, BH, "Print background"); y += BH; dialog->c[0]->type(FL_TOGGLE_BUTTON); @@ -423,7 +423,7 @@ int mpegFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->b[0]->value(!CTX::instance()->post.animCycle); dialog->b[1]->value(CTX::instance()->post.animCycle); dialog->v[0]->value(CTX::instance()->post.animDelay); @@ -497,7 +497,7 @@ int gifFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->b[0]->value(CTX::instance()->print.gifDither); dialog->b[1]->value(CTX::instance()->print.gifInterlace); dialog->b[2]->value(CTX::instance()->print.gifSort); @@ -544,25 +544,25 @@ static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5 #endif switch(quality){ case 0: // raster - b[1]->deactivate(); - b[2]->deactivate(); - b[3]->deactivate(); + b[1]->deactivate(); + b[2]->deactivate(); + b[3]->deactivate(); b[4]->deactivate(); break; case 1: // simple sort case 3: // unsorted - b[1]->activate(); + b[1]->activate(); b[2]->activate(); - b[3]->deactivate(); + b[3]->deactivate(); if(format == FORMAT_PDF || format == FORMAT_SVG) b[4]->deactivate(); else b[4]->activate(); break; case 2: // bsp sort - b[1]->activate(); + b[1]->activate(); b[2]->activate(); - b[3]->activate(); + b[3]->activate(); if(format == FORMAT_PDF || format == FORMAT_SVG) b[4]->deactivate(); else @@ -618,7 +618,7 @@ int gl2psFileDialog(const char *name, const char *title, int format) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->window->label(title); dialog->c->value(CTX::instance()->print.epsQuality); dialog->b[0]->value(CTX::instance()->print.epsCompress); @@ -692,7 +692,7 @@ int optionsFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->window->show(); while(dialog->window->shown()){ @@ -741,7 +741,7 @@ int geoFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->b->value(CTX::instance()->print.geoLabels ? 1 : 0); dialog->window->show(); @@ -803,7 +803,7 @@ int meshStatFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->b[0]->value(CTX::instance()->mesh.saveAll ? 1 : 0); dialog->b[1]->value(CTX::instance()->print.posElementary ? 1 : 0); dialog->b[2]->value(CTX::instance()->print.posElement ? 1 : 0); @@ -883,8 +883,8 @@ int mshFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - - dialog->c->value((CTX::instance()->mesh.mshFileVersion == 1.0) ? 0 : + + dialog->c->value((CTX::instance()->mesh.mshFileVersion == 1.0) ? 0 : CTX::instance()->mesh.binary ? 2 : 1); dialog->b[0]->value(CTX::instance()->mesh.saveAll ? 1 : 0); dialog->b[1]->value(CTX::instance()->mesh.saveParametric ? 1 : 0); @@ -897,7 +897,7 @@ int mshFileDialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - opt_mesh_msh_file_version(0, GMSH_SET | GMSH_GUI, + opt_mesh_msh_file_version(0, GMSH_SET | GMSH_GUI, (dialog->c->value() == 0) ? 1.0 : 2.2); opt_mesh_binary(0, GMSH_SET | GMSH_GUI, (dialog->c->value() == 2) ? 1 : 0); opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); @@ -946,7 +946,7 @@ int unvFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->b[0]->value(CTX::instance()->mesh.saveAll ? 1 : 0); dialog->b[1]->value(CTX::instance()->mesh.saveGroupsOfNodes ? 1 : 0); dialog->window->show(); @@ -958,7 +958,7 @@ int unvFileDialog(const char *name) if (!o) break; if (o == dialog->ok) { opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b[0]->value() ? 1 : 0); - opt_mesh_save_groups_of_nodes(0, GMSH_SET | GMSH_GUI, + opt_mesh_save_groups_of_nodes(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value() ? 1 : 0); CreateOutputFile(name, FORMAT_UNV); dialog->window->hide(); @@ -998,7 +998,7 @@ int bdfFileDialog(const char *name) {"Partition", 0, 0, 0}, {0} }; - + int BBB = BB + 16; // labels too long if(!dialog){ @@ -1021,7 +1021,7 @@ int bdfFileDialog(const char *name) dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->c->value(CTX::instance()->mesh.bdfFieldFormat); dialog->d->value((CTX::instance()->mesh.saveElementTagType == 3) ? 2 : (CTX::instance()->mesh.saveElementTagType == 2) ? 1 : 0); @@ -1035,7 +1035,7 @@ int bdfFileDialog(const char *name) if (!o) break; if (o == dialog->ok) { opt_mesh_bdf_field_format(0, GMSH_SET | GMSH_GUI, dialog->c->value()); - opt_mesh_save_element_tag_type(0, GMSH_SET | GMSH_GUI, + opt_mesh_save_element_tag_type(0, GMSH_SET | GMSH_GUI, dialog->d->value() + 1); opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); CreateOutputFile(name, FORMAT_BDF); @@ -1099,7 +1099,7 @@ int genericMeshFileDialog(const char *name, const char *title, int format, dialog->window->end(); dialog->window->hotspot(dialog->window); } - + dialog->window->label(title); dialog->c->value(CTX::instance()->mesh.binary ? 1 : 0); if(binary_support) @@ -1122,7 +1122,7 @@ int genericMeshFileDialog(const char *name, const char *title, int format, if (!o) break; if (o == dialog->ok) { opt_mesh_binary(0, GMSH_SET | GMSH_GUI, dialog->c->value()); - opt_mesh_save_element_tag_type(0, GMSH_SET | GMSH_GUI, + opt_mesh_save_element_tag_type(0, GMSH_SET | GMSH_GUI, dialog->d->value() + 1); opt_mesh_save_all(0, GMSH_SET | GMSH_GUI, dialog->b->value() ? 1 : 0); CreateOutputFile(name, format); @@ -1147,7 +1147,7 @@ static void _saveViews(const std::string &name, int which, int format, bool canA } else if(which == 0){ int iview = FlGui::instance()->options->view.index; - if(iview < 0 || iview >= PView::list.size()){ + if(iview < 0 || iview >= (int)PView::list.size()){ Msg::Info("No or invalid current view: saving View[0]"); iview = 0; } @@ -1423,7 +1423,7 @@ void cgnsw_write_dummy_bc_cb(Fl_Widget *widget, void *data) dlg->checkButtonWriteNormals->deactivate(); dlg->roundButton0NormalGeo->deactivate(); dlg->roundButton1NormalElem->deactivate(); - } + } } void cgnsw_bc_location_cb(Fl_Widget *widget, void *data) @@ -1455,7 +1455,7 @@ void cgnsw_write_normals_cb(Fl_Widget *widget, void *data) else { dlg->roundButton0NormalGeo->deactivate(); dlg->roundButton1NormalElem->deactivate(); - } + } } void cgnsw_normal_source_cb(Fl_Widget *widget, void *data) @@ -1509,7 +1509,7 @@ int cgnsFileDialog(const char *filename) {"Physical", 0, 0, 0}, {0} }; - + static Fl_Menu_Item vectorDimMenu[] = { {"2", 0, 0, 0}, {"3", 0, 0, 0}, @@ -1657,7 +1657,7 @@ int cgnsFileDialog(const char *filename) &dlg); dlg.checkButtonWriteNormals->align(FL_ALIGN_RIGHT); yr += BH; - + // Normal source { const int GH = 2*RBH + WB; diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index a9dc741ffd..b03af6f7ff 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -90,11 +90,11 @@ static void mergePostProcessingFile(const std::string &fileName) { if(!FlGui::instance()->onelab->mergeAuto()) return; - int n = PView::list.size(); + unsigned int n = PView::list.size(); // store old step values std::vector<int> steps(n, 0); if(FlGui::instance()->onelab->showLastStep()){ - for(int i = 0; i < PView::list.size(); i++) + for(unsigned int i = 0; i < PView::list.size(); i++) steps[i] = (int)opt_view_nb_timestep(i, GMSH_GET, 0); } @@ -135,7 +135,7 @@ static void mergePostProcessingFile(const std::string &fileName) // hide everything except the onelab X-Y graphs if(FlGui::instance()->onelab->hideNewViews()){ - for(int i = 0; i < PView::list.size(); i++){ + for(unsigned int i = 0; i < PView::list.size(); i++){ if(PView::list[i]->getData()->getFileName().substr(0, 6) != "OneLab") PView::list[i]->getOptions()->visible = 0; } @@ -143,7 +143,7 @@ static void mergePostProcessingFile(const std::string &fileName) else if(n != PView::list.size()){ // if we created new views, assume we only want to see those (and the // onelab X-Y graphs) - for(int i = 0; i < n; i++){ + for(unsigned int i = 0; i < n; i++){ if(PView::list[i]->getData()->getFileName().substr(0, 6) != "OneLab") PView::list[i]->getOptions()->visible = 0; } @@ -152,7 +152,7 @@ static void mergePostProcessingFile(const std::string &fileName) // if we added steps, go to the last one if(FlGui::instance()->onelab->showLastStep()){ steps.resize(PView::list.size(), 0); - for(int i = 0; i < PView::list.size(); i++){ + for(unsigned int i = 0; i < PView::list.size(); i++){ int step = (int)opt_view_nb_timestep(i, GMSH_GET, 0); if(step > steps[i]) opt_view_timestep(i, GMSH_SET|GMSH_GUI, step - 1); @@ -160,7 +160,7 @@ static void mergePostProcessingFile(const std::string &fileName) } drawContext::global()->draw(); - if(n != (int)PView::list.size()) + if(n != PView::list.size()) FlGui::instance()->menu->setContext(menu_post, 0); } @@ -1199,7 +1199,7 @@ void onelabWindow::rebuildSolverList() hosts.push_back(opt_solver_remote_login(i, GMSH_GET, "")); } } - for(int i = 0; i < 5; i++){ + for(unsigned int i = 0; i < 5; i++){ if(i < names.size()){ onelab::server::citer it = onelab::server::instance()->findClient(names[i]); if(it != onelab::server::instance()->lastClient()) diff --git a/Post/PViewFactory.cpp b/Post/PViewFactory.cpp index 42ae9495e0..6fedf92945 100644 --- a/Post/PViewFactory.cpp +++ b/Post/PViewFactory.cpp @@ -11,11 +11,11 @@ PViewFactory::PViewFactory (std::string name, std::string type, GModel *model, int timeStep, int dim) - : _model(model), _name(name), _type(type), _timeStep(timeStep), _dim(dim) + : _name(name), _type(type), _dim(dim), _timeStep(timeStep), _model(model) { } -void PViewFactory::setEntry (int id, const fullMatrix<double> &val) +void PViewFactory::setEntry (int id, const fullMatrix<double> &val) { std::vector<double> &vv = _values[id]; vv.resize(val.size1()*val.size2()); diff --git a/Post/PViewFactory.h b/Post/PViewFactory.h index 8f53fc73c9..5a0a520e84 100644 --- a/Post/PViewFactory.h +++ b/Post/PViewFactory.h @@ -20,10 +20,11 @@ template <class t> class fullMatrix; class PViewFactory { std::map<int,std::vector<double> > _values; std::string _name, _type; - int _dim,_timeStep; + int _dim, _timeStep; GModel *_model; public: - PViewFactory(std::string name, std::string type, GModel *model, int timeStep, int dim=3); + PViewFactory(std::string name, std::string type, GModel *model, int timeStep, + int dim=3); void setEntry(int id, const fullMatrix<double> &val); PView *createView(); }; diff --git a/contrib/mmg3d/build/sources/memory.h b/contrib/mmg3d/build/sources/memory.h index dc85346434..c804eb8708 100644 --- a/contrib/mmg3d/build/sources/memory.h +++ b/contrib/mmg3d/build/sources/memory.h @@ -3,32 +3,33 @@ Logiciel initial: MMG3D Version 4.0 Co-auteurs : Cecile Dobrzynski et Pascal Frey. Propriétaires :IPB - UPMC -INRIA. -Copyright © 2004-2005-2006-2007-2008-2009-2010-2011, +Copyright © 2004-2005-2006-2007-2008-2009-2010-2011, diffusé sous les termes et conditions de la licence publique générale de GNU -Version 3 ou toute version ultérieure. +Version 3 ou toute version ultérieure. Ce fichier est une partie de MMG3D. MMG3D est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier suivant les termes de la licence publique générale de GNU Version 3 ou toute version ultérieure. -MMG3D est distribué dans l'espoir qu'il sera utile, mais SANS -AUCUNE GARANTIE ; sans même garantie de valeur marchande. +MMG3D est distribué dans l'espoir qu'il sera utile, mais SANS +AUCUNE GARANTIE ; sans même garantie de valeur marchande. Voir la licence publique générale de GNU pour plus de détails. -MMG3D est diffusé en espérant qu’il sera utile, -mais SANS AUCUNE GARANTIE, ni explicite ni implicite, -y compris les garanties de commercialisation ou -d’adaptation dans un but spécifique. +MMG3D est diffusé en espérant qu’il sera utile, +mais SANS AUCUNE GARANTIE, ni explicite ni implicite, +y compris les garanties de commercialisation ou +d’adaptation dans un but spécifique. Reportez-vous à la licence publique générale de GNU pour plus de détails. -Vous devez avoir reçu une copie de la licence publique générale de GNU -en même temps que ce document. +Vous devez avoir reçu une copie de la licence publique générale de GNU +en même temps que ce document. Si ce n’est pas le cas, aller voir <http://www.gnu.org/licenses/>. +****************************************************************************/ /**************************************************************************** Initial software: MMG3D Version 4.0 Co-authors: Cecile Dobrzynski et Pascal Frey. Owners: IPB - UPMC -INRIA. -Copyright © 2004-2005-2006-2007-2008-2009-2010-2011, -spread under the terms and conditions of the license GNU General Public License +Copyright © 2004-2005-2006-2007-2008-2009-2010-2011, +spread under the terms and conditions of the license GNU General Public License as published Version 3, or (at your option) any later version. This file is part of MMG3D @@ -41,7 +42,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with MMG3D. If not, see <http://www.gnu.org/licenses/>. +along with MMG3D. If not, see <http://www.gnu.org/licenses/>. ****************************************************************************/ #ifdef __cplusplus extern "C" { -- GitLab