From: Carl Hetherington Date: Wed, 28 Jan 2015 22:52:13 +0000 (+0000) Subject: Small fixes and tidy-ups spotted by cppcheck. X-Git-Tag: v2.0.48~262 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=a112eeb4d052b1212f94e95efd83a215213da691 Small fixes and tidy-ups spotted by cppcheck. --- diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index 282f5427f..f06db3543 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -68,8 +68,8 @@ Cinema::remove_screen (shared_ptr 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")); } diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index ad09458f9..028912f2b 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -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 diff --git a/src/lib/content_video.h b/src/lib/content_video.h index a7f73597c..4c0bdb655 100644 --- a/src/lib/content_video.h +++ b/src/lib/content_video.h @@ -30,6 +30,7 @@ class ContentVideo public: ContentVideo () : eyes (EYES_BOTH) + , part (PART_WHOLE) {} ContentVideo (boost::shared_ptr i, Eyes e, Part p, VideoFrame f) diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 950c2f381..96dc816ec 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -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 () {} diff --git a/src/lib/font.cc b/src/lib/font.cc index ecf7aabf0..5cf30a2aa 100644 --- a/src/lib/font.cc +++ b/src/lib/font.cc @@ -21,9 +21,10 @@ #include 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 diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 6212875b1..299f7f38d 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -47,11 +47,11 @@ ImageExaminer::ImageExaminer (shared_ptr film, shared_ptrpath(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 { diff --git a/src/lib/isdcf_metadata.cc b/src/lib/isdcf_metadata.cc index 7d960b6ac..9d9d825f5 100644 --- a/src/lib/isdcf_metadata.cc +++ b/src/lib/isdcf_metadata.cc @@ -29,23 +29,23 @@ using boost::shared_ptr; using dcp::raw_convert; ISDCFMetadata::ISDCFMetadata (cxml::ConstNodePtr node) -{ - content_version = node->number_child ("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 ("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; - } -} diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 1698da99e..1aeed4062 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -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) { diff --git a/src/lib/update.h b/src/lib/update.h index c3e2b5613..5bb9e9501 100644 --- a/src/lib/update.h +++ b/src/lib/update.h @@ -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 (); diff --git a/src/lib/util.cc b/src/lib/util.cc index 0a6f381db..807883ca0 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 5dc9e3d66..823517bfc 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -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 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 () { diff --git a/src/tools/dcpomatic_server_cli.cc b/src/tools/dcpomatic_server_cli.cc index b816460a3..80f4a0d0c 100644 --- a/src/tools/dcpomatic_server_cli.cc +++ b/src/tools/dcpomatic_server_cli.cc @@ -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); diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index 641ddd503..16930ffd8 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -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 ()); } diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h index 77cf29a30..cd51e86f1 100644 --- a/src/wx/content_menu.h +++ b/src/wx/content_menu.h @@ -27,7 +27,7 @@ class Film; -class ContentMenu +class ContentMenu : public boost::noncopyable { public: ContentMenu (wxWindow* p); diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index 88aac7049..6b94e7d5b 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -33,7 +33,7 @@ class FilmEditor; class ContentSubPanel; class Film; -class ContentPanel +class ContentPanel : public boost::noncopyable { public: ContentPanel (wxNotebook *, boost::shared_ptr); diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index b4d06286e..6f406dadb 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -41,7 +41,7 @@ * @param V Data type of state as used by the view. */ template -class ContentWidget +class ContentWidget : public boost::noncopyable { public: /** @param parent Parent window. diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index ced6e6efd..060ec31ff 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -18,6 +18,7 @@ */ #include +#include 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); diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index fd3ea6bf7..783535a12 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -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, wxScrolledWindow* window, wxPanel* panel, wxFlexGridSizer* table) diff --git a/test/resampler_test.cc b/test/resampler_test.cc index ffd636ac8..0fc05685b 100644 --- a/test/resampler_test.cc +++ b/test/resampler_test.cc @@ -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 a (new AudioBuffers (1, 1000)); a->make_silent (); shared_ptr r = resamp.run (a); - total_out += r->frames (); } }