Commit 626b8c85 authored by Mathieu Faverge's avatar Mathieu Faverge

Apply patch 7 from issue #13 - gcc wall

parent d7a891c8
......@@ -46,8 +46,8 @@ MatrixGLWidget::MatrixGLWidget(QWidget* parent, symbol_matrix_t* matrix, QLabel*
#else
QGLWidget(parent)
#endif
, m_label(label)
, m_frameCount(0)
, m_label(label)
{
this->setFixedSize(MATRIX_WINDOW_LENGTH, MATRIX_WINDOW_HEIGHT);
......
......@@ -155,11 +155,11 @@ extern "C" {
void - in all cases.
*/
void memAllocTraceReset ();
};
}
/*
/*
Function: operator new
This is a thread-safe memory allocation routine.
Parameters:
......@@ -173,9 +173,9 @@ extern "C" {
*/
void *operator new(std::size_t size) throw(std::bad_alloc);
/*
/*
Function: operator new[]
This is a thread-safe memory allocation routine.
Parameters:
......
......@@ -95,10 +95,7 @@ bool convert_to_double(const std::string &arg, double *val) {
double clockGet (void)
{
#ifdef _MSC_VER
// TODO
return 0.;
#elif (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac)
#if (defined X_ARCHalpha_compaq_osf1) || (defined X_ARCHi686_mac)
struct rusage data;
getrusage (RUSAGE_SELF, &data);
return (((double) data.ru_utime.tv_sec + (double) data.ru_stime.tv_sec) +
......@@ -110,5 +107,7 @@ double clockGet (void)
clock_gettime (CLOCK_REALTIME, &tp); /* Elapsed time */
return ((double) tp.tv_sec + (double) tp.tv_nsec * (double)1.0e-9L);
#else
return 0.;
#endif
}
......@@ -75,7 +75,7 @@
#include <iostream>
#include "interface/Node_select.hpp"
Q_DECLARE_METATYPE( Container * );
Q_DECLARE_METATYPE( Container * )
using namespace std;
......
......@@ -320,7 +320,6 @@ Settings_tab::update_table_from_palette( const string &pname )
Session &S = Session::getSession();
Palette *p = S.get_palette(_ecname, pname);
map<string, EntityValue*> *ev_list;
map<string, EntityValue*>::const_iterator ev;
int rownbr = content->rowCount();
......@@ -459,9 +458,6 @@ void
Settings_tab::on_btn_cancel_clicked()
{
if (_changed) {
Session &S = Session::getSession();
map<string, EntityValue*> *ev_list;
map<string, EntityValue*>::iterator ev;
std::map<std::string, int>::iterator it;
......
......@@ -67,7 +67,7 @@ class EntityValue;
*/
class Settings_tab : public QWidget {
Q_OBJECT;
Q_OBJECT
public:
QVBoxLayout *background;
......
......@@ -153,6 +153,6 @@ namespace PajeDef {
void print (std::vector<PajeFieldName>* fields, PajeDefinition *def);
std::string print_string (std::vector<PajeFieldName>* fields, PajeDefinition *def);
bool check_definition(PajeDefinition *def);
};
}
#endif // DEFINITION_HPP
......@@ -185,7 +185,7 @@ ParserDefinitionPaje::~ParserDefinitionPaje() {
void ParserDefinitionPaje::enter_definition(const PajeLine_t *line){
PajeDefinition def;
int evtdefid, trid;
int trid;
char *defname = line->_tokens[2];
char *tridstr = line->_tokens[3];
......
......@@ -208,10 +208,10 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
//max offset for a single line
long max_offset=_offset+_pageSize;
for(i = _offset; (i < max_offset) && (i < _filesize) && ((c != '\n') && (c != '\0')) && (itks < _PAJE_NBMAXTKS); i++) {
c = _line[i];
switch (c) {
// It's the end of the line, we just add the end caractere
// for the last token and increase the counter
......@@ -245,19 +245,19 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
while ((i < _filesize) && (i < max_offset-1 ) && (_line[i] != '\'')) {
i++;
}
// If i is too big, we have an error
if ( !(i < max_offset -1) ) {
throw "overflow";
return -1;
}
if((i==_filesize)){
if(i==_filesize){
_eof=true;
throw "Overflow";
return -1;
}
// We finish the token by replacing the \' by \0
_line[i] = '\0';
itks++;
......@@ -280,19 +280,19 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
while ((i < _filesize) && (i < max_offset-1 ) && (_line[i] != '"')) {
i++;
}
// If i is too big, we have an error
if ( !(i < max_offset)) {
throw "Overflow";
return -1;
}
if((i==_filesize)){
if(i==_filesize){
_eof=true;
throw "Overflow";
return -1;
}
// We finish the token by replacing the " by \0
_line[i] = '\0';
itks++;
......@@ -303,19 +303,19 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
case '\t' :
{
// Skip all spaces
while ( (i<_filesize) && (i < max_offset-1 ) &&
while ( (i<_filesize) && (i < max_offset-1 ) &&
((_line[i] == ' ') || (_line[i] == '\t')) ) {
_line[i] = '\0';
i++;
}
if((i==_filesize)){
if(i==_filesize){
_eof=true;
throw "Overflow";
return -1;
}
// We store a new token if it's a new space
if (_tokens[itks][0] != '\0')
if (_tokens[itks][0] != '\0')
itks++;
_tokens[itks] = &_line[i];
i--;
......@@ -325,13 +325,12 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
break;
}
}
if(itks==0){
i+=sizeof(char); //we read one char but no token : empty line, advance the offset of one char, in order not to loop
}
_offset=i;
// We remove the last token if it is empty
if ((itks > 0) && (_tokens[itks-1][0] == '\0'))
itks--;
......@@ -341,7 +340,6 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
lineptr->_nbtks = _nbtks;
lineptr->_tokens = _tokens;
#ifdef WIN32
if (_filesize>MAX_SIZE_UNCUT){
......@@ -349,9 +347,9 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
if(_global_offset+_offset>=_filesize)_eof=true;
else{
if(_offset+_pageSize>=MAX_SIZE_UNCUT){ //time to mmap another part of the file, else we might miss a line
_global_offset+=_offset;
DWORD high_offset=(_global_offset/ULONG_MAX);
//to align correctly
......@@ -359,11 +357,11 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
DWORD low_aligned_offset=(low_offset/_pageSize)*_pageSize;
_offset=low_offset % _pageSize;
_global_offset=high_offset*((ULONGLONG)(ULONG_MAX)+1) + low_aligned_offset;
_current_chunk++;
if (_global_offset+MAX_SIZE_UNCUT>=_filesize) _mapped_size= _filesize-_global_offset;
else _mapped_size=MAX_SIZE_UNCUT;
//munmap(_line, MAX_SIZE_UNCUT);
//printf("mmaping %d bytes for chunk %d\n",_mapped_size, _current_chunk);
_old_line=_line;
......@@ -375,8 +373,8 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
//printf("mmaping failed %d %d %llu %lu %lu %lu\n",_mapped_size, _current_chunk, _global_offset, d, (DWORD)( _global_offset/ULONG_MAX), (DWORD) (_global_offset%ULONG_MAX));
Error::set(Error::VITE_ERR_OPEN, 0, Error::VITE_ERRCODE_ERROR);
throw "Fail to open file";
}
}
}
}
}else if(_offset>=_filesize){
......@@ -389,36 +387,36 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
if(_global_offset+_offset>=_filesize)_eof=true;
else{
if(_offset+_pageSize>=MAX_SIZE_UNCUT){ //time to mmap another part of the file, else we might miss a line
_global_offset+=_offset;
_offset=_global_offset % getpagesize();
_global_offset=(_global_offset/getpagesize())*getpagesize();
_current_chunk++;
if (_global_offset+MAX_SIZE_UNCUT>=_filesize) _mapped_size= _filesize-_global_offset;
else _mapped_size=MAX_SIZE_UNCUT;
//munmap(_line, MAX_SIZE_UNCUT);
//printf("mmaping %d bytes for chunk %d\n",_mapped_size, _current_chunk);
_old_line=_line;
_eoc=true;// we finished a chunk
_line = (char*)mmap(0, _mapped_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(_fd),_global_offset); // Mapping of the file
madvise(_line, _mapped_size , MADV_SEQUENTIAL);//advise kernel that we want to read sequentially in the file
if ((char*)-1 == _line)
{
//printf("mmaping failed\n",_mapped_size, _current_chunk);
if(_fd)fclose(_fd); // Close it if wrong
Error::set(Error::VITE_ERR_OPEN, 0, Error::VITE_ERRCODE_ERROR);
throw "Fail to open file";
}
}
}
}
}else if(_offset>=_filesize){
_eof=true;
}
#endif
return _lineid;
}
......@@ -426,7 +424,7 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
bool mt_PajeFileManager::eoc(){return _eoc;}
void mt_PajeFileManager::close_old_chunk(){
if(_old_line!=NULL){
#ifndef WIN32
munmap(_old_line, MAX_SIZE_UNCUT);
......
......@@ -459,12 +459,7 @@ public:
inline void end_draw()
{
std::ostringstream buf_txt;
Element_pos graduation_diff;
//Element_pos coeff_prefix;
const Element_pos offset_x = 0;
const Element_pos offset_y = 0;
graduation_diff = Ruler::get_graduation_diff(Info::Render::_x_min_visible, Info::Render::_x_max_visible);
/* Now, draw ruler */
/*Rendering is done in paintGL because we need to recalculate graduations each time paintGL is called, not just when launching the program*/
......
......@@ -90,7 +90,6 @@ using namespace std;
extern "C" {
void checkGlError(){
int rc = glGetError();
assert(rc == GL_NO_ERROR );
}
}
......@@ -119,15 +118,15 @@ static bool _draw_counter;
Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat& format)
: Hook_event(this, core, parent, format),
_glsl(0),
_container_height(_DRAWING_CONTAINER_HEIGHT_DEFAULT),
_modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)),
_containers(nullptr),
_counters(nullptr),
_arrows3(nullptr),
_counters(nullptr),
_ruler(nullptr),
_wait(nullptr),
_selection(nullptr),
_time_line(nullptr),
_modelview(glm::mat4(1.0)), _projection(glm::mat4(1.0)),
_container_height(_DRAWING_CONTAINER_HEIGHT_DEFAULT)
_time_line(nullptr)
{
_texts.clear();
_variable_texts.clear();
......@@ -816,7 +815,6 @@ void Render_alternate::call_ruler(){
Element_pos graduation_diff;
//Element_pos coeff_prefix;
const Element_pos offset_x = _default_entity_x_translate;
const Element_pos offset_y = _ruler_y + _ruler_height+3.5;
update_visible_interval_value();
......@@ -1430,7 +1428,7 @@ void Render_alternate::reload_links(){
it->first->reload_file_color();
it->first->set_visible(true);
it->second.first->delete_shader();
Shader* s = s = new Shader(_glsl, it->first->get_used_color()->get_red(),
Shader* s = new Shader(_glsl, it->first->get_used_color()->get_red(),
it->first->get_used_color()->get_green(),
it->first->get_used_color()->get_blue(),
false);
......@@ -1449,7 +1447,7 @@ void Render_alternate::reload_events(){
it->first->reload_file_color();
it->first->set_visible(true);
it->second.first->delete_shader();
Shader* s = s = new Shader(_glsl, it->first->get_used_color()->get_red(),
Shader* s = new Shader(_glsl, it->first->get_used_color()->get_red(),
it->first->get_used_color()->get_green(),
it->first->get_used_color()->get_blue(),
false);
......
......@@ -177,13 +177,12 @@ double Ruler::get_variable_part(const Element_pos n, const Element_pos coeff_for
if ( floor(common_part_without_coeff) != 0. )/* and there is numbers before comma */
return common_part_without_coeff;
else
else
return common_part;
}
string Ruler::get_common_part_string(const Element_pos n, Element_pos coeff_for_common_prefix){
int i;
double common_part;
Element_pos buf;
ostringstream buf_txt, result_txt;
......@@ -220,7 +219,7 @@ string Ruler::get_common_part_string(const Element_pos n, Element_pos coeff_for_
buf *= 10;
}
for (i=0 ; common_part > 0 ; common_part = floor(common_part/10.)){
for (; common_part > 0 ; common_part = floor(common_part/10.)){
buf_txt << ((int)common_part)%10;
......
......@@ -105,7 +105,7 @@ Container::Container(Name name,
template <class T>
void MyDelete(T *ptr){
delete ptr;
};
}
Container::~Container()
{
......
......@@ -391,12 +391,9 @@ public:
Variable *var;
const std::list<std::pair<Date, Double> > *variable_values;
Element_pos position;
const Color *color;
std::map<std::string, Value *>::const_iterator field;
Element_pos lvl_zoom;
color = nullptr;
if(zoom>=0)
lvl_zoom = zoom;
else
......
......@@ -60,7 +60,6 @@ EntityValue::EntityValue(const Name &name, EntityType *type, map<std::string, Va
{
Palette *sp = nullptr;
Color *color = nullptr;
Color *new_color;
std::string palette_name = "default";
// Search opt field for color to set the default (random if not provided within the trace file)
......
......@@ -342,10 +342,10 @@ bool IntervalOfContainer::add_link(Date start, Date end, LinkType *type, Contain
QT_TRY {
oa << *this;
}
QT_CATCH(eos::portable_archive_exception e) {
QT_CATCH(const eos::portable_archive_exception &e) {
printf("fail while dumping serialized file ! %s %s\n", e.what(), filename);
return false;
}QT_CATCH(exception e) {
}QT_CATCH(const exception &e) {
printf("fail while dumping serialized file ! %s %s\n", e.what(), filename);
return false;
......
......@@ -45,7 +45,7 @@ using namespace boost::serialization;
l.set_correct(t);
}
BOOST_SERIALIZATION_ASSUME_ABSTRACT(Value);//this type can be inherited by other serialized classes*/
BOOST_SERIALIZATION_ASSUME_ABSTRACT(Value) //this type can be inherited by other serialized classes*/
//telle the compiler not to be stupid when serializing these objects
......
......@@ -114,7 +114,7 @@ Trace::Trace(): _max_date(0.0) {
template <class T>
void MyDelete(T *ptr){
delete ptr;
};
}
Trace::~Trace()
......@@ -982,6 +982,9 @@ Trace::get_all_entityvalues(const string &type)
else if (type == "link_types") {
return get_all_entityvalues( _EntityClass_Link );
}
assert( 0 );
return nullptr;
}
bool Trace::load_config_from_xml(const QString &filename){
......
......@@ -87,12 +87,10 @@ const double Variable::get_value_at(double d) const {
list<pair<Date, Double> >::const_iterator it= _values.begin();
const list<pair<Date, Double> >::const_iterator it_end= _values.end();
if(it==it_end)return 0.0;
const Date* previous=&((*it).first);
const Double * val = &((*it).second);
it++;
while ((it!=it_end)){
if(((*it).first.get_value())>d)break;
previous=&((*it).first);
val = &((*it).second);
it++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment