summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/analyse_audio_job.cc21
-rw-r--r--src/lib/analyse_audio_job.h4
-rw-r--r--src/lib/audio_buffers.cc22
-rw-r--r--src/lib/audio_mapping.cc23
-rw-r--r--src/lib/cinema_sound_processor.cc4
-rw-r--r--src/lib/colour_conversion.cc4
-rw-r--r--src/lib/compose.hpp2
-rw-r--r--src/lib/cross_linux.cc7
-rw-r--r--src/lib/dcpomatic_socket.cc8
-rw-r--r--src/lib/dcpomatic_socket.h4
-rw-r--r--src/lib/digester.cc2
-rw-r--r--src/lib/digester.h2
-rw-r--r--src/lib/edid.cc6
-rw-r--r--src/lib/ffmpeg_decoder.cc9
-rw-r--r--src/lib/ffmpeg_image_proxy.cc14
-rw-r--r--src/lib/ffmpeg_image_proxy.h2
-rw-r--r--src/lib/film.cc2
-rw-r--r--src/lib/image.cc55
-rw-r--r--src/lib/image_decoder.cc3
-rw-r--r--src/lib/image_examiner.cc2
-rw-r--r--src/lib/image_filename_sorter.cc4
-rw-r--r--src/lib/internet.cc7
-rw-r--r--src/lib/j2k_image_proxy.cc4
-rw-r--r--src/lib/kdm_with_metadata.cc8
-rw-r--r--src/lib/playlist.cc12
-rw-r--r--src/lib/playlist.h2
-rw-r--r--src/lib/reel_writer.cc2
-rw-r--r--src/lib/render_text.cc3
-rw-r--r--src/lib/video_ring_buffers.cc2
-rw-r--r--src/lib/warnings.h27
-rw-r--r--src/tools/dcpomatic.cc11
-rw-r--r--src/wx/audio_mapping_view.h7
-rw-r--r--src/wx/closed_captions_dialog.h3
-rw-r--r--src/wx/content_panel.cc5
-rw-r--r--src/wx/content_sub_panel.h9
-rw-r--r--src/wx/content_view.h3
-rw-r--r--src/wx/controls.h3
-rw-r--r--src/wx/custom_scale_dialog.cc3
-rw-r--r--src/wx/custom_scale_dialog.h3
-rw-r--r--src/wx/download_certificate_dialog.h3
-rw-r--r--src/wx/download_certificate_panel.h3
-rw-r--r--src/wx/editable_list.h3
-rw-r--r--src/wx/film_editor.h3
-rw-r--r--src/wx/film_viewer.cc2
-rw-r--r--src/wx/film_viewer.h5
-rw-r--r--src/wx/filter_dialog.h3
-rw-r--r--src/wx/focus_manager.cc3
-rw-r--r--src/wx/gl_video_view.h3
-rw-r--r--src/wx/i18n_hook.h3
-rw-r--r--src/wx/job_manager_view.h3
-rw-r--r--src/wx/job_view.cc2
-rw-r--r--src/wx/job_view.h2
-rw-r--r--src/wx/markers_dialog.h3
-rw-r--r--src/wx/player_stress_tester.h3
-rw-r--r--src/wx/playlist_controls.cc10
-rw-r--r--src/wx/playlist_controls.h4
-rw-r--r--src/wx/question_dialog.h3
-rw-r--r--src/wx/repeat_dialog.h5
-rw-r--r--src/wx/screens_panel.h3
-rw-r--r--src/wx/system_font_dialog.h3
-rw-r--r--src/wx/table_dialog.h3
-rw-r--r--src/wx/time_picker.h3
-rw-r--r--src/wx/timeline_content_view.h3
-rw-r--r--src/wx/verify_dcp_dialog.h3
-rw-r--r--src/wx/video_waveform_plot.h3
-rw-r--r--src/wx/wx_util.h3
-rw-r--r--test/test.cc2
-rw-r--r--test/test.h3
-rw-r--r--wscript6
69 files changed, 291 insertions, 124 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc
index acd730a68..47beb0d43 100644
--- a/src/lib/analyse_audio_job.cc
+++ b/src/lib/analyse_audio_job.cc
@@ -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()));
diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h
index f7cc3e256..8f88b0fa1 100644
--- a/src/lib/analyse_audio_job.h
+++ b/src/lib/analyse_audio_job.h
@@ -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;
diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc
index cfe762659..739441b4c 100644
--- a/src/lib/audio_buffers.cc
+++ b/src/lib/audio_buffers.cc
@@ -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 */
diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc
index 05dfb7e89..e2f681680 100644
--- a/src/lib/audio_mapping.cc
+++ b/src/lib/audio_mapping.cc
@@ -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]);
}
}
diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc
index 1a3ba5a0f..9f1048274 100644
--- a/src/lib/cinema_sound_processor.cc
+++ b/src/lib/cinema_sound_processor.cc
@@ -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
diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc
index 2e052060e..93605b4c7 100644
--- a/src/lib/colour_conversion.cc
+++ b/src/lib/colour_conversion.cc
@@ -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 ());
}
diff --git a/src/lib/compose.hpp b/src/lib/compose.hpp
index 2c44f148b..37ad5efa1 100644
--- a/src/lib/compose.hpp
+++ b/src/lib/compose.hpp
@@ -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 {
diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc
index 25fd3490e..c76293ce8 100644
--- a/src/lib/cross_linux.cc
+++ b/src/lib/cross_linux.cc
@@ -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.) */
diff --git a/src/lib/dcpomatic_socket.cc b/src/lib/dcpomatic_socket.cc
index a0a7a1cf3..f2c8d12bf 100644
--- a/src/lib/dcpomatic_socket.cc
+++ b/src/lib/dcpomatic_socket.cc
@@ -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);
diff --git a/src/lib/dcpomatic_socket.h b/src/lib/dcpomatic_socket.h
index 1fa0b046f..6f6f8cece 100644
--- a/src/lib/dcpomatic_socket.h
+++ b/src/lib/dcpomatic_socket.h
@@ -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
diff --git a/src/lib/digester.cc b/src/lib/digester.cc
index 452452ba4..b2d2239e3 100644
--- a/src/lib/digester.cc
+++ b/src/lib/digester.cc
@@ -76,7 +76,7 @@ Digester::get (uint8_t* buffer) const
}
-int
+size_t
Digester::size () const
{
return MD5_DIGEST_SIZE;
diff --git a/src/lib/digester.h b/src/lib/digester.h
index 6cdaf2331..54626c10c 100644
--- a/src/lib/digester.h
+++ b/src/lib/digester.h
@@ -42,7 +42,7 @@ public:
void get (uint8_t* buffer) const;
- int size () const;
+ size_t size () const;
private:
mutable md5_ctx _context;
diff --git a/src/lib/edid.cc b/src/lib/edid.cc
index 3df65d325..bb078bb7f 100644
--- a/src/lib/edid.cc
+++ b/src/lib/edid.cc
@@ -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);
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index cfaf0361b..8cf68a208 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -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 ()) {
diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc
index db6059266..65c3ae29b 100644
--- a/src/lib/ffmpeg_image_proxy.cc
+++ b/src/lib/ffmpeg_image_proxy.cc
@@ -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;
}
diff --git a/src/lib/ffmpeg_image_proxy.h b/src/lib/ffmpeg_image_proxy.h
index aa77003a4..139296d9b 100644
--- a/src/lib/ffmpeg_image_proxy.h
+++ b/src/lib/ffmpeg_image_proxy.h
@@ -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.
*/
diff --git a/src/lib/film.cc b/src/lib/film.cc
index cf7d04933..719a16f9c 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -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());
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 002c7df9a..e78358093 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -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]);
}
diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc
index 15187b11b..4052d8c2f 100644
--- a/src/lib/image_decoder.cc
+++ b/src/lib/image_decoder.cc
@@ -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()) {
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
index 6586a0d09..1a949381d 100644
--- a/src/lib/image_examiner.cc
+++ b/src/lib/image_examiner.cc
@@ -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());
}
}
diff --git a/src/lib/image_filename_sorter.cc b/src/lib/image_filename_sorter.cc
index 47f46e81d..aeb19917c 100644
--- a/src/lib/image_filename_sorter.cc
+++ b/src/lib/image_filename_sorter.cc
@@ -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;
diff --git a/src/lib/internet.cc b/src/lib/internet.cc
index 943363d1a..c18b3a6e6 100644
--- a/src/lib/internet.cc
+++ b/src/lib/internet.cc
@@ -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;
}
diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc
index acf8bb052..29b50a577 100644
--- a/src/lib/j2k_image_proxy.cc
+++ b/src/lib/j2k_image_proxy.cc
@@ -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;
}
diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc
index 0ef1b8f38..7c7c95f44 100644
--- a/src/lib/kdm_with_metadata.cc
+++ b/src/lib/kdm_with_metadata.cc
@@ -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);
}
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index b96b0fbe0..30045e2e4 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -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();
}
}
}
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 51c13e33f..704a91eac 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -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;
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc
index 770130798..17041f96a 100644
--- a/src/lib/reel_writer.cc
+++ b/src/lib/reel_writer.cc
@@ -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);
diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc
index de33f9380..347125712 100644
--- a/src/lib/render_text.cc
+++ b/src/lib/render_text.cc
@@ -24,10 +24,13 @@
#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>
diff --git a/src/lib/video_ring_buffers.cc b/src/lib/video_ring_buffers.cc
index bfec507ea..92f26540d 100644
--- a/src/lib/video_ring_buffers.cc
+++ b/src/lib/video_ring_buffers.cc
@@ -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
index 000000000..c9ecdb19f
--- /dev/null
+++ b/src/lib/warnings.h
@@ -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")
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 9cd99a265..ae6652847 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -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;
diff --git a/src/wx/audio_mapping_view.h b/src/wx/audio_mapping_view.h
index 3057416b2..e20e5289b 100644
--- a/src/wx/audio_mapping_view.h
+++ b/src/wx/audio_mapping_view.h
@@ -23,9 +23,12 @@
*
*/
-#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,
diff --git a/src/wx/closed_captions_dialog.h b/src/wx/closed_captions_dialog.h
index 5c366ca7b..cfdab5f3c 100644
--- a/src/wx/closed_captions_dialog.h
+++ b/src/wx/closed_captions_dialog.h
@@ -21,7 +21,10 @@
#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;
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 7d854224d..9a96bcc1b 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -43,10 +43,13 @@
#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 {
diff --git a/src/wx/content_sub_panel.h b/src/wx/content_sub_panel.h
index d5f502eea..507d35360 100644
--- a/src/wx/content_sub_panel.h
+++ b/src/wx/content_sub_panel.h
@@ -21,10 +21,13 @@
#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;
diff --git a/src/wx/content_view.h b/src/wx/content_view.h
index 334e9bb68..3f4a65ab1 100644
--- a/src/wx/content_view.h
+++ b/src/wx/content_view.h
@@ -19,7 +19,10 @@
*/
#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>
diff --git a/src/wx/controls.h b/src/wx/controls.h
index b9c4604b6..1d6273af6 100644
--- a/src/wx/controls.h
+++ b/src/wx/controls.h
@@ -24,7 +24,10 @@
#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>
diff --git a/src/wx/custom_scale_dialog.cc b/src/wx/custom_scale_dialog.cc
index 3452d5765..21eb2e8ed 100644
--- a/src/wx/custom_scale_dialog.cc
+++ b/src/wx/custom_scale_dialog.cc
@@ -22,10 +22,13 @@
#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;
diff --git a/src/wx/custom_scale_dialog.h b/src/wx/custom_scale_dialog.h
index 4c9ccf388..23b83b469 100644
--- a/src/wx/custom_scale_dialog.h
+++ b/src/wx/custom_scale_dialog.h
@@ -21,8 +21,11 @@
#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
diff --git a/src/wx/download_certificate_dialog.h b/src/wx/download_certificate_dialog.h
index a2fbf808f..ef241a0ca 100644
--- a/src/wx/download_certificate_dialog.h
+++ b/src/wx/download_certificate_dialog.h
@@ -18,9 +18,12 @@
*/
+#include "lib/warnings.h"
#include <dcp/certificate.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/notebook.h>
+DCPOMATIC_ENABLE_WARNINGS
class DownloadCertificatePanel;
diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h
index 2ad03f7c0..ba355f813 100644
--- a/src/wx/download_certificate_panel.h
+++ b/src/wx/download_certificate_panel.h
@@ -21,8 +21,11 @@
#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;
diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h
index ca58009a4..df69405c4 100644
--- a/src/wx/editable_list.h
+++ b/src/wx/editable_list.h
@@ -23,8 +23,11 @@
#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>
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index b8d862f81..84a1d361b 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -23,7 +23,10 @@
*/
#include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
class wxNotebook;
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 21a35c227..870832f4d 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -622,7 +622,7 @@ FilmViewer::average_latency () const
total += i;
}
- return total / _latency_history.size();
+ return total / static_cast<Frame>(_latency_history.size());
}
void
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 29985a581..e08cc8e8d 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -28,8 +28,11 @@
#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;
diff --git a/src/wx/filter_dialog.h b/src/wx/filter_dialog.h
index 3ba4a09f5..775995f38 100644
--- a/src/wx/filter_dialog.h
+++ b/src/wx/filter_dialog.h
@@ -22,7 +22,10 @@
* @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;
diff --git a/src/wx/focus_manager.cc b/src/wx/focus_manager.cc
index f4f23cb28..e10075f3a 100644
--- a/src/wx/focus_manager.cc
+++ b/src/wx/focus_manager.cc
@@ -19,7 +19,10 @@
*/
#include "focus_manager.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/textctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
FocusManager* FocusManager::_instance;
diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h
index 3675b8ddc..14506bec5 100644
--- a/src/wx/gl_video_view.h
+++ b/src/wx/gl_video_view.h
@@ -21,7 +21,10 @@
#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>
diff --git a/src/wx/i18n_hook.h b/src/wx/i18n_hook.h
index 40fd89a2c..b2de66172 100644
--- a/src/wx/i18n_hook.h
+++ b/src/wx/i18n_hook.h
@@ -21,7 +21,10 @@
#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
diff --git a/src/wx/job_manager_view.h b/src/wx/job_manager_view.h
index 77114a97c..2e471532f 100644
--- a/src/wx/job_manager_view.h
+++ b/src/wx/job_manager_view.h
@@ -22,7 +22,10 @@
* @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>
diff --git a/src/wx/job_view.cc b/src/wx/job_view.cc
index b61da04f8..729f619fa 100644
--- a/src/wx/job_view.cc
+++ b/src/wx/job_view.cc
@@ -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);
diff --git a/src/wx/job_view.h b/src/wx/job_view.h
index d58a90831..1971036bd 100644
--- a/src/wx/job_view.h
+++ b/src/wx/job_view.h
@@ -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 {
diff --git a/src/wx/markers_dialog.h b/src/wx/markers_dialog.h
index fbbaa1aee..e2c261873 100644
--- a/src/wx/markers_dialog.h
+++ b/src/wx/markers_dialog.h
@@ -18,7 +18,10 @@
*/
+#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>
diff --git a/src/wx/player_stress_tester.h b/src/wx/player_stress_tester.h
index 9da73762f..c8cc14676 100644
--- a/src/wx/player_stress_tester.h
+++ b/src/wx/player_stress_tester.h
@@ -18,7 +18,10 @@
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
#include <boost/filesystem.hpp>
diff --git a/src/wx/playlist_controls.cc b/src/wx/playlist_controls.cc
index 72ec7ad1f..e8fd5f9e5 100644
--- a/src/wx/playlist_controls.cc
+++ b/src/wx/playlist_controls.cc
@@ -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 ();
diff --git a/src/wx/playlist_controls.h b/src/wx/playlist_controls.h
index 4f144834a..9d7fdea91 100644
--- a/src/wx/playlist_controls.h
+++ b/src/wx/playlist_controls.h
@@ -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;
};
diff --git a/src/wx/question_dialog.h b/src/wx/question_dialog.h
index a3b05173a..6b99065f6 100644
--- a/src/wx/question_dialog.h
+++ b/src/wx/question_dialog.h
@@ -18,7 +18,10 @@
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
class QuestionDialog : public wxDialog
{
diff --git a/src/wx/repeat_dialog.h b/src/wx/repeat_dialog.h
index 0c4fb6a86..38d896c8f 100644
--- a/src/wx/repeat_dialog.h
+++ b/src/wx/repeat_dialog.h
@@ -18,9 +18,12 @@
*/
+#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
{
diff --git a/src/wx/screens_panel.h b/src/wx/screens_panel.h
index 510297efb..d5ea461aa 100644
--- a/src/wx/screens_panel.h
+++ b/src/wx/screens_panel.h
@@ -18,9 +18,12 @@
*/
+#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>
diff --git a/src/wx/system_font_dialog.h b/src/wx/system_font_dialog.h
index 48a31a839..da51c9c3a 100644
--- a/src/wx/system_font_dialog.h
+++ b/src/wx/system_font_dialog.h
@@ -26,7 +26,10 @@
* 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>
diff --git a/src/wx/table_dialog.h b/src/wx/table_dialog.h
index a5015ee59..fdc2022c8 100644
--- a/src/wx/table_dialog.h
+++ b/src/wx/table_dialog.h
@@ -21,7 +21,10 @@
#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
{
diff --git a/src/wx/time_picker.h b/src/wx/time_picker.h
index 9e83c0043..53b0ce2b8 100644
--- a/src/wx/time_picker.h
+++ b/src/wx/time_picker.h
@@ -18,7 +18,10 @@
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
class wxSpinCtrl;
diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h
index 27cfed53e..2573e3cb3 100644
--- a/src/wx/timeline_content_view.h
+++ b/src/wx/timeline_content_view.h
@@ -22,8 +22,11 @@
#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;
diff --git a/src/wx/verify_dcp_dialog.h b/src/wx/verify_dcp_dialog.h
index d2f21863d..47e5d19a8 100644
--- a/src/wx/verify_dcp_dialog.h
+++ b/src/wx/verify_dcp_dialog.h
@@ -18,8 +18,11 @@
*/
+#include "lib/warnings.h"
#include <dcp/verify.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <list>
class wxRichTextCtrl;
diff --git a/src/wx/video_waveform_plot.h b/src/wx/video_waveform_plot.h
index 380186074..1e38f5890 100644
--- a/src/wx/video_waveform_plot.h
+++ b/src/wx/video_waveform_plot.h
@@ -18,7 +18,10 @@
*/
+#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>
diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h
index af938b670..517b6407a 100644
--- a/src/wx/wx_util.h
+++ b/src/wx/wx_util.h
@@ -25,8 +25,11 @@
#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>
diff --git a/test/test.cc b/test/test.cc
index 32d32f988..7bc75468c 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -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 ());
}
diff --git a/test/test.h b/test/test.h
index 77108af46..b620a68a0 100644
--- a/test/test.h
+++ b/test/test.h
@@ -18,7 +18,10 @@
*/
+#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 72db83e2c..1c8fc4fd7 100644
--- 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
}
""",