add -Wpointer-arith -Wcast-qual -Wcast-align and others to compile flags, and fix...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 10 Aug 2012 15:57:09 +0000 (15:57 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 10 Aug 2012 15:57:09 +0000 (15:57 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13124 d708f5d6-7413-0410-9779-e7cbd77b26cf

16 files changed:
gtk2_ardour/ardour_ui.cc
gtk2_ardour/editor.cc
gtk2_ardour/lv2_plugin_ui.cc
gtk2_ardour/utils.cc
libs/ardour/audio_library.cc
libs/ardour/midi_source.cc
libs/ardour/plugin_manager.cc
libs/ardour/route.cc
libs/ardour/smf_source.cc
libs/ardour/sndfilesource.cc
libs/gtkmm2ext/gtkmm2ext/gtk_ui.h
libs/pbd/locale_guard.cc
libs/pbd/pbd/xml++.h
libs/pbd/xml++.cc
tools/sanity_check/systemtest.cpp
wscript

index 3164467a83eedcd8c031b9322362b3d923e51993..6968c6b78af7238958f22f774fe2b028a9809bbe 100644 (file)
@@ -1957,7 +1957,7 @@ JACK, reconnect and save the session."), PROGRAM_NAME);
        msg.run ();
 
        if (free_reason) {
-               free ((char*) reason);
+               free (const_cast<char*> (reason));
        }
 }
 
index fc857047813aa9f7ea42c7ee0124c380712f5631..5d92ccb08e63dd3259becad06297e1eefa461cd8 100644 (file)
@@ -3112,8 +3112,8 @@ Editor::convert_drop_to_paths (
                const char* q;
 
                p = (const char *) malloc (txt.length() + 1);
-               txt.copy ((char *) p, txt.length(), 0);
-               ((char*)p)[txt.length()] = '\0';
+               txt.copy (const_cast<char *> (p), txt.length(), 0);
+               const_cast<char*>(p)[txt.length()] = '\0';
 
                while (p)
                {
index 7e8f827596f5697e1e7cde797f79168c68821e72..f127256f1b295cfa9200de13b8d9850c1d26c007 100644 (file)
@@ -203,7 +203,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
                _external_ui_feature.URI  = LV2_EXTERNAL_UI_URI;
                _external_ui_feature.data = &_external_ui_host;
 
-               features_src = features = (LV2_Feature**)_lv2->features();
+               features_src = features = const_cast<LV2_Feature**>(_lv2->features());
                features_count = 2;
                while (*features++) {
                        features_count++;
@@ -216,7 +216,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
                        *features++ = *features_src++;
                }
        } else {
-               features_dst = (LV2_Feature**)_lv2->features();
+               features_dst = const_cast<LV2_Feature**>(_lv2->features());
        }
 
        if (!ui_host) {
index 62144ffd6936b67ccb40c8b1f0ab441f6ecfabe6..d383758002f18fc76033617d30ddd6cf3c9c66e1 100644 (file)
@@ -226,13 +226,13 @@ get_font_for_style (string widgetname)
 
        Glib::RefPtr<const Pango::Layout> layout = foobar.get_layout();
 
-       PangoFontDescription *pfd = (PangoFontDescription *)pango_layout_get_font_description((PangoLayout *)layout->gobj());
+       PangoFontDescription *pfd = (PangoFontDescription *)pango_layout_get_font_description(const_cast<PangoLayout *>(layout->gobj()));
 
        if (!pfd) {
 
                /* layout inherited its font description from a PangoContext */
 
-               PangoContext* ctxt = (PangoContext*) pango_layout_get_context ((PangoLayout*) layout->gobj());
+               PangoContext* ctxt = (PangoContext*) pango_layout_get_context (const_cast<PangoLayout*>(layout->gobj()));
                pfd =  pango_context_get_font_description (ctxt);
                return Pango::FontDescription (pfd); /* make a copy */
        }
index 65e8243e5208d5dbe1358e4abf09aaf85811c0cf..c2b2f1bff736c05cbfc70621c4f88d89661dcc60 100644 (file)
@@ -94,7 +94,7 @@ AudioLibrary::get_tags (string member)
 
        lrdf_statement pattern;
        pattern.subject = strdup(Glib::filename_to_uri(member).c_str());
-       pattern.predicate = (char*)TAG;
+       pattern.predicate = const_cast<char*>(TAG);
        pattern.object = 0;
        pattern.object_type = lrdf_literal;
 
@@ -126,8 +126,8 @@ AudioLibrary::search_members_and (vector<string>& members, const vector<string>&
        vector<string>::const_iterator i;
        for (i = tags.begin(); i != tags.end(); ++i){
                pattern = new lrdf_statement;
-               pattern->subject = (char*)"?";
-               pattern->predicate = (char*)TAG;
+               pattern->subject = const_cast<char*>("?");
+               pattern->predicate = const_cast<char*>(TAG);
                pattern->object = strdup((*i).c_str());
                pattern->next = old;
 
index 92795db4aec202d3f25131d6813c3cf750e16442..ff3ff55ced038108305faa219225778b27cf31c4 100644 (file)
@@ -232,7 +232,8 @@ MidiSource::midi_read (Evoral::EventSink<framepos_t>& dst, framepos_t source_sta
                                                                                   _name, time_frames + source_start, i->event_type(), i->size()));
 
                                if (tracker) {
-                                       Evoral::MIDIEvent<Evoral::MusicalTime>& ev (*(Evoral::MIDIEvent<Evoral::MusicalTime>*) (&(*i)));
+                                       Evoral::MIDIEvent<Evoral::MusicalTime>& ev (*(reinterpret_cast<Evoral::MIDIEvent<Evoral::MusicalTime>*> 
+                                                                                     (const_cast<Evoral::Event<Evoral::MusicalTime>*> (&(*i)))));
                                        if (ev.is_note_on()) {
                                                DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("\t%1 track note on %2 @ %3 velocity %4\n", _name, (int) ev.note(), time_frames, (int) ev.velocity()));
                                                tracker->add (ev.note(), ev.channel());
index a4be2096de90dfe1e1e4edc3fb6ed18f44a0c325..a749038d7e0040038b34a8f70c4b8411ef7f6da5 100644 (file)
@@ -452,7 +452,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id)
 
        snprintf(buf, sizeof(buf), "%s%" PRIu32, LADSPA_BASE, plugin_id);
        pattern.subject = buf;
-       pattern.predicate = (char*)RDF_TYPE;
+       pattern.predicate = const_cast<char*>(RDF_TYPE);
        pattern.object = 0;
        pattern.object_type = lrdf_uri;
 
@@ -463,7 +463,7 @@ PluginManager::get_ladspa_category (uint32_t plugin_id)
        }
 
        pattern.subject = matches1->object;
-       pattern.predicate = (char*)(LADSPA_BASE "hasLabel");
+       pattern.predicate = const_cast<char*>(LADSPA_BASE "hasLabel");
        pattern.object = 0;
        pattern.object_type = lrdf_literal;
 
index a540e0aa93e7612440957c7585013c814516064e..94530e3890e911e4f70ebd28d73f818abfe5ec72 100644 (file)
@@ -2313,7 +2313,7 @@ Route::set_state_2X (const XMLNode& node, int version)
                                        } else if (keyname == "editor") {
                                                sk = EditorSort;
                                        } else {
-                                               RouteSortOrderKey sk = (RouteSortOrderKey) string_2_enum (remaining.substr (0, equal), sk);
+                                               sk = (RouteSortOrderKey) string_2_enum (remaining.substr (0, equal), sk);
                                        }
 
                                        set_order_key (sk, n);
index 47c653a698a6fb1f9a688818fe02800eb4f048e9..e0462efb08137f9cb14e8004e32f3aed4e4b2d1d 100644 (file)
@@ -361,7 +361,7 @@ SMFSource::append_event_unlocked_frames (const Evoral::Event<framepos_t>& ev, fr
                const Evoral::Event<double> beat_ev (ev.event_type(),
                                                     ev_time_beats,
                                                     ev.size(),
-                                                    (uint8_t*)ev.buffer());
+                                                    const_cast<uint8_t*>(ev.buffer()));
                _model->append (beat_ev, event_id);
        }
 
index 0ec318a0ac372e7cb4480d6a001aed71bc209782..ca2544054cc9b8e12d59ba59c220830b64d26729 100644 (file)
@@ -858,7 +858,7 @@ SndFileSource::get_soundfile_info (const string& path, SoundFileInfo& info, stri
 
        sf_info.format = 0; // libsndfile says to clear this before sf_open().
 
-       if ((sf = sf_open ((char*) path.c_str(), SFM_READ, &sf_info)) == 0) {
+       if ((sf = sf_open (const_cast<char*>(path.c_str()), SFM_READ, &sf_info)) == 0) {
                char errbuf[256];
                error_msg = sf_error_str (0, errbuf, sizeof (errbuf) - 1);
                return false;
index 40137bbbb7a719effd331bf67aca400e086c1b0c..64176232f05f4a2f36d2cba695fb64217a9e202d 100644 (file)
@@ -83,7 +83,7 @@ struct UIRequest : public BaseUI::BaseRequestObject {
     ~UIRequest () { 
            if (type == ErrorMessage && msg) {
                    /* msg was strdup()'ed */
-                   free ((char *)msg);
+                   free (const_cast<char *>(msg));
            }
     }
 };
index 30fdeadebae5ee8a9ee44f9f90a55dcec3d78b52..3b8fa7132e2c371e6c3a7a0fbfcc59062c6ee91a 100644 (file)
@@ -23,7 +23,7 @@ LocaleGuard::~LocaleGuard ()
        setlocale (LC_NUMERIC, old);
 
         if (old) {
-                free ((char*)old);
+                free (const_cast<char*>(old));
         }
 }
 
index 9c3782e3c2bb4a1ce25446c5df75dc63662b3248..86b05c4d910474f98a93e242975de596e7732fd7 100644 (file)
@@ -98,8 +98,8 @@ public:
        const XMLPropertyList& properties() const { return _proplist; }
        XMLProperty*       property(const char*);
        XMLProperty*       property(const std::string&);
-       const XMLProperty* property(const char* n)   const { return ((XMLNode*)this)->property(n); }
-       const XMLProperty* property(const std::string& n) const { return ((XMLNode*)this)->property(n); }
+        const XMLProperty* property(const char* n)   const { return const_cast<XMLNode*>(this)->property(n); }
+        const XMLProperty* property(const std::string& n) const { return const_cast<XMLNode*>(this)->property(n); }
        
        XMLProperty* add_property(const char* name, const std::string& value);
        XMLProperty* add_property(const char* name, const char* value = "");
index 3046f971ab17772a4d1c651a10c97b6c9161a1ee..6554bed9ee12c7e02812297f2251d79ef69b8fe3 100644 (file)
@@ -131,7 +131,7 @@ XMLTree::read_buffer(const string& buffer)
        delete _root;
        _root = 0;
 
-       doc = xmlParseMemory((char*)buffer.c_str(), buffer.length());
+       doc = xmlParseMemory(const_cast<char*>(buffer.c_str()), buffer.length());
        if (!doc) {
                return false;
        }
index 4801ac2f092ce68c3cbc7d3af22de7b27fc8b05f..025eb0ef25a146b7829633ede584568550f1908d 100644 (file)
@@ -295,7 +295,7 @@ long long unsigned int system_available_physical_mem() {
        char buf[256];
        long long unsigned int res = 0;
 
-       if (0<read_string((char*)"/proc/meminfo", buf, sizeof (buf))) {
+       if (0<read_string(const_cast<char*>("/proc/meminfo"), buf, sizeof (buf))) {
                if (strncmp (buf, "MemTotal:", 9) == 0) {
                        if (sscanf (buf, "%*s %llu", &res) != 1) {
                                perror ("parse error in /proc/meminfo");
diff --git a/wscript b/wscript
index eb0f100edfd3b41d380b3cd65eea67c64a5c319b..064d03f31f00a1b0da75b9efb12d4ebfd3ebdc61 100644 (file)
--- a/wscript
+++ b/wscript
@@ -334,8 +334,20 @@ def set_compiler_flags (conf,opt):
     # warnings flags
     #
 
-    conf.env.append_value('CFLAGS', "-Wall")
-    conf.env.append_value('CXXFLAGS', [ '-Wall', '-Woverloaded-virtual'])
+    conf.env.append_value('CFLAGS', [ '-Wall',
+                                      '-Wpointer-arith',
+                                      '-Wcast-qual',
+                                      '-Wcast-align',
+                                      '-Wstrict-prototypes',
+                                      '-Wmissing-prototypes'
+                                      ])
+
+    conf.env.append_value('CXXFLAGS', [ '-Wall', 
+                                        '-Wpointer-arith',
+                                        '-Wcast-qual',
+                                        '-Wcast-align', 
+                                        '-Woverloaded-virtual'
+                                        ])
 
 
     #