Cleanup: use an early return to calm some indentation.
authorCarl Hetherington <cth@carlh.net>
Thu, 19 Jan 2023 12:00:21 +0000 (13:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 11 Feb 2023 21:26:38 +0000 (22:26 +0100)
src/tools/dcpomatic_kdm.cc

index b0bc197aa419c2b4ed4762621dd5b993387bd7f3..c1239ff29f9ad94b616cf3cd405b0740cbe0b03f 100644 (file)
@@ -353,57 +353,58 @@ private:
                        string title;
 
                        auto dkdm = std::dynamic_pointer_cast<DKDM>(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<int>() : 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<int>() : 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<KDMWithMetadata>(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<KDMWithMetadata>(name_values, i->cinema.get(), i->cinema->emails, encrypted));
                        }
 
                        if (kdms.empty()) {