From: Carl Hetherington Date: Thu, 19 Jan 2023 12:00:21 +0000 (+0100) Subject: Cleanup: use an early return to calm some indentation. X-Git-Tag: v2.16.43~13 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=57cbdbed89e6432049fec50ecef28b5b57bcf301 Cleanup: use an early return to calm some indentation. --- diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index b0bc197aa..c1239ff29 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -353,57 +353,58 @@ private: string title; auto dkdm = std::dynamic_pointer_cast(dkdm_base); - if (dkdm) { + if (!dkdm) { + return; + } + + /* Decrypt the DKDM */ + dcp::DecryptedKDM decrypted (dkdm->dkdm(), Config::instance()->decryption_chain()->key().get()); + title = decrypted.content_title_text (); + + /* This is the signer for our new KDMs */ + auto signer = Config::instance()->signer_chain (); + if (!signer->valid ()) { + throw InvalidSignerError (); + } - /* Decrypt the DKDM */ - dcp::DecryptedKDM decrypted (dkdm->dkdm(), Config::instance()->decryption_chain()->key().get()); - title = decrypted.content_title_text (); + for (auto i: _screens->screens()) { - /* This is the signer for our new KDMs */ - auto signer = Config::instance()->signer_chain (); - if (!signer->valid ()) { - throw InvalidSignerError (); + if (!i->recipient) { + continue; } - for (auto i: _screens->screens()) { + dcp::LocalTime begin(_timing->from(), dcp::UTCOffset(i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute())); + dcp::LocalTime end(_timing->until(), dcp::UTCOffset(i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute())); - if (!i->recipient) { - continue; - } + /* Make an empty KDM */ + dcp::DecryptedKDM kdm ( + begin, + end, + decrypted.annotation_text().get_value_or (""), + title, + dcp::LocalTime().as_string() + ); - dcp::LocalTime begin(_timing->from(), dcp::UTCOffset(i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute())); - dcp::LocalTime end(_timing->until(), dcp::UTCOffset(i->cinema->utc_offset_hour(), i->cinema->utc_offset_minute())); + /* Add keys from the DKDM */ + for (auto const& j: decrypted.keys()) { + kdm.add_key (j); + } - /* Make an empty KDM */ - dcp::DecryptedKDM kdm ( - begin, - end, - decrypted.annotation_text().get_value_or (""), - title, - dcp::LocalTime().as_string() + auto const encrypted = kdm.encrypt( + signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(), + !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional() : 0 ); - /* Add keys from the DKDM */ - for (auto const& j: decrypted.keys()) { - kdm.add_key (j); - } - - auto const encrypted = kdm.encrypt( - signer, i->recipient.get(), i->trusted_device_thumbprints(), _output->formulation(), - !_output->forensic_mark_video(), _output->forensic_mark_audio() ? boost::optional() : 0 - ); - - dcp::NameFormat::Map name_values; - name_values['c'] = i->cinema->name; - name_values['s'] = i->name; - name_values['f'] = title; - name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); - name_values['e'] = end.date() + " " + end.time_of_day(true, false); - name_values['i'] = encrypted.cpl_id (); - - /* Encrypt */ - kdms.push_back (make_shared(name_values, i->cinema.get(), i->cinema->emails, encrypted)); - } + dcp::NameFormat::Map name_values; + name_values['c'] = i->cinema->name; + name_values['s'] = i->name; + name_values['f'] = title; + name_values['b'] = begin.date() + " " + begin.time_of_day(true, false); + name_values['e'] = end.date() + " " + end.time_of_day(true, false); + name_values['i'] = encrypted.cpl_id (); + + /* Encrypt */ + kdms.push_back (make_shared(name_values, i->cinema.get(), i->cinema->emails, encrypted)); } if (kdms.empty()) {