WIP signed-unsigned
authorCarl Hetherington <cth@carlh.net>
Fri, 24 Jul 2020 21:18:24 +0000 (23:18 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 24 Jul 2020 21:18:24 +0000 (23:18 +0200)
69 files changed:
src/lib/analyse_audio_job.cc
src/lib/analyse_audio_job.h
src/lib/audio_buffers.cc
src/lib/audio_mapping.cc
src/lib/cinema_sound_processor.cc
src/lib/colour_conversion.cc
src/lib/compose.hpp
src/lib/cross_linux.cc
src/lib/dcpomatic_socket.cc
src/lib/dcpomatic_socket.h
src/lib/digester.cc
src/lib/digester.h
src/lib/edid.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_image_proxy.cc
src/lib/ffmpeg_image_proxy.h
src/lib/film.cc
src/lib/image.cc
src/lib/image_decoder.cc
src/lib/image_examiner.cc
src/lib/image_filename_sorter.cc
src/lib/internet.cc
src/lib/j2k_image_proxy.cc
src/lib/kdm_with_metadata.cc
src/lib/playlist.cc
src/lib/playlist.h
src/lib/reel_writer.cc
src/lib/render_text.cc
src/lib/video_ring_buffers.cc
src/lib/warnings.h [new file with mode: 0644]
src/tools/dcpomatic.cc
src/wx/audio_mapping_view.h
src/wx/closed_captions_dialog.h
src/wx/content_panel.cc
src/wx/content_sub_panel.h
src/wx/content_view.h
src/wx/controls.h
src/wx/custom_scale_dialog.cc
src/wx/custom_scale_dialog.h
src/wx/download_certificate_dialog.h
src/wx/download_certificate_panel.h
src/wx/editable_list.h
src/wx/film_editor.h
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/filter_dialog.h
src/wx/focus_manager.cc
src/wx/gl_video_view.h
src/wx/i18n_hook.h
src/wx/job_manager_view.h
src/wx/job_view.cc
src/wx/job_view.h
src/wx/markers_dialog.h
src/wx/player_stress_tester.h
src/wx/playlist_controls.cc
src/wx/playlist_controls.h
src/wx/question_dialog.h
src/wx/repeat_dialog.h
src/wx/screens_panel.h
src/wx/system_font_dialog.h
src/wx/table_dialog.h
src/wx/time_picker.h
src/wx/timeline_content_view.h
src/wx/verify_dcp_dialog.h
src/wx/video_waveform_plot.h
src/wx/wx_util.h
test/test.cc
test/test.h
wscript

index acd730a68bc1e4588546a64cdabed407ba5aac80..47beb0d4398383f007de7a4c59ba5ca69fa1b839 100644 (file)
@@ -92,7 +92,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
        }
 
        /* XXX: is this right?  Especially for more than 5.1? */
-       vector<double> channel_corrections(film->audio_channels(), 1);
+       vector<double> channel_corrections(static_cast<size_t>(film->audio_channels()), 1);
        add_if_required (channel_corrections,  4,   -3); // Ls
        add_if_required (channel_corrections,  5,   -3); // Rs
        add_if_required (channel_corrections,  6, -144); // HI
@@ -113,7 +113,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
                channel_corrections,
                850, // suggested by leqm_nrt CLI source
                64,  // suggested by leqm_nrt CLI source
-               boost::thread::hardware_concurrency()
+               static_cast<int>(boost::thread::hardware_concurrency())
                ));
 }
 
@@ -231,16 +231,17 @@ AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b, DCPTime time)
        }
 #endif
 
-       int const frames = b->frames ();
-       int const channels = b->channels ();
-       vector<double> interleaved(frames * channels);
+       DCPOMATIC_ASSERT (b->frames());
+       DCPOMATIC_ASSERT (b->channels());
 
