mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Use auto when initializing with a cast
This commit is contained in:
parent
41ec7eda54
commit
2fa581537b
@ -24,7 +24,7 @@ InsecureRandomDataProvider::random()
|
||||
// Seed the random number generator with something simple, but
|
||||
// just to be interesting, don't use the unmodified current
|
||||
// time. It would be better if this were a more secure seed.
|
||||
unsigned int seed =
|
||||
auto seed =
|
||||
static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
|
||||
#ifdef HAVE_RANDOM
|
||||
::srandom(seed);
|
||||
|
@ -294,7 +294,7 @@ JSON::addDictionaryMember(std::string const& key, JSON const& val)
|
||||
bool
|
||||
JSON::checkDictionaryKeySeen(std::string const& key)
|
||||
{
|
||||
JSON_dictionary* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
|
||||
auto* obj = dynamic_cast<JSON_dictionary*>(this->m->value.get());
|
||||
if (nullptr == obj) {
|
||||
throw std::logic_error(
|
||||
"JSON::checkDictionaryKey called on non-dictionary");
|
||||
@ -315,7 +315,7 @@ JSON::makeArray()
|
||||
JSON
|
||||
JSON::addArrayElement(JSON const& val)
|
||||
{
|
||||
JSON_array* arr = dynamic_cast<JSON_array*>(this->m->value.get());
|
||||
auto* arr = dynamic_cast<JSON_array*>(this->m->value.get());
|
||||
if (nullptr == arr) {
|
||||
throw std::runtime_error("JSON::addArrayElement called on non-array");
|
||||
}
|
||||
@ -470,13 +470,13 @@ JSON::checkSchemaInternal(
|
||||
std::list<std::string>& errors,
|
||||
std::string prefix)
|
||||
{
|
||||
JSON_array* this_arr = dynamic_cast<JSON_array*>(this_v);
|
||||
JSON_dictionary* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
|
||||
auto* this_arr = dynamic_cast<JSON_array*>(this_v);
|
||||
auto* this_dict = dynamic_cast<JSON_dictionary*>(this_v);
|
||||
|
||||
JSON_array* sch_arr = dynamic_cast<JSON_array*>(sch_v);
|
||||
JSON_dictionary* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
|
||||
auto* sch_arr = dynamic_cast<JSON_array*>(sch_v);
|
||||
auto* sch_dict = dynamic_cast<JSON_dictionary*>(sch_v);
|
||||
|
||||
JSON_string* sch_str = dynamic_cast<JSON_string*>(sch_v);
|
||||
auto* sch_str = dynamic_cast<JSON_string*>(sch_v);
|
||||
|
||||
std::string err_prefix;
|
||||
if (prefix.empty()) {
|
||||
|
@ -76,7 +76,7 @@ Pl_ASCIIHexDecoder::flush()
|
||||
b[i] = this->inbuf[i] - '0';
|
||||
}
|
||||
}
|
||||
unsigned char ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
|
||||
auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
|
||||
|
||||
QTC::TC(
|
||||
"libtests",
|
||||
|
@ -24,7 +24,7 @@ namespace
|
||||
static void
|
||||
error_handler(j_common_ptr cinfo)
|
||||
{
|
||||
qpdf_jpeg_error_mgr* jerr =
|
||||
auto* jerr =
|
||||
reinterpret_cast<qpdf_jpeg_error_mgr*>(cinfo->err);
|
||||
char buf[JMSG_LENGTH_MAX];
|
||||
(*cinfo->err->format_message)(cinfo, buf);
|
||||
@ -167,7 +167,7 @@ static boolean
|
||||
empty_pipeline_output_buffer(j_compress_ptr cinfo)
|
||||
{
|
||||
QTC::TC("libtests", "Pl_DCT empty_pipeline_output_buffer");
|
||||
dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
|
||||
auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
|
||||
dest->next->write(dest->buffer, dest->size);
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = dest->size;
|
||||
@ -178,7 +178,7 @@ static void
|
||||
term_pipeline_destination(j_compress_ptr cinfo)
|
||||
{
|
||||
QTC::TC("libtests", "Pl_DCT term_pipeline_destination");
|
||||
dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
|
||||
auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
|
||||
dest->next->write(dest->buffer, dest->size - dest->pub.free_in_buffer);
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ jpeg_pipeline_dest(
|
||||
reinterpret_cast<j_common_ptr>(cinfo),
|
||||
JPOOL_PERMANENT,
|
||||
sizeof(dct_pipeline_dest)));
|
||||
dct_pipeline_dest* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
|
||||
auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
|
||||
dest->pub.init_destination = init_pipeline_destination;
|
||||
dest->pub.empty_output_buffer = empty_pipeline_output_buffer;
|
||||
dest->pub.term_destination = term_pipeline_destination;
|
||||
@ -261,7 +261,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer)
|
||||
void
|
||||
Pl_DCT::compress(void* cinfo_p, Buffer* b)
|
||||
{
|
||||
struct jpeg_compress_struct* cinfo =
|
||||
auto* cinfo =
|
||||
reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
|
||||
|
||||
#if ( \
|
||||
@ -316,7 +316,7 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
|
||||
void
|
||||
Pl_DCT::decompress(void* cinfo_p, Buffer* b)
|
||||
{
|
||||
struct jpeg_decompress_struct* cinfo =
|
||||
auto* cinfo =
|
||||
reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
|
||||
|
||||
#if ( \
|
||||
|
@ -189,7 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
|
||||
}
|
||||
|
||||
if (code < 256) {
|
||||
unsigned char ch = static_cast<unsigned char>(code);
|
||||
auto ch = static_cast<unsigned char>(code);
|
||||
getNext()->write(&ch, 1);
|
||||
} else {
|
||||
unsigned int idx = code - 258;
|
||||
|
@ -127,11 +127,11 @@ Pl_RunLength::flush_encode()
|
||||
throw std::logic_error(
|
||||
"Pl_RunLength: invalid length in flush_encode for run");
|
||||
}
|
||||
unsigned char ch = static_cast<unsigned char>(257 - this->m->length);
|
||||
auto ch = static_cast<unsigned char>(257 - this->m->length);
|
||||
this->getNext()->write(&ch, 1);
|
||||
this->getNext()->write(&this->m->buf[0], 1);
|
||||
} else if (this->m->length > 0) {
|
||||
unsigned char ch = static_cast<unsigned char>(this->m->length - 1);
|
||||
auto ch = static_cast<unsigned char>(this->m->length - 1);
|
||||
this->getNext()->write(&ch, 1);
|
||||
this->getNext()->write(this->m->buf, this->m->length);
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ ValueSetter::writeAppearance()
|
||||
// Write one or more lines, centered vertically, possibly with
|
||||
// one row highlighted.
|
||||
|
||||
size_t max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
|
||||
auto max_rows = static_cast<size_t>((bbox.ury - bbox.lly) / tfh);
|
||||
bool highlight = false;
|
||||
size_t highlight_idx = 0;
|
||||
|
||||
|
@ -557,7 +557,7 @@ QPDF_Stream::pipeStreamData(
|
||||
if (decode_pipeline) {
|
||||
pipeline = decode_pipeline;
|
||||
}
|
||||
Pl_Flate* flate = dynamic_cast<Pl_Flate*>(pipeline);
|
||||
auto* flate = dynamic_cast<Pl_Flate*>(pipeline);
|
||||
if (flate != nullptr) {
|
||||
flate->setWarnCallback(
|
||||
[this](char const* msg, int code) { warn(msg); });
|
||||
|
@ -115,7 +115,7 @@ QPDF::optimize(
|
||||
}
|
||||
|
||||
ObjUser root_ou = ObjUser(ObjUser::ou_root);
|
||||
QPDFObjGen root_og = QPDFObjGen(root.getObjGen());
|
||||
auto root_og = QPDFObjGen(root.getObjGen());
|
||||
this->m->obj_user_to_objects[root_ou].insert(root_og);
|
||||
this->m->object_to_obj_users[root_og].insert(root_ou);
|
||||
|
||||
|
@ -74,7 +74,7 @@ main()
|
||||
uint64_t ul1 = 1099511627776LL; // Too big for 32-bit
|
||||
uint64_t ul2 = 12345; // Fits into 32-bit
|
||||
int32_t i2 = 81; // Fits in char and uchar
|
||||
signed char c1 = static_cast<signed char>('\xf7'); // Signed value when char
|
||||
auto c1 = static_cast<signed char>('\xf7'); // Signed value when char
|
||||
char c2 = 'W'; // char; may be signed or unsigned
|
||||
|
||||
// Verify i1 and u1 have same bit pattern
|
||||
|
Loading…
Reference in New Issue
Block a user