Commit 2fa581537b068e5ddcaee68fd7b92e290fc5fc53

Authored by m-holger
1 parent 41ec7eda

Use auto when initializing with a cast

libqpdf/InsecureRandomDataProvider.cc
... ... @@ -24,7 +24,7 @@ InsecureRandomDataProvider::random()
24 24 // Seed the random number generator with something simple, but
25 25 // just to be interesting, don't use the unmodified current
26 26 // time. It would be better if this were a more secure seed.
27   - unsigned int seed =
  27 + auto seed =
28 28 static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
29 29 #ifdef HAVE_RANDOM
30 30 ::srandom(seed);
... ...
libqpdf/JSON.cc
... ... @@ -294,7 +294,7 @@ JSON::addDictionaryMember(std::string const&amp; key, JSON const&amp; val)
294 294 bool
295 295 JSON::checkDictionaryKeySeen(std::string const& key)
296 296 {
297   - JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
  297 + auto* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
298 298 if (nullptr == obj) {
299 299 throw std::logic_error(
300 300 "JSON::checkDictionaryKey called on non-dictionary");
... ... @@ -315,7 +315,7 @@ JSON::makeArray()
315 315 JSON
316 316 JSON::addArrayElement(JSON const& val)
317 317 {
318   - JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get());
  318 + auto* arr = dynamic_cast<JSON_array*>(this->m->value.get());
319 319 if (nullptr == arr) {
320 320 throw std::runtime_error("JSON::addArrayElement called on non-array");
321 321 }
... ... @@ -470,13 +470,13 @@ JSON::checkSchemaInternal(
470 470 std::list<std::string>& errors,
471 471 std::string prefix)
472 472 {
473   - JSON_array* this_arr = dynamic_cast<JSON_array*>(this_v);
474   - JSON_dictionary* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
  473 + auto* this_arr = dynamic_cast<JSON_array*>(this_v);
  474 + auto* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
475 475  
476   - JSON_array* sch_arr = dynamic_cast<JSON_array*>(sch_v);
477   - JSON_dictionary* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
  476 + auto* sch_arr = dynamic_cast<JSON_array*>(sch_v);
  477 + auto* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
478 478  
479   - JSON_string* sch_str = dynamic_cast<JSON_string*>(sch_v);
  479 + auto* sch_str = dynamic_cast<JSON_string*>(sch_v);
480 480  
481 481 std::string err_prefix;
482 482 if (prefix.empty()) {
... ...
libqpdf/Pl_ASCIIHexDecoder.cc
... ... @@ -76,7 +76,7 @@ Pl_ASCIIHexDecoder::flush()
76 76 b[i] = this->inbuf[i] - '0';
77 77 }
78 78 }
79   - unsigned char ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
  79 + auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
80 80  
81 81 QTC::TC(
82 82 "libtests",
... ...
libqpdf/Pl_DCT.cc
... ... @@ -24,7 +24,7 @@ namespace
24 24 static void
25 25 error_handler(j_common_ptr cinfo)
26 26 {
27   - qpdf_jpeg_error_mgr* jerr =
  27 + auto* jerr =
28 28 reinterpret_cast<qpdf_jpeg_error_mgr*>(cinfo->err);
29 29 char buf[JMSG_LENGTH_MAX];
30 30 (*cinfo->err->format_message)(cinfo, buf);
... ... @@ -167,7 +167,7 @@ static boolean
167 167 empty_pipeline_output_buffer(j_compress_ptr cinfo)
168 168 {
169 169 QTC::TC("libtests", "Pl_DCT empty_pipeline_output_buffer");
170   - dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
  170 + auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
171 171 dest->next->write(dest->buffer, dest->size);
172 172 dest->pub.next_output_byte = dest->buffer;
173 173 dest->pub.free_in_buffer = dest->size;
... ... @@ -178,7 +178,7 @@ static void
178 178 term_pipeline_destination(j_compress_ptr cinfo)
179 179 {
180 180 QTC::TC("libtests", "Pl_DCT term_pipeline_destination");
181   - dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
  181 + auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
182 182 dest->next->write(dest->buffer, dest->size - dest->pub.free_in_buffer);
183 183 }
184 184  
... ... @@ -192,7 +192,7 @@ jpeg_pipeline_dest(
192 192 reinterpret_cast<j_common_ptr>(cinfo),
193 193 JPOOL_PERMANENT,
194 194 sizeof(dct_pipeline_dest)));
195   - dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
  195 + auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
196 196 dest->pub.init_destination = init_pipeline_destination;
197 197 dest->pub.empty_output_buffer = empty_pipeline_output_buffer;
198 198 dest->pub.term_destination = term_pipeline_destination;
... ... @@ -261,7 +261,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer)
261 261 void
262 262 Pl_DCT::compress(void* cinfo_p, Buffer* b)
263 263 {
264   - struct jpeg_compress_struct* cinfo =
  264 + auto* cinfo =
265 265 reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
266 266  
267 267 #if ( \
... ... @@ -316,7 +316,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
316 316 void
317 317 Pl_DCT::decompress(void* cinfo_p, Buffer* b)
318 318 {
319   - struct jpeg_decompress_struct* cinfo =
  319 + auto* cinfo =
320 320 reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
321 321  
322 322 #if ( \
... ...
libqpdf/Pl_LZWDecoder.cc
... ... @@ -189,7 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
189 189 }
190 190  
191 191 if (code < 256) {
192   - unsigned char ch = static_cast<unsigned char>(code);
  192 + auto ch = static_cast<unsigned char>(code);
193 193 getNext()->write(&ch, 1);
194 194 } else {
195 195 unsigned int idx = code - 258;
... ...
libqpdf/Pl_RunLength.cc
... ... @@ -127,11 +127,11 @@ Pl_RunLength::flush_encode()
127 127 throw std::logic_error(
128 128 "Pl_RunLength: invalid length in flush_encode for run");
129 129 }
130   - unsigned char ch = static_cast<unsigned char>(257 - this->m->length);
  130 + auto ch = static_cast<unsigned char>(257 - this->m->length);
131 131 this->getNext()->write(&ch, 1);
132 132 this->getNext()->write(&this->m->buf[0], 1);
133 133 } else if (this->m->length > 0) {
134   - unsigned char ch = static_cast<unsigned char>(this->m->length - 1);
  134 + auto ch = static_cast<unsigned char>(this->m->length - 1);
135 135 this->getNext()->write(&ch, 1);
136 136 this->getNext()->write(this->m->buf, this->m->length);
137 137 }
... ...
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -611,7 +611,7 @@ ValueSetter::writeAppearance()
611 611 // Write one or more lines, centered vertically, possibly with
612 612 // one row highlighted.
613 613  
614   - size_t max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
  614 + auto max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
615 615 bool highlight = false;
616 616 size_t highlight_idx = 0;
617 617  
... ...
libqpdf/QPDF_Stream.cc
... ... @@ -557,7 +557,7 @@ QPDF_Stream::pipeStreamData(
557 557 if (decode_pipeline) {
558 558 pipeline = decode_pipeline;
559 559 }
560   - Pl_Flate* flate = dynamic_cast<Pl_Flate*>(pipeline);
  560 + auto* flate = dynamic_cast<Pl_Flate*>(pipeline);
561 561 if (flate != nullptr) {
562 562 flate->setWarnCallback(
563 563 [this](char const* msg, int code) { warn(msg); });
... ...
libqpdf/QPDF_optimization.cc
... ... @@ -115,7 +115,7 @@ QPDF::optimize(
115 115 }
116 116  
117 117 ObjUser root_ou = ObjUser(ObjUser::ou_root);
118   - QPDFObjGen root_og = QPDFObjGen(root.getObjGen());
  118 + auto root_og = QPDFObjGen(root.getObjGen());
119 119 this->m->obj_user_to_objects[root_ou].insert(root_og);
120 120 this->m->object_to_obj_users[root_og].insert(root_ou);
121 121  
... ...
libtests/qintc.cc
... ... @@ -74,7 +74,7 @@ main()
74 74 uint64_t ul1 = 1099511627776LL; // Too big for 32-bit
75 75 uint64_t ul2 = 12345; // Fits into 32-bit
76 76 int32_t i2 = 81; // Fits in char and uchar
77   - signed char c1 = static_cast<signed char>('\xf7'); // Signed value when char
  77 + auto c1 = static_cast<signed char>('\xf7'); // Signed value when char
78 78 char c2 = 'W'; // char; may be signed or unsigned
79 79  
80 80 // Verify i1 and u1 have same bit pattern
... ...