-       for (int j = 0; j < channels; ++j) {
+       vector<double> interleaved(static_cast<size_t>(b->frames() * b->channels()));
+
+       for (int j = 0; j < b->channels(); ++j) {
                float* data = b->data(j);
-               for (int i = 0; i < frames; ++i) {
-                       float s = data[i];
+               for (Frame i = 0; i < b->frames(); ++i) {
+                       float s = data[static_cast<size_t>(i)];
 
-                       interleaved[i * channels + j] = s;
+                       interleaved[static_cast<size_t>(i * b->channels() + j)] = s;
 
                        float as = fabsf (s);
                        if (as < 10e-7) {
@@ -266,7 +267,7 @@ AnalyseAudioJob::analyse (shared_ptr<const AudioBuffers> b, DCPTime time)
 
        _leqm->add(interleaved);
 
-       _done += frames;
+       _done += b->frames();
 
        DCPTime const length = _playlist->length (_film);
        set_progress ((time.seconds() - _start.seconds()) / (length.seconds() - _start.seconds()));
index f7cc3e2567ffa39dd82205f3a48d664c119efd24..8f88b0fa143d42c88d68f678c809a5c906fe1f9a 100644 (file)
@@ -66,8 +66,8 @@ private:
        dcpomatic::DCPTime _start;
        bool _from_zero;
 
-       int64_t _done;
-       int64_t _samples_per_point;
+       Frame _done;
+       Frame _samples_per_point;
        AudioPoint* _current;
 
        float* _sample_peak;
index cfe762659ebdb6d91128557b35cccb3c08c56144..739441b4c1ff6a68788a58d6422137c586f1731b 100644 (file)
@@ -89,13 +89,13 @@ AudioBuffers::allocate (int channels, int32_t frames)
        _frames = frames;
        _allocated_frames = frames;
 
-       _data = static_cast<float**> (malloc (_channels * sizeof (float *)));
+       _data = static_cast<float**>(malloc(static_cast<size_t>(_channels) * sizeof(float *)));
        if (!_data) {
                throw bad_alloc ();
        }
 
        for (int i = 0; i < _channels; ++i) {
-               _data[i] = static_cast<float*> (malloc (frames * sizeof (float)));
+               _data[i] = static_cast<float*>(malloc(static_cast<size_t>(frames) * sizeof(float)));
                if (!_data[i]) {
                        throw bad_alloc ();
                }
@@ -158,7 +158,8 @@ AudioBuffers::make_silent (int c)
        /* This isn't really allowed, as all-bits-0 is not guaranteed to mean a 0 float,
           but it seems that we can get away with it.
        */
-       memset (_data[c], 0, _frames * sizeof(float));
+       DCPOMATIC_ASSERT (_frames >= 0);
+       memset (_data[c], 0, static_cast<size_t>(_frames) * sizeof(float));
 }
 
 /** Make some frames.
@@ -169,12 +170,13 @@ void
 AudioBuffers::make_silent (int32_t from, int32_t frames)
 {
        DCPOMATIC_ASSERT ((from + frames) <= _allocated_frames);
+       DCPOMATIC_ASSERT (frames >= 0);
 
        for (int c = 0; c < _channels; ++c) {
                /* This isn't really allowed, as all-bits-0 is not guaranteed to mean a 0 float,
                   but it seems that we can get away with it.
                */
-               memset (_data[c] + from, 0, frames * sizeof(float));
+               memset (_data[c] + from, 0, static_cast<size_t>(frames) * sizeof(float));
        }
 }
 
@@ -197,9 +199,10 @@ AudioBuffers::copy_from (AudioBuffers const * from, int32_t frames_to_copy, int3
        DCPOMATIC_ASSERT (from);
        DCPOMATIC_ASSERT (read_offset >= 0 && (read_offset + frames_to_copy) <= from->_allocated_frames);
        DCPOMATIC_ASSERT (write_offset >= 0 && (write_offset + frames_to_copy) <= _allocated_frames);
+       DCPOMATIC_ASSERT (frames_to_copy > 0);
 
        for (int i = 0; i < _channels; ++i) {
-               memcpy (_data[i] + write_offset, from->_data[i] + read_offset, frames_to_copy * sizeof(float));
+               memcpy (_data[i] + write_offset, from->_data[i] + read_offset, static_cast<size_t>(frames_to_copy) * sizeof(float));
        }
 }
 
@@ -225,7 +228,7 @@ AudioBuffers::move (int32_t frames, int32_t from, int32_t to)
        DCPOMATIC_ASSERT ((to + frames) <= _allocated_frames);
 
        for (int i = 0; i < _channels; ++i) {
-               memmove (_data[i] + to, _data[i] + from, frames * sizeof(float));
+               memmove (_data[i] + to, _data[i] + from, static_cast<size_t>(frames) * sizeof(float));
        }
 }
 
@@ -256,6 +259,8 @@ AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, i
 void
 AudioBuffers::ensure_size (int32_t frames)
 {
+       DCPOMATIC_ASSERT (frames >= 0);
+
        if (_allocated_frames >= frames) {
                return;
        }
@@ -272,7 +277,7 @@ AudioBuffers::ensure_size (int32_t frames)
        frames++;
 
        for (int i = 0; i < _channels; ++i) {
-               _data[i] = static_cast<float*> (realloc (_data[i], frames * sizeof (float)));
+               _data[i] = static_cast<float*>(realloc(_data[i], static_cast<size_t>(frames) * sizeof (float)));
                if (!_data[i]) {
                        throw bad_alloc ();
                }
@@ -339,7 +344,8 @@ void
 AudioBuffers::copy_channel_from (AudioBuffers const * from, int from_channel, int to_channel)
 {
        DCPOMATIC_ASSERT (from->frames() == frames());
-       memcpy (data(to_channel), from->data(from_channel), frames() * sizeof (float));
+       DCPOMATIC_ASSERT (frames() >= 0);
+       memcpy (data(to_channel), from->data(from_channel), static_cast<size_t>(frames()) * sizeof(float));
 }
 
 /** Make a copy of these AudioBuffers */
index 05dfb7e897de8bb1c23cdfdb01c9390519cd3d52..e2f6816808451cc2a39421f013b0cc40060716f2 100644 (file)
@@ -60,12 +60,15 @@ AudioMapping::AudioMapping (int input_channels, int output_channels)
 void
 AudioMapping::setup (int input_channels, int output_channels)
 {
+       DCPOMATIC_ASSERT (input_channels >= 0);
+       DCPOMATIC_ASSERT (output_channels >= 0);
+
        _input_channels = input_channels;
        _output_channels = output_channels;
 
-       _gain.resize (_input_channels);
+       _gain.resize (static_cast<size_t>(_input_channels));
        for (int i = 0; i < _input_channels; ++i) {
-               _gain[i].resize (_output_channels);
+               _gain[i].resize (static_cast<size_t>(_output_channels));
        }
 
        make_zero ();
@@ -179,17 +182,17 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version)
 void
 AudioMapping::set (int input_channel, int output_channel, float g)
 {
-       DCPOMATIC_ASSERT (input_channel < int(_gain.size()));
-       DCPOMATIC_ASSERT (output_channel < int(_gain[0].size()));
-       _gain[input_channel][output_channel] = g;
+       DCPOMATIC_ASSERT (input_channel >= 0 && input_channel < int(_gain.size()));
+       DCPOMATIC_ASSERT (output_channel >= 0 && output_channel < int(_gain[0].size()));
+       _gain[static_cast<size_t>(input_channel)][static_cast<size_t>(output_channel)] = g;
 }
 
 float
 AudioMapping::get (int input_channel, int output_channel) const
 {
-       DCPOMATIC_ASSERT (input_channel < int (_gain.size()));
-       DCPOMATIC_ASSERT (output_channel < int (_gain[0].size()));
-       return _gain[input_channel][output_channel];
+       DCPOMATIC_ASSERT (input_channel >= 0 && input_channel < int(_gain.size()));
+       DCPOMATIC_ASSERT (output_channel >= 0 && output_channel < int(_gain[0].size()));
+       return _gain[static_cast<size_t>(input_channel)][static_cast<size_t>(output_channel)];
 }
 
 void
@@ -217,8 +220,8 @@ AudioMapping::digest () const
        Digester digester;
        digester.add (_input_channels);
        digester.add (_output_channels);
-       for (int i = 0; i < _input_channels; ++i) {
-               for (int j = 0; j < _output_channels; ++j) {
+       for (size_t i = 0; i < static_cast<size_t>(_input_channels); ++i) {
+               for (int j = 0; j < static_cast<size_t>(_output_channels); ++j) {
                        digester.add (_gain[i][j]);
                }
        }
index 1a3ba5a0f0af61fcd9b9d412a4b6111e4ffc82ca..9f1048274ecdccea6d50eff08f55835bffef58eb 100644 (file)
@@ -107,8 +107,8 @@ CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s)
 CinemaSoundProcessor const *
 CinemaSoundProcessor::from_index (int i)
 {
-       DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ()));
-       return _cinema_sound_processors[i];
+       DCPOMATIC_ASSERT (i >= 0 && i < int(_cinema_sound_processors.size()));
+       return _cinema_sound_processors[static_cast<size_t>(i)];
 }
 
 float
index 2e052060e2b247ad9f26dbd51c54399b952f9c91..93605b4c701fa8782105fa1d24bcce78cf3bfe19 100644 (file)
@@ -99,8 +99,8 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version)
                /* Read in old <Matrix> nodes and convert them to chromaticities */
                boost::numeric::ublas::matrix<double> C (3, 3);
                for (list<cxml::NodePtr>::iterator i = m.begin(); i != m.end(); ++i) {
-                       int const ti = (*i)->number_attribute<int> ("i");
-                       int const tj = (*i)->number_attribute<int> ("j");
+                       size_t const ti = (*i)->number_attribute<size_t>("i");
+                       size_t const tj = (*i)->number_attribute<size_t>("j");
                        C(ti, tj) = raw_convert<double> ((*i)->content ());
                }
 
index 2c44f148bdf05e9bb5c48e7902c15d6e7a3bf7d9..37ad5efa1ef504b57c20c103266b434ccc1fc276 100644 (file)
@@ -152,7 +152,7 @@ namespace StringPrivate
          // save string
          output.push_back(fmt.substr(b, i - b));
 
-         int n = 1;            // number of digits
+         std::string::size_type n = 1;         // number of digits
          int spec_no = 0;
 
          do {
index 25fd3490e2bf40374995a5169edebd054afc3607..c76293ce80c05523d204aacc5451c8f62fce29ce 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "cross.h"
 #include "compose.hpp"
+#include "dcpomatic_assert.h"
 #include "log.h"
 #include "dcpomatic_log.h"
 #include "config.h"
@@ -65,13 +66,15 @@ using boost::function;
 void
 dcpomatic_sleep_seconds (int s)
 {
-       sleep (s);
+       DCPOMATIC_ASSERT (s >= 0);
+       sleep (static_cast<unsigned int>(s));
 }
 
 void
 dcpomatic_sleep_milliseconds (int ms)
 {
-       usleep (ms * 1000);
+       DCPOMATIC_ASSERT (ms >= 0);
+       usleep (static_cast<unsigned int>(ms) * 1000);
 }
 
 /** @return A string of CPU information (model name etc.) */
index a0a7a1cf3f3d877ee92aa204c2ad3c23f162a754..f2c8d12bfd8b0b0223a333c27d1aa49a66752b82 100644 (file)
@@ -79,7 +79,7 @@ Socket::connect (boost::asio::ip::tcp::endpoint endpoint)
  *  @param size Number of bytes to write.
  */
 void
-Socket::write (uint8_t const * data, int size)
+Socket::write (uint8_t const * data, size_t size)
 {
        _deadline.expires_from_now (boost::posix_time::seconds (_timeout));
        boost::system::error_code ec = boost::asio::error::would_block;
@@ -111,7 +111,7 @@ Socket::write (uint32_t v)
  *  @param size Number of bytes to read.
  */
 void
-Socket::read (uint8_t* data, int size)
+Socket::read (uint8_t* data, size_t size)
 {
        _deadline.expires_from_now (boost::posix_time::seconds (_timeout));
        boost::system::error_code ec = boost::asio::error::would_block;
@@ -200,7 +200,7 @@ bool
 Socket::check_read_digest ()
 {
        DCPOMATIC_ASSERT (_read_digester);
-       int const size = _read_digester->size ();
+       size_t const size = _read_digester->size ();
 
        uint8_t ref[size];
        _read_digester->get (ref);
@@ -220,7 +220,7 @@ void
 Socket::finish_write_digest ()
 {
        DCPOMATIC_ASSERT (_write_digester);
-       int const size = _write_digester->size();
+       size_t const size = _write_digester->size();
 
        uint8_t buffer[size];
        _write_digester->get (buffer);
index 1fa0b046f0c1c7e2490865bfaa41a99114f8dcfb..6f6f8ceceb1352bf1f73c6b42f6a8b093111d4c0 100644 (file)
@@ -44,9 +44,9 @@ public:
        void connect (boost::asio::ip::tcp::endpoint);
 
        void write (uint32_t n);
-       void write (uint8_t const * data, int size);
+       void write (uint8_t const * data, size_t size);
 
-       void read (uint8_t* data, int size);
+       void read (uint8_t* data, size_t size);
        uint32_t read_uint32 ();
 
        class ReadDigestScope
index 452452ba4b1c1091622a001c639446d83f2f2989..b2d2239e36c7b6e73294c11771968fd922dbee74 100644 (file)
@@ -76,7 +76,7 @@ Digester::get (uint8_t* buffer) const
 }
 
 
-int
+size_t
 Digester::size () const
 {
        return MD5_DIGEST_SIZE;
index 6cdaf2331b8bda04a7aec588c659add946f8c79c..54626c10c303518be2e58abd83e17bec410ec125 100644 (file)
@@ -42,7 +42,7 @@ public:
 
        void get (uint8_t* buffer) const;
 
-       int size () const;
+       size_t size () const;
 
 private:
        mutable md5_ctx _context;
index 3df65d325ca6ce1ec7767c5f1162c07fdbfea2f5..bb078bb7fd83bd066128e7156e4d072a87656fbd 100644 (file)
@@ -78,7 +78,11 @@ get_monitors()
 
                        mon.manufacturer_product_code = (edid[11] << 8) | edid[10];
 
-                       mon.serial_number = (edid[15] << 24) | (edid[14] << 16) | (edid[13] << 8) | edid[12];
+                       mon.serial_number = (static_cast<uint32_t>(edid[15]) << 24) |
+                               (static_cast<uint32_t>(edid[14]) << 16) |
+                               (static_cast<uint32_t>(edid[13]) << 8) |
+                               static_cast<uint32_t>(edid[12]);
+
                        mon.week_of_manufacture = edid[16];
                        mon.year_of_manufacture = edid[17];
                        monitors.push_back (mon);
index cfaf0361b9ab79da14f4f4ae841a5bd8a243cf9d..8cf68a208bef216fc7859b61e1de28d8486a2619 100644 (file)
@@ -420,7 +420,8 @@ FFmpegDecoder::decode_audio_packet ()
        */
 
        AVPacket copy_packet = _packet;
-       int const stream_index = copy_packet.stream_index;
+       DCPOMATIC_ASSERT (copy_packet.stream_index >= 0);
+       size_t const stream_index = static_cast<size_t>(copy_packet.stream_index);
 
        /* XXX: inefficient */
        vector<shared_ptr<FFmpegAudioStream> > streams = ffmpeg_content()->ffmpeg_audio_streams ();
@@ -645,8 +646,10 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTime
           chosen by the user; created a `mapped' palette from those settings.
        */
        map<RGBA, RGBA> colour_map = ffmpeg_content()->subtitle_stream()->colours ();
-       vector<RGBA> mapped_palette (rect->nb_colors);
-       for (int i = 0; i < rect->nb_colors; ++i) {
+       DCPOMATIC_ASSERT (rect->nb_colors);
+       size_t const colors = static_cast<size_t>(rect->nb_colors);
+       vector<RGBA> mapped_palette (colors);
+       for (size_t i = 0; i < colors; ++i) {
                RGBA c (palette[2], palette[1], palette[0], palette[3]);
                map<RGBA, RGBA>::const_iterator j = colour_map.find (c);
                if (j != colour_map.end ()) {
index db6059266dc472e13b8908a67f5baf0b2a800618..65c3ae29be221121dfab80950d3549abefea160d 100644 (file)
@@ -83,7 +83,7 @@ avio_seek_wrapper (void* data, int64_t offset, int whence)
 int
 FFmpegImageProxy::avio_read (uint8_t* buffer, int const amount)
 {
-       int const to_do = min(int64_t(amount), _data.size() - _pos);
+       size_t const to_do = min(static_cast<size_t>(amount), _data.size() - _pos);
        if (to_do == 0) {
                return AVERROR_EOF;
        }
@@ -97,18 +97,22 @@ FFmpegImageProxy::avio_seek (int64_t const pos, int whence)
 {
        switch (whence) {
        case AVSEEK_SIZE:
-               return _data.size();
+               return static_cast<int64_t>(_data.size());
        case SEEK_CUR:
-               _pos += pos;
+               DCPOMATIC_ASSERT ((static_cast<int_64_t>(_pos) + pos) >= 0);
+               _pos = static_cast<size_t>(_pos + pos);
                break;
        case SEEK_SET:
-               _pos = pos;
+               DCPOMATIC_ASSERT (pos >= 0);
+               _pos = static_cast<size_t>(pos);
                break;
        case SEEK_END:
-               _pos = _data.size() - pos;
+               DCPOMATIC_ASSERT ((static_cast<int64_t>(_data.size()) - pos) >= 0);
+               _pos = static_cast<size_t>(_data.size() - pos);
                break;
        }
 
+       DCPOMATIC_ASSERT (_pos >= 0);
        return _pos;
 }
 
index aa77003a4f9169c90bbf47471806700369f6b96e..139296d9b653ccb38da7780e9b07468435de3d1c 100644 (file)
@@ -44,7 +44,7 @@ public:
 
 private:
        dcp::Data _data;
-       mutable int64_t _pos;
+       mutable size_t _pos;
        /** Path of a file that this image came from, if applicable; stored so that
            failed-decode errors can give more detail.
        */
index cf7d04933f47dffafab2e56dbda3479c0ebb421a..719a16f9c65a1fde2fd5393e94852bd38f62bda4 100644 (file)
@@ -1566,7 +1566,7 @@ Film::make_kdm (
 /** @return The approximate disk space required to encode a DCP of this film with the
  *  current settings, in bytes.
  */
-uint64_t
+size_t
 Film::required_disk_space () const
 {
        return _playlist->required_disk_space (shared_from_this(), j2k_bandwidth(), audio_channels(), audio_frame_rate());
index 002c7df9ad11fb9e80947fcf51300096c5df27d2..e7835809371056acdcf6ea1077bbbd6d38cf5cb8 100644 (file)
@@ -187,7 +187,8 @@ Image::crop_scale_window (
        }
 
        /* Prepare input data pointers with crop */
-       uint8_t* scale_in_data[planes()];
+       DCPOMATIC_ASSERT (planes() > 0);
+       uint8_t* scale_in_data[static_cast<size_t>(planes())];
        for (int c = 0; c < planes(); ++c) {
                /* To work out the crop in bytes, start by multiplying
                   the crop by the (average) bytes per pixel.  Then
@@ -206,7 +207,7 @@ Image::crop_scale_window (
                throw PixelFormatError ("crop_scale_window()", out_format);
        }
 
-       uint8_t* scale_out_data[out->planes()];
+       uint8_t* scale_out_data[static_cast<size_t>(out->planes())];
        for (int c = 0; c < out->planes(); ++c) {
                /* See the note in the crop loop above */
                int const x = lrintf (out->bytes_per_pixel(c) * corner.x) & ~ ((int) out_desc->log2_chroma_w);
@@ -302,9 +303,9 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo
 void
 Image::yuv_16_black (uint16_t v, bool alpha)
 {
-       memset (data()[0], 0, sample_size(0).height * stride()[0]);
+       memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
        for (int i = 1; i < 3; ++i) {
-               int16_t* p = reinterpret_cast<int16_t*> (data()[i]);
+               uint16_t* p = reinterpret_cast<uint16_t*> (data()[i]);
                int const lines = sample_size(i).height;
                for (int y = 0; y < lines; ++y) {
                        /* We divide by 2 here because we are writing 2 bytes at a time */
@@ -316,7 +317,7 @@ Image::yuv_16_black (uint16_t v, bool alpha)
        }
 
        if (alpha) {
-               memset (data()[3], 0, sample_size(3).height * stride()[3]);
+               memset (data()[3], 0, static_cast<size_t>(sample_size(3).height * stride()[3]));
        }
 }
 
@@ -345,7 +346,7 @@ Image::make_part_black (int x, int w)
                int const s = stride()[0];
                uint8_t* p = data()[0];
                for (int y = 0; y < h; y++) {
-                       memset (p + x * bpp, 0, w * bpp);
+                       memset (p + x * bpp, 0, static_cast<size_t>(w * bpp));
                        p += s;
                }
                break;
@@ -373,17 +374,17 @@ Image::make_black ()
        case AV_PIX_FMT_YUV422P:
        case AV_PIX_FMT_YUV444P:
        case AV_PIX_FMT_YUV411P:
-               memset (data()[0], 0, sample_size(0).height * stride()[0]);
-               memset (data()[1], eight_bit_uv, sample_size(1).height * stride()[1]);
-               memset (data()[2], eight_bit_uv, sample_size(2).height * stride()[2]);
+               memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
+               memset (data()[1], eight_bit_uv, static_cast<size_t>(sample_size(1).height * stride()[1]));
+               memset (data()[2], eight_bit_uv, static_cast<size_t>(sample_size(2).height * stride()[2]));
                break;
 
        case AV_PIX_FMT_YUVJ420P:
        case AV_PIX_FMT_YUVJ422P:
        case AV_PIX_FMT_YUVJ444P:
-               memset (data()[0], 0, sample_size(0).height * stride()[0]);
-               memset (data()[1], eight_bit_uv + 1, sample_size(1).height * stride()[1]);
-               memset (data()[2], eight_bit_uv + 1, sample_size(2).height * stride()[2]);
+               memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
+               memset (data()[1], eight_bit_uv + 1, static_cast<size_t>(sample_size(1).height * stride()[1]));
+               memset (data()[2], eight_bit_uv + 1, static_cast<size_t>(sample_size(2).height * stride()[2]));
                break;
 
        case AV_PIX_FMT_YUV422P9LE:
@@ -456,7 +457,7 @@ Image::make_black ()
        case AV_PIX_FMT_RGB48LE:
        case AV_PIX_FMT_RGB48BE:
        case AV_PIX_FMT_XYZ12LE:
-               memset (data()[0], 0, sample_size(0).height * stride()[0]);
+               memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
                break;
 
        case AV_PIX_FMT_UYVY422:
@@ -487,7 +488,7 @@ Image::make_transparent ()
                throw PixelFormatError ("make_transparent()", _pixel_format);
        }
 
-       memset (data()[0], 0, sample_size(0).height * stride()[0]);
+       memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
 }
 
 void
@@ -747,7 +748,7 @@ Image::copy (shared_ptr<const Image> other, Position<int> position)
        for (int ty = position.y, oy = 0; ty < size().height && oy < other->size().height; ++ty, ++oy) {
                uint8_t * const tp = data()[0] + ty * stride()[0] + position.x * 3;
                uint8_t * const op = other->data()[0] + oy * other->stride()[0];
-               memcpy (tp, op, N * 3);
+               memcpy (tp, op, static_cast<size_t>(N * 3));
        }
 }
 
@@ -758,7 +759,7 @@ Image::read_from_socket (shared_ptr<Socket> socket)
                uint8_t* p = data()[i];
                int const lines = sample_size(i).height;
                for (int y = 0; y < lines; ++y) {
-                       socket->read (p, line_size()[i]);
+                       socket->read (p, static_cast<size_t>(line_size()[i]));
                        p += stride()[i];
                }
        }
@@ -771,7 +772,7 @@ Image::write_to_socket (shared_ptr<Socket> socket) const
                uint8_t* p = data()[i];
                int const lines = sample_size(i).height;
                for (int y = 0; y < lines; ++y) {
-                       socket->write (p, line_size()[i]);
+                       socket->write (p, static_cast<size_t>(line_size()[i]));
                        p += stride()[i];
                }
        }
@@ -891,7 +892,7 @@ Image::allocate ()
                   |XXXwrittenXXX|<------line-size------------->|XXXwrittenXXXXXXwrittenXXX
                                                                               ^^^^ out of bounds
                */
-               _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * (sample_size(i).height + 1) + 32);
+               _data[i] = (uint8_t *) wrapped_av_malloc (static_cast<size_t>(_stride[i] * (sample_size(i).height + 1) + 32));
 #if HAVE_VALGRIND_MEMCHECK_H
                /* The data between the end of the line size and the stride is undefined but processed by
                   libswscale, causing lots of valgrind errors.  Mark it all defined to quell these errors.
@@ -914,7 +915,7 @@ Image::Image (Image const & other)
                uint8_t* q = other._data[i];
                int const lines = sample_size(i).height;
                for (int j = 0; j < lines; ++j) {
-                       memcpy (p, q, _line_size[i]);
+                       memcpy (p, q, static_cast<size_t>(_line_size[i]));
                        p += stride()[i];
                        q += other.stride()[i];
                }
@@ -933,7 +934,7 @@ Image::Image (AVFrame* frame)
                uint8_t* q = frame->data[i];
                int const lines = sample_size(i).height;
                for (int j = 0; j < lines; ++j) {
-                       memcpy (p, q, _line_size[i]);
+                       memcpy (p, q, static_cast<size_t>(_line_size[i]));
                        p += stride()[i];
                        /* AVFrame's linesize is what we call `stride' */
                        q += frame->linesize[i];
@@ -954,7 +955,7 @@ Image::Image (shared_ptr<const Image> other, bool aligned)
                uint8_t* q = other->data()[i];
                int const lines = sample_size(i).height;
                for (int j = 0; j < lines; ++j) {
-                       memcpy (p, q, line_size()[i]);
+                       memcpy (p, q, static_cast<size_t>(line_size()[i]));
                        p += stride()[i];
                        q += other->stride()[i];
                }
@@ -1071,7 +1072,7 @@ operator== (Image const & a, Image const & b)
                uint8_t* q = b.data()[c];
                int const lines = a.sample_size(c).height;
                for (int y = 0; y < lines; ++y) {
-                       if (memcmp (p, q, a.line_size()[c]) != 0) {
+                       if (memcmp(p, q, static_cast<size_t>(a.line_size()[c])) != 0) {
                                return false;
                        }
 
@@ -1218,7 +1219,7 @@ Image::memory_used () const
 {
        size_t m = 0;
        for (int i = 0; i < planes(); ++i) {
-               m += _stride[i] * sample_size(i).height;
+               m += static_cast<size_t>(_stride[i] * sample_size(i).height);
        }
        return m;
 }
@@ -1303,9 +1304,13 @@ Image::as_png () const
                throw EncodeError (N_("could not create PNG info struct"));
        }
 
-       png_set_IHDR (png_ptr, info_ptr, size().width, size().height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+       png_set_IHDR (
+               png_ptr, info_ptr,
+               static_cast<png_uint_32>(size().width), static_cast<png_uint_32>(size().height),
+               8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT
+               );
 
-       png_byte ** row_pointers = reinterpret_cast<png_byte **>(png_malloc(png_ptr, size().height * sizeof(png_byte *)));
+       png_byte ** row_pointers = reinterpret_cast<png_byte **>(png_malloc(png_ptr, static_cast<size_t>(size().height) * sizeof(png_byte *)));
        for (int i = 0; i < size().height; ++i) {
                row_pointers[i] = (png_byte *) (data()[0] + i * stride()[0]);
        }
index 15187b11b6aa27ef084e24ea759c27163603194f..4052d8c2f62d8f60d1af19f4e2214b847b8bf976 100644 (file)
@@ -55,7 +55,8 @@ ImageDecoder::pass ()
 
        if (!_image_content->still() || !_image) {
                /* Either we need an image or we are using moving images, so load one */
-               boost::filesystem::path path = _image_content->path (_image_content->still() ? 0 : _frame_video_position);
+               DCPOMATIC_ASSERT (_frame_video_position >= 0);
+               boost::filesystem::path path = _image_content->path (_image_content->still() ? 0 : static_cast<size_t>(_frame_video_position));
                if (valid_j2k_file (path)) {
                        AVPixelFormat pf;
                        if (_image_content->video->colour_conversion()) {
index 6586a0d09bc5ad10ce09660a14d159ce5c695f6f..1a949381dd4f858c106b1aba09b4c91df77511c3 100644 (file)
@@ -70,7 +70,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
        if (content->still ()) {
                _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (film->video_frame_rate ());
        } else {
-               _video_length = _image_content->number_of_paths ();
+               _video_length = static_cast<Frame>(_image_content->number_of_paths());
        }
 }
 
index 47f46e81d75ecbe5aa589c4b1fd592241a5f150d..aeb19917c2882c8914d2be88c45fa278e0d0718f 100644 (file)
@@ -36,8 +36,8 @@ ImageFilenameSorter::operator() (boost::filesystem::path a, boost::filesystem::p
        string an = extract_numbers (a);
        string bn = extract_numbers (b);
 
-       int const anl = an.length ();
-       int const bnl = bn.length ();
+       size_t const anl = an.length ();
+       size_t const bnl = bn.length ();
 
        if (anl > bnl) {
                bn = string(anl - bnl, '0') + bn;
index 943363d1a67da48109f246ed3b900c5e23312135..c18b3a6e6f8c5f183676466742c605443425061b 100644 (file)
@@ -185,7 +185,12 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio
        char buffer[4096];
        while (true) {
                int const N = zip_fread (file_in_zip, buffer, sizeof (buffer));
-               checked_fwrite (buffer, N, f, temp_cert.file());
+               if (N == -1) {
+                       zip_fclose (file_in_zip);
+                       zip_close (zip);
+                       return optional<string>(_("Could not read from ZIP file"));
+               }
+               checked_fwrite (buffer, static_cast<size_t>(N), f, temp_cert.file());
                if (N < int (sizeof (buffer))) {
                        break;
                }
index acf8bb05235e7018216824bfd484f0fa533b5d6a..29b50a577b17be15009c35434bac0e38f138110f 100644 (file)
@@ -108,7 +108,7 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
        if (xml->optional_number_child<int> ("Eye")) {
                _eye = static_cast<dcp::Eye> (xml->number_child<int> ("Eye"));
        }
-       _data = Data (xml->number_child<int> ("Size"));
+       _data = Data (xml->number_child<size_t>("Size"));
        /* This only matters when we are using J2KImageProxy for the preview, which
           will never use this constructor (which is only used for passing data to
           encode servers).  So we can put anything in here.  It's a bit of a hack.
@@ -238,7 +238,7 @@ J2KImageProxy::memory_used () const
        size_t m = _data.size();
        if (_image) {
                /* 3 components, 16-bits per pixel */
-               m += 3 * 2 * _image->size().width * _image->size().height;
+               m += static_cast<size_t>(3 * 2 * _image->size().width * _image->size().height);
        }
        return m;
 }
index 0ef1b8f380b1fc305366470b3278ce2be991c980..7c7c95f440152b95a0543e859dc3b451565ba89c 100644 (file)
@@ -142,7 +142,7 @@ write_directories (
        function<bool (boost::filesystem::path)> confirm_overwrite
        )
 {
-       int written = 0;
+       size_t written = 0;
 
        BOOST_FOREACH (list<KDMWithMetadataPtr> const & i, kdms) {
                boost::filesystem::path path = directory;
@@ -154,7 +154,7 @@ write_directories (
                written += i.size();
        }
 
-       return written;
+       return static_cast<int>(written);
 }
 
 
@@ -168,7 +168,7 @@ write_zip_files (
        function<bool (boost::filesystem::path)> confirm_overwrite
        )
 {
-       int written = 0;
+       size_t written = 0;
 
        BOOST_FOREACH (list<KDMWithMetadataPtr> const & i, kdms) {
                boost::filesystem::path path = directory;
@@ -183,7 +183,7 @@ write_zip_files (
                }
        }
 
-       return written;
+       return static_cast<size_t>(written);
 }
 
 
index b96b0fbe0edf48a809ba93f89c28e87de56a5b08..30045e2e44279aa10deb4f7924559622b6db98c2 100644 (file)
@@ -625,20 +625,22 @@ Playlist::move_later (shared_ptr<const Film> film, shared_ptr<Content> c)
        c->set_position (film, c->position() + next_c->length_after_trim(film));
 }
 
-int64_t
+size_t
 Playlist::required_disk_space (shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const
 {
-       int64_t video = uint64_t (j2k_bandwidth / 8) * length(film).seconds();
-       int64_t audio = uint64_t (audio_channels * audio_frame_rate * 3) * length(film).seconds();
+       size_t video = static_cast<size_t>(j2k_bandwidth / 8) * length(film).seconds();
+       size_t audio = static_cast<size_t>(audio_channels * audio_frame_rate * 3) * length(film).seconds();
 
        BOOST_FOREACH (shared_ptr<Content> i, content()) {
                shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (i);
                if (d) {
+                       DCPTime const len = d->length_after_trim(film);
+                       DCPOMATIC_ASSERT (len.get() >= 0);
                        if (d->reference_video()) {
-                               video -= uint64_t (j2k_bandwidth / 8) * d->length_after_trim(film).seconds();
+                               video -= static_cast<size_t>(j2k_bandwidth / 8) * len.seconds();
                        }
                        if (d->reference_audio()) {
-                               audio -= uint64_t (audio_channels * audio_frame_rate * 3) * d->length_after_trim(film).seconds();
+                               audio -= static_cast<size_t>(audio_channels * audio_frame_rate * 3) * len.seconds();
                        }
                }
        }
index 51c13e33f19a1af510ffcaf5763d65f7689bae7b..704a91eace3f21f5bac69f42e477f14527579b29 100644 (file)
@@ -61,7 +61,7 @@ public:
 
        dcpomatic::DCPTime length (boost::shared_ptr<const Film> film) const;
        boost::optional<dcpomatic::DCPTime> start () const;
-       int64_t required_disk_space (boost::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
+       size_t required_disk_space (boost::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
 
        int best_video_frame_rate () const;
        dcpomatic::DCPTime video_end (boost::shared_ptr<const Film> film) const;
index 770130798010ab0bd9290f0fa80fac8daf112e0d..17041f96a0be3259ee1f3b910addc463040a0c35 100644 (file)
@@ -766,7 +766,7 @@ ReelWriter::existing_picture_frame_ok (FILE* asset_file, shared_ptr<InfoFileHand
        bool ok = true;
 
        /* Read the data from the asset and hash it */
-       dcpomatic_fseek (asset_file, info.offset, SEEK_SET);
+       dcpomatic_fseek (asset_file, static_cast<int64_t>(info.offset), SEEK_SET);
        Data data (info.size);
        size_t const read = fread (data.data().get(), 1, data.size(), asset_file);
        LOG_GENERAL ("Read %1 bytes of asset data; wanted %2", read, info.size);
index de33f9380b1b09dfd4a9cde380874aba93e9251f..347125712e84680263fc7b4fc6e76efda6bfa993 100644 (file)
 #include "cross.h"
 #include "font.h"
 #include "dcpomatic_assert.h"
+#include "warnings.h"
 #include <dcp/raw_convert.h>
 #include <fontconfig/fontconfig.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <cairomm/cairomm.h>
 #include <pangomm.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <pango/pangocairo.h>
 #ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
 #include <pango/pangocairo.h>
index bfec507ea4f84a5b22e82271e5966e33e9771e2a..92f26540d47ff3175f7f35de0d5d1293b7b23304 100644 (file)
@@ -57,7 +57,7 @@ Frame
 VideoRingBuffers::size () const
 {
        boost::mutex::scoped_lock lm (_mutex);
-       return _data.size ();
+       return static_cast<Frame>(_data.size());
 }
 
 bool
diff --git a/src/lib/warnings.h b/src/lib/warnings.h
new file mode 100644 (file)
index 0000000..c9ecdb1
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#define DCPOMATIC_DISABLE_WARNINGS \
+  _Pragma("GCC diagnostic push") \
+  _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"")
+  _Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
+
+#define DCPOMATIC_ENABLE_WARNINGS \
+  _Pragma("GCC diagnostic pop")
index 9cd99a265f553b9e51f39a600e20dbe340a0a9a7..ae665284762f109415dba7999b9be21074fdc1ce 100644 (file)
@@ -646,9 +646,12 @@ private:
 
        void file_history (wxCommandEvent& event)
        {
+               if (event.GetId() < ID_file_history) {
+                       return;
+               }
+               size_t const n = event.GetId() - ID_file_history;
                vector<boost::filesystem::path> history = Config::instance()->history ();
-               int n = event.GetId() - ID_file_history;
-               if (n >= 0 && n < static_cast<int> (history.size ()) && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
+               if (n < history.size() && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
                        load_film (history[n]);
                }
        }
@@ -1394,7 +1397,7 @@ private:
                delete _history_separator;
                _history_separator = 0;
 
-               int pos = _history_position;
+               unsigned int pos = _history_position;
 
                /* Clear out non-existant history items before we re-build the menu */
                Config::instance()->clean_history ();
@@ -1492,7 +1495,7 @@ private:
        wxMenu* _file_menu;
        shared_ptr<Film> _film;
        int _history_items;
-       int _history_position;
+       unsigned int _history_position;
        wxMenuItem* _history_separator;
        boost::signals2::scoped_connection _config_changed_connection;
        boost::signals2::scoped_connection _analytics_message_connection;
index 3057416b29c623e1ad7b7c8fc06b223e89ccf221..e20e5289bc30901948d51a7d4b1a8a779fe8f927 100644 (file)
  *
  */
 
-#include <boost/signals2.hpp>
-#include <wx/wx.h>
 #include "lib/audio_mapping.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
+#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
+#include <boost/signals2.hpp>
 
 /** @class AudioMappingView
  *  @brief This class displays the mapping of one set of audio channels to another,
index 5c366ca7b0dbe2cc9d9f61e8eba4002b5e71c6ff..cfdab5f3c2c39393e7eaefcb5fe1f6b5df991444 100644 (file)
 #include "lib/dcpomatic_time.h"
 #include "lib/player.h"
 #include "lib/text_ring_buffers.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 class Butler;
 class FilmViewer;
index 7d854224d232a0b939758cd4094e3951d0604a65..9a96bcc1b6b4632d7f9e0fbf315eced2e0d740ae 100644 (file)
 #include "lib/string_text_file_content.h"
 #include "lib/string_text_file.h"
 #include "lib/dcpomatic_log.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/notebook.h>
 #include <wx/listctrl.h>
 #include <wx/display.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/filesystem.hpp>
 #include <boost/foreach.hpp>
 #include <iostream>
@@ -664,7 +667,7 @@ ContentPanel::set_selection (ContentList cl)
        _no_check_selection = true;
 
        ContentList content = _film->content ();
-       for (size_t i = 0; i < content.size(); ++i) {
+       for (long int i = 0; i < static_cast<long int>(content.size()); ++i) {
                if (find(cl.begin(), cl.end(), content[i]) != cl.end()) {
                        _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
                } else {
index d5f502eeaf2a59608be487a9ccfb520feabb8d85..507d353601a5c46fdda063d248309dfa764c4e41 100644 (file)
 #ifndef DCPOMATIC_CONTENT_SUB_PANEL_H
 #define DCPOMATIC_CONTENT_SUB_PANEL_H
 
-#include <boost/shared_ptr.hpp>
-#include <wx/wx.h>
-#include "lib/film.h"
 #include "lib/config.h"
+#include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
+#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
+#include <boost/shared_ptr.hpp>
 
 class ContentPanel;
 class Content;
index 334e9bb68202449a8053324cf5d6b854239a9085..3f4a65ab1bc1e58f1258ea6a6de219ee2e7c17a4 100644 (file)
 */
 
 #include "lib/content_store.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/listctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 #include <vector>
index b9c4604b6b298b7cd80d785ff759bbad58079e1e..1d6273af68088172e9e9702ee1c496a1a5e9d4a5 100644 (file)
 #include "lib/dcpomatic_time.h"
 #include "lib/types.h"
 #include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 
index 3452d5765b943f346db9e1fb015b006e2e72e06e..21eb2e8ed017b2f4c72f79fe30dd6a94edbdc019 100644 (file)
 #include "custom_scale_dialog.h"
 #include "wx_util.h"
 #include "lib/util.h"
+#include "lib/warnings.h"
 #include <dcp/raw_convert.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/propgrid/property.h>
 #include <wx/propgrid/props.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 
 using boost::optional;
index 4c9ccf388223b8bd161d196b4a751f2f58317113..23b83b46920f9a4877157efbdb5fd541035ebbd4 100644 (file)
 
 #include "table_dialog.h"
 #include <dcp/types.h>
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/spinctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 
 class CustomScaleDialog : public TableDialog
index a2fbf808f768b39c77e5f56a1e9e7ea0cff57ac9..ef241a0cab5d046ba9b2edcfed25af74a6f34627 100644 (file)
 
 */
 
+#include "lib/warnings.h"
 #include <dcp/certificate.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/notebook.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 class DownloadCertificatePanel;
 
index 2ad03f7c0c96d1a00a82d8844684b8a52bc0b53c..ba355f8138c30c3c4aa46ecace7f75a7dc3fbf3d 100644 (file)
 #ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
 #define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
 
+#include "lib/warnings.h"
 #include <dcp/certificate.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/optional.hpp>
 
 class DownloadCertificateDialog;
index ca58009a4b7059027700b9fde7181380742f26a1..df69405c4ead7d36a400c662d831d20072ecc910 100644 (file)
 
 #include "wx_util.h"
 #include "dcpomatic_button.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/listctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/function.hpp>
 #include <vector>
 
index b8d862f8112ea03ebddf64d8976e22a0f9240850..84a1d361b7e3af37afec1085930a7e5b5156fdd6 100644 (file)
  */
 
 #include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/signals2.hpp>
 
 class wxNotebook;
index 21a35c227465e3631444a9cac687bccc84c77bd3..870832f4df834e994cf479789dd0e3e148f9282c 100644 (file)
@@ -622,7 +622,7 @@ FilmViewer::average_latency () const
                 total += i;
         }
 
-        return total / _latency_history.size();
+        return total / static_cast<Frame>(_latency_history.size());
 }
 
 void
index 29985a5816bb701b44ec3e0a5c0e92672b8a4d8c..e08cc8e8d99cfb967d5092e69d2fbdf83edd9c09 100644 (file)
 #include "lib/player_text.h"
 #include "lib/timer.h"
 #include "lib/signaller.h"
+#include "lib/warnings.h"
 #include <RtAudio.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 class wxToggleButton;
 class FFmpegPlayer;
@@ -179,7 +182,7 @@ private:
        dcp::Size _out_size;
 
        RtAudio _audio;
-       int _audio_channels;
+       unsigned int _audio_channels;
        unsigned int _audio_block_size;
        bool _playing;
        int _suspended;
index 3ba4a09f5992342ef2e0e8593a20e80d872bde7f..775995f38f9c1fb4972e0594d32264ad010edcaf 100644 (file)
  *  @brief A dialog to select FFmpeg filters.
  */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/signals2.hpp>
 
 class Film;
index f4f23cb283c7dba8eff4a7e9546a80cb54c9271d..e10075f3ad30418c2eb2e5a7712753ad3e1e054c 100644 (file)
 */
 
 #include "focus_manager.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/textctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 FocusManager* FocusManager::_instance;
 
index 3675b8ddcb6025dce1c84b37a917e6b3d7ee2e57..14506bec5470025b136ff99e704563fd7ee0930a 100644 (file)
 #include "video_view.h"
 #include "lib/signaller.h"
 #include "lib/position.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <wx/glcanvas.h>
 #include <dcp/util.h>
 #include <boost/atomic.hpp>
index 40fd89a2c66cce72ecaed2701c7a47afbbad450d..b2de66172b0971fbee2c05c3aa9e2f786273eed9 100644 (file)
 #ifndef DCPOMATIC_I18N_HOOK_H
 #define DCPOMATIC_I18N_HOOK_H
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <map>
 
 class I18NHook
index 77114a97c382b170f06758d58d1d8f2d41fb52af..2e471532fe1e7399a7e9b0978bbafcfe6e99fa80 100644 (file)
  *  @brief Class which is a wxPanel for showing the progress of jobs.
  */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/shared_ptr.hpp>
 #include <list>
 
index b61da04f84da3ff1dd6dbba67f3c1e0187c1a7d5..729f619fad31cce25df68612476965324228b071 100644 (file)
@@ -179,7 +179,7 @@ JobView::cancel_clicked (wxCommandEvent &)
 }
 
 void
-JobView::insert (int pos)
+JobView::insert (size_t pos)
 {
        _table->Insert (pos, _gauge_message, 1, wxEXPAND | wxLEFT | wxRIGHT);
        _table->Insert (pos + 1, _controls, 1, wxALIGN_CENTER_VERTICAL | wxALL, 3);
index d58a90831e37ae075faa54f730fcc338f07e508a..1971036bd358698f58f00a4032da5656606e4240 100644 (file)
@@ -48,7 +48,7 @@ public:
 
        void setup ();
        void maybe_pulse ();
-       void insert (int pos);
+       void insert (size_t pos);
        void detach ();
 
        boost::shared_ptr<Job> job () const {
index fbbaa1aee9fd2c12178d87ce6303c51b4a8b1a2a..e2c261873959074522a02a6356794beb0495388c 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 #include <list>
index 9da73762f38d44860efedb7ac0780805090e5366..c8cc14676a3f8f87b0b06cba96519a8f1912a9ec 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/signals2.hpp>
 #include <boost/filesystem.hpp>
 
index 72ec7ad1fd35ef963862a604df911d10f7b88fff..e8fd5f9e5950b789fd8dbf17d6276041ec356cd7 100644 (file)
@@ -202,7 +202,7 @@ PlaylistControls::previous_clicked ()
 bool
 PlaylistControls::can_do_next ()
 {
-       return _selected_playlist && (_selected_playlist_position + 1) < int(_playlists[*_selected_playlist].get().size());
+       return _selected_playlist && (_selected_playlist_position + 1) < _playlists[*_selected_playlist].get().size();
 }
 
 void
@@ -321,7 +321,7 @@ PlaylistControls::get_kdm_from_directory (shared_ptr<DCPContent> dcp)
 void
 PlaylistControls::spl_selection_changed ()
 {
-       long int selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+       size_t const selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (selected == -1) {
                _current_spl_view->DeleteAllItems ();
                _selected_playlist = boost::none;
@@ -343,7 +343,7 @@ PlaylistControls::spl_selection_changed ()
 }
 
 void
-PlaylistControls::select_playlist (int selected, int position)
+PlaylistControls::select_playlist (size_t selected, size_t position)
 {
        log (wxString::Format("load-playlist %s", std_to_wx(_playlists[selected].name()).data()));
 
@@ -351,7 +351,7 @@ PlaylistControls::select_playlist (int selected, int position)
 
        BOOST_FOREACH (SPLEntry const & i, _playlists[selected].get()) {
                dialog.Pulse ();
-               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i.content);
+               shared_ptr<DCPContent> dcp = dynamic_ponter_cast<DCPContent> (i.content);
                if (dcp && dcp->needs_kdm()) {
                        optional<dcp::EncryptedKDM> kdm;
                        kdm = get_kdm_from_directory (dcp);
@@ -441,7 +441,7 @@ PlaylistControls::viewer_finished ()
        }
 
        _selected_playlist_position++;
-       if (_selected_playlist_position < int(_playlists[*_selected_playlist].get().size())) {
+       if (_selected_playlist_position < _playlists[*_selected_playlist].get().size()) {
                /* Next piece of content on the SPL */
                update_current_content ();
                _viewer->start ();
index 4f144834ab342c0cb3ee4c90dfa7ce3197d80dd1..9d7fdea917e8cd2aa448f2d6ddd18c3c7a8a5f99 100644 (file)
@@ -50,7 +50,7 @@ private:
        void update_content_directory ();
        void update_playlist_directory ();
        void spl_selection_changed ();
-       void select_playlist (int selected, int position);
+       void select_playlist (size_t selected, size_t position);
        void started ();
        void stopped ();
        void setup_sensitivity ();
@@ -78,5 +78,5 @@ private:
 
        std::vector<SPL> _playlists;
        boost::optional<int> _selected_playlist;
-       int _selected_playlist_position;
+       size_t _selected_playlist_position;
 };
index a3b05173a40bdfb8189cdacdf5c39ccf2fdbd5fd..6b99065f632b05a224d990dde62978ee2810b600 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 class QuestionDialog : public wxDialog
 {
index 0c4fb6a865345b0331849b0f14d619b07f3f3afd..38d896c8f8674a2edd33c8ccc802ec738edbc22d 100644 (file)
 
 */
 
+#include "table_dialog.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/spinctrl.h>
-#include "table_dialog.h"
+DCPOMATIC_ENABLE_WARNINGS
 
 class RepeatDialog : public TableDialog
 {
index 510297efb67a285e2bc06b722042b3e90519182d..d5ea461aa8cad4201c6029a0d102154e84618be0 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
 #include <wx/srchctrl.h>
 #include <wx/treectrl.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 #include <list>
index 48a31a839160223d4408da4347a6e3575d55ab8a..da51c9c3a072322cb1a28d371f212130f5877978 100644 (file)
  *  one of those fonts.
  */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/filesystem.hpp>
 #include <boost/optional.hpp>
 #include <vector>
index a5015ee59c02f4921233922455a5e774b5fbce38..fdc2022c84f6a39033f54794ecd09927d1cf35f1 100644 (file)
 #ifndef DCPOMATIC_TABLE_DIALOG_H
 #define DCPOMATIC_TABLE_DIALOG_H
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 
 class TableDialog : public wxDialog
 {
index 9e83c00430709cc158dc1b23d6f530548c01ff39..53b0ce2b8886214128ce476b1de2c2efe6f1f05d 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/signals2.hpp>
 
 class wxSpinCtrl;
index 27cfed53eef989373eee4db604886d4890c3facb..2573e3cb311b970cc181c1a76825b04beaa955bc 100644 (file)
 #define DCPOMATIC_TIMELINE_CONTENT_VIEW_H
 
 #include "lib/types.h"
+#include "lib/warnings.h"
 #include "timeline_view.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/signals2.hpp>
 
 class Content;
index d2f21863d606eaf389c788c5a1bbb31e1e1b8517..47e5d19a8e0c27425d982b0f473cf2c0b1915633 100644 (file)
 
 */
 
+#include "lib/warnings.h"
 #include <dcp/verify.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <list>
 
 class wxRichTextCtrl;
index 3801860740008cf82550a5431f4d50de46893100..1e38f58906b35d4b7f5d7b00802bcb1126943785 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 #include <boost/signals2.hpp>
index af938b670f54121b9d478fe9f4546c3a69d370e7..517b6407a744f297270e7a52649fb8d5a586d778 100644 (file)
 #ifndef DCPOMATIC_WX_UTIL_H
 #define DCPOMATIC_WX_UTIL_H
 
+#include "lib/warnings.h"
 #include "lib/dcpomatic_time.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <wx/gbsizer.h>
 #include <boost/function.hpp>
 #include <boost/thread.hpp>
index 32d32f98879f8ddefcf16f7d19447085d5d873a6..7bc75468c7add82bb26de987208766bdaefae002 100644 (file)
@@ -513,7 +513,7 @@ write_image (shared_ptr<const Image> image, boost::filesystem::path file, string
 {
        using namespace MagickCore;
 
-       Magick::Image m (image->size().width, image->size().height, format.c_str(), pixel_type, (void *) image->data()[0]);
+       Magick::Image m (static_cast<size_t>(image->size().width), static_cast<size_t>(image->size().height), format.c_str(), pixel_type, reinterpret_cast<void *>(image->data()[0]));
        m.write (file.string ());
 }
 
index 77108af46b586f267dc53db0830f671039148a09..b620a68a0802195982b02ddf365a22563cb2e8ce 100644 (file)
 
 */
 
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
 #include <Magick++.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/filesystem.hpp>
 #include <boost/shared_ptr.hpp>
 
diff --git a/wscript b/wscript
index 72db83e2cc638ada4377d2f7dd6b62001518cdbf..1c8fc4fd74a8605b743f116ba03d662c7630dfbe 100644 (file)
--- a/wscript
+++ b/wscript
@@ -75,6 +75,7 @@ def options(opt):
     opt.add_option('--variant',           help='build variant (swaroop-studio, swaroop-theater)', choices=['swaroop-studio', 'swaroop-theater'])
     opt.add_option('--use-lld',           action='store_true', default=False, help='use lld linker')
     opt.add_option('--enable-disk',       action='store_true', default=False, help='build dcpomatic2_disk tool; requires Boost process, lwext4 and nanomsg libraries')
+    opt.add_option('--warnings-are-errors', action='store_true', default=False, help='build with -Werror')
 
 def configure(conf):
     conf.load('compiler_cxx')
@@ -113,6 +114,9 @@ def configure(conf):
                                        '-Wno-parentheses',
                                        '-D_FILE_OFFSET_BITS=64'])
 
+    if conf.options.warnings_are_errors:
+        conf.env.append_value('CXXFLAGS', '-Werror')
+
     if conf.options.force_cpp11:
         conf.env.append_value('CXXFLAGS', ['-std=c++11', '-DBOOST_NO_CXX11_SCOPED_ENUMS'])
 
@@ -325,7 +329,7 @@ def configure(conf):
         conf.check_cc(fragment="""
                                #include <libssh/libssh.h>\n
                                int main () {\n
-                               ssh_session s = ssh_new ();\n
+                               ssh_new ();\n
                                return 0;\n
                                }
                                """,