Small fixes and tidy-ups spotted by cppcheck.
authorCarl Hetherington <cth@carlh.net>
Wed, 28 Jan 2015 22:52:13 +0000 (22:52 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 28 Jan 2015 22:52:13 +0000 (22:52 +0000)
19 files changed:
src/lib/cinema.cc
src/lib/colour_conversion.cc
src/lib/content_video.h
src/lib/exceptions.h
src/lib/font.cc
src/lib/image_examiner.cc
src/lib/isdcf_metadata.cc
src/lib/playlist.cc
src/lib/update.h
src/lib/util.cc
src/lib/video_content.cc
src/tools/dcpomatic_server_cli.cc
src/wx/audio_plot.cc
src/wx/content_menu.h
src/wx/content_panel.h
src/wx/content_widget.h
src/wx/dcp_panel.h
src/wx/job_manager_view.cc
test/resampler_test.cc

index 282f5427fae472b859101c3d76dfbb30f224ad7d..f06db354343b3c971ce09e84bfba4ed950f08bf2 100644 (file)
@@ -68,8 +68,8 @@ Cinema::remove_screen (shared_ptr<Screen> s)
 }
 
 Screen::Screen (cxml::ConstNodePtr node)
+       : name (node->string_child ("name"))
 {
-       name = node->string_child ("Name");
        if (node->optional_string_child ("Certificate")) {
                certificate = dcp::Certificate (node->string_child ("Certificate"));
        }
index ad09458f98a2ec4338b4ce7f97c1d476966b70b8..028912f2b482b2c00d281671724094cab834b407 100644 (file)
@@ -193,8 +193,9 @@ PresetColourConversion::PresetColourConversion (string n, dcp::ColourConversion
 
 PresetColourConversion::PresetColourConversion (cxml::NodePtr node, int version)
        : conversion (node, version)
+       , name (node->string_child ("Name"))
 {
-       name = node->string_child ("Name");
+
 }
 
 void
index a7f73597c866495b0df60a2f3036bd8066d0f1f0..4c0bdb655d7ea222bef72e6d2b454e725d72ffd7 100644 (file)
@@ -30,6 +30,7 @@ class ContentVideo
 public:
        ContentVideo ()
                : eyes (EYES_BOTH)
+               , part (PART_WHOLE)
        {}
 
        ContentVideo (boost::shared_ptr<const ImageProxy> i, Eyes e, Part p, VideoFrame f)
index 950c2f381aae0da529fc0403c75fbfa3412637a6..96dc816ec4dea27cbbc94937dbf98a0c76c2fe6b 100644 (file)
@@ -40,9 +40,9 @@ class StringError : public std::exception
 {
 public:
        /** @param w Error message */
-       StringError (std::string w) {
-               _what = w;
-       }
+       StringError (std::string w)
+               : _what (w)
+       {}
 
        virtual ~StringError () throw () {}
 
index ecf7aabf0146ae6c707ebf4218db19427d0d6a53..5cf30a2aae370704d985fc6fe31c102f0fcfaad3 100644 (file)
 #include <libxml++/libxml++.h>
 
 Font::Font (cxml::NodePtr node)
+       : id (node->string_child ("Id"))
+       , file (node->optional_string_child ("File"))
 {
-       id = node->string_child ("Id");
-       file = node->optional_string_child ("File");
+       
 }
 
 void
index 6212875b1de0ed6f3b063e0f67acfa7e6338c613..299f7f38d04f713aa185f45dae7119db7910bac4 100644 (file)
@@ -47,11 +47,11 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
        boost::filesystem::path path = content->path(0).string ();
        if (valid_j2k_file (path)) {
                boost::uintmax_t size = boost::filesystem::file_size (path);
-               uint8_t* buffer = new uint8_t[size];
                FILE* f = fopen_boost (path, "r");
                if (!f) {
                        throw FileError ("Could not open file for reading", path);
                }
+               uint8_t* buffer = new uint8_t[size];
                fread (buffer, 1, size, f);
                fclose (f);
                try {
index 7d960b6ac758538d0728b68501a803e0368dcc7d..9d9d825f53b9801b5aa4beec7535c054ecff641a 100644 (file)
@@ -29,23 +29,23 @@ using boost::shared_ptr;
 using dcp::raw_convert;
 
 ISDCFMetadata::ISDCFMetadata (cxml::ConstNodePtr node)
-{
-       content_version = node->number_child<int> ("ContentVersion");
-       audio_language = node->string_child ("AudioLanguage");
-       subtitle_language = node->string_child ("SubtitleLanguage");
-       territory = node->string_child ("Territory");
-       rating = node->string_child ("Rating");
-       studio = node->string_child ("Studio");
-       facility = node->string_child ("Facility");
-       package_type = node->string_child ("PackageType");
-
+       : content_version (node->number_child<int> ("ContentVersion"))
+       , audio_language (node->string_child ("AudioLanguage"))
+       , subtitle_language (node->string_child ("SubtitleLanguage"))
+       , territory (node->string_child ("Territory"))
+       , rating (node->string_child ("Rating"))
+       , studio (node->string_child ("Studio"))
+       , facility (node->string_child ("Facility"))
+       , package_type (node->string_child ("PackageType"))
        /* This stuff was added later */
-       temp_version = node->optional_bool_child ("TempVersion").get_value_or (false);
-       pre_release = node->optional_bool_child ("PreRelease").get_value_or (false);
-       red_band = node->optional_bool_child ("RedBand").get_value_or (false);
-       chain = node->optional_string_child ("Chain").get_value_or ("");
-       two_d_version_of_three_d = node->optional_bool_child ("TwoDVersionOfThreeD").get_value_or (false);
-       mastered_luminance = node->optional_string_child ("MasteredLuminance").get_value_or ("");
+       , temp_version (node->optional_bool_child ("TempVersion").get_value_or (false))
+       , pre_release (node->optional_bool_child ("PreRelease").get_value_or (false))
+       , red_band (node->optional_bool_child ("RedBand").get_value_or (false))
+       , chain (node->optional_string_child ("Chain").get_value_or (""))
+       , two_d_version_of_three_d (node->optional_bool_child ("TwoDVersionOfThreeD").get_value_or (false))
+       , mastered_luminance (node->optional_string_child ("MasteredLuminance").get_value_or (""))
+{
+       
 }
 
 void
@@ -66,23 +66,3 @@ ISDCFMetadata::as_xml (xmlpp::Node* root) const
        root->add_child("TwoDVersionOfThreeD")->add_child_text (two_d_version_of_three_d ? "1" : "0");
        root->add_child("MasteredLuminance")->add_child_text (mastered_luminance);
 }
-
-void
-ISDCFMetadata::read_old_metadata (string k, string v)
-{
-       if (k == N_("audio_language")) {
-               audio_language = v;
-       } else if (k == N_("subtitle_language")) {
-               subtitle_language = v;
-       } else if (k == N_("territory")) {
-               territory = v;
-       } else if (k == N_("rating")) {
-               rating = v;
-       } else if (k == N_("studio")) {
-               studio = v;
-       } else if (k == N_("facility")) {
-               facility = v;
-       } else if (k == N_("package_type")) {
-               package_type = v;
-       }
-}      
index 1698da99ef25ace321b80954c8a4239a7105090b..1aeed4062a8e2d603f3d09b731e43e499b56879e 100644 (file)
@@ -84,7 +84,6 @@ Playlist::maybe_sequence_video ()
        
        _sequencing_video = true;
        
-       ContentList cl = _content;
        DCPTime next_left;
        DCPTime next_right;
        for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) {
index c3e2b5613d2772e3049f1c685d3e7c86aab71e27..5bb9e95016de1ed2bace2ec556fd54f9dccfef07 100644 (file)
@@ -30,7 +30,7 @@
 struct update_checker_test;
 
 /** Class to check for the existance of an update for DCP-o-matic on a remote server */
-class UpdateChecker
+class UpdateChecker : public boost::noncopyable
 {
 public:
        UpdateChecker ();
index 0a6f381db8adf23cd7c8028e3dd2cc624f49d575..807883ca0906ffc787ff8da0f54533c50566df9e 100644 (file)
@@ -287,9 +287,8 @@ set_backtrace_file (boost::filesystem::path p)
 void
 terminate ()
 {
-       static bool tried_throw = false;
-
        try {
+               static bool tried_throw = false;
                // try once to re-throw currently active exception
                if (!tried_throw) {
                        tried_throw = true;
index 5dc9e3d66814424f4dee8eed190e30a52cb75437..823517bfc0af47103ac146f30cae854b3ebabd79 100644 (file)
@@ -443,17 +443,6 @@ VideoContent::video_size_after_crop () const
        return crop().apply (video_size_after_3d_split ());
 }
 
-/** @param t A time offset from the start of this piece of content.
- *  @return Corresponding time with respect to the content.
- */
-ContentTime
-VideoContent::dcp_time_to_content_time (DCPTime t) const
-{
-       shared_ptr<const Film> film = _film.lock ();
-       DCPOMATIC_ASSERT (film);
-       return ContentTime (t, FrameRateChange (video_frame_rate(), film->video_frame_rate()));
-}
-
 void
 VideoContent::scale_and_crop_to_fit_width ()
 {
index b816460a3376daadea18467caf49fb5e1a20ffd9..80f4a0d0c339677dd46a528a2f171cad5e23ba01 100644 (file)
@@ -112,7 +112,7 @@ main (int argc, char* argv[])
        
        try {
                server.run (num_threads);
-       } catch (boost::system::system_error e) {
+       } catch (boost::system::system_error& e) {
                if (e.code() == boost::system::errc::address_in_use) {
                        cerr << argv[0] << ": address already in use.  Is another DCP-o-matic server instance already running?\n";
                        exit (EXIT_FAILURE);
index 641ddd503aa7fc781167f616d5489059dde8bcb7..16930ffd870ab55724d6753ea0e91eabcb8160ca 100644 (file)
@@ -280,7 +280,7 @@ AudioPlot::plot_rms (wxGraphicsPath& path, int channel, Metrics const & metrics)
                        p += pow (*j, 2);
                }
 
-               if (smoothing.size() > 0) {
+               if (!smoothing.empty ()) {
                        p = sqrt (p / smoothing.size ());
                }
 
index 77cf29a3057400d523ff3449a2ce96cb2f8d8679..cd51e86f1a9fb21b14aa146d62287cca611b9a7e 100644 (file)
@@ -27,7 +27,7 @@
 
 class Film;
 
-class ContentMenu
+class ContentMenu : public boost::noncopyable
 {
 public:
        ContentMenu (wxWindow* p);
index 88aac70495d0d66a48f97e1edf359fd24e377f39..6b94e7d5b0d5997d14b9aa2a243363c844d10e25 100644 (file)
@@ -33,7 +33,7 @@ class FilmEditor;
 class ContentSubPanel;
 class Film;
 
-class ContentPanel
+class ContentPanel : public boost::noncopyable
 {
 public:
        ContentPanel (wxNotebook *, boost::shared_ptr<Film>);
index b4d06286e46972de23b863460ec8aebceba57653..6f406dadbc926e92c094b74d53366327b6d08093 100644 (file)
@@ -41,7 +41,7 @@
  *  @param V Data type of state as used by the view.
  */
 template <class S, class T, typename U, typename V>
-class ContentWidget
+class ContentWidget : public boost::noncopyable
 {
 public:
        /** @param parent Parent window.
index ced6e6efd1f6b05d8cdd186b630ddeb43e4ee293..060ec31ff972c55cd99830821c313de315fbdef7 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
 
 class wxNotebook;
 class wxPanel;
@@ -32,7 +33,7 @@ class wxSizer;
 
 class Film;
 
-class DCPPanel
+class DCPPanel : public boost::noncopyable
 {
 public:
        DCPPanel (wxNotebook *, boost::shared_ptr<Film>);
index fd3ea6bf782c2e7af7304095846f34cd358e4dd5..783535a1243cf91627dff56be7687545ccd4298a 100644 (file)
@@ -36,7 +36,7 @@ using std::cout;
 using boost::shared_ptr;
 using boost::weak_ptr;
 
-class JobRecord
+class JobRecord : public boost::noncopyable
 {
 public:
        JobRecord (shared_ptr<Job> job, wxScrolledWindow* window, wxPanel* panel, wxFlexGridSizer* table)
index ffd636ac8ffb6371503d6f1a90743fd945f55c0a..0fc05685b565c2c0b01d2238a643652868f300e1 100644 (file)
@@ -35,8 +35,6 @@ resampler_test_one (int from, int to)
 {
        Resampler resamp (from, to, 1);
 
-       int total_out = 0;
-
        /* 3 hours */
        int64_t const N = int64_t (from) * 60 * 60 * 3;
                
@@ -45,7 +43,6 @@ resampler_test_one (int from, int to)
                shared_ptr<AudioBuffers> a (new AudioBuffers (1, 1000));
                a->make_silent ();
                shared_ptr<const AudioBuffers> r = resamp.run (a);
-               total_out += r->frames ();
        }
 }