aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-05-20 14:34:53 +0200
committerm-holger <m-holger@kubitscheck.org>2023-05-20 16:41:44 +0200
commit2fa581537b068e5ddcaee68fd7b92e290fc5fc53 (patch)
treebcd19f51a33a389f9da1ca09b5b4b0c8e2d2cd5b
parent41ec7eda54e2263eeb1aee4c3a0616c9c2777fb7 (diff)
downloadqpdf-2fa581537b068e5ddcaee68fd7b92e290fc5fc53.tar.zst
Use auto when initializing with a cast
-rw-r--r--libqpdf/InsecureRandomDataProvider.cc2
-rw-r--r--libqpdf/JSON.cc14
-rw-r--r--libqpdf/Pl_ASCIIHexDecoder.cc2
-rw-r--r--libqpdf/Pl_DCT.cc12
-rw-r--r--libqpdf/Pl_LZWDecoder.cc2
-rw-r--r--libqpdf/Pl_RunLength.cc4
-rw-r--r--libqpdf/QPDFFormFieldObjectHelper.cc2
-rw-r--r--libqpdf/QPDF_Stream.cc2
-rw-r--r--libqpdf/QPDF_optimization.cc2
-rw-r--r--libtests/qintc.cc2
10 files changed, 22 insertions, 22 deletions
diff --git a/libqpdf/InsecureRandomDataProvider.cc b/libqpdf/InsecureRandomDataProvider.cc
index 90a548ee..ed62d6c7 100644
--- a/libqpdf/InsecureRandomDataProvider.cc
+++ b/libqpdf/InsecureRandomDataProvider.cc
@@ -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);
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index fbf06f88..5f76f1ec 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -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()) {
diff --git a/libqpdf/Pl_ASCIIHexDecoder.cc b/libqpdf/Pl_ASCIIHexDecoder.cc
index 5590efba..3548f33e 100644
--- a/libqpdf/Pl_ASCIIHexDecoder.cc
+++ b/libqpdf/Pl_ASCIIHexDecoder.cc
@@ -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",
diff --git a/libqpdf/Pl_DCT.cc b/libqpdf/Pl_DCT.cc
index c01398ad..299b48b1 100644
--- a/libqpdf/Pl_DCT.cc
+++ b/libqpdf/Pl_DCT.cc
@@ -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 ( \
diff --git a/libqpdf/Pl_LZWDecoder.cc b/libqpdf/Pl_LZWDecoder.cc
index 1c2d6807..3356ea4f 100644
--- a/libqpdf/Pl_LZWDecoder.cc
+++ b/libqpdf/Pl_LZWDecoder.cc
@@ -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;
diff --git a/libqpdf/Pl_RunLength.cc b/libqpdf/Pl_RunLength.cc
index 786e2e86..d60da70a 100644
--- a/libqpdf/Pl_RunLength.cc
+++ b/libqpdf/Pl_RunLength.cc
@@ -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);
}
diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc
index 93dc0e63..7712cab2 100644
--- a/libqpdf/QPDFFormFieldObjectHelper.cc
+++ b/libqpdf/QPDFFormFieldObjectHelper.cc
@@ -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;
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index 8e2e16c5..4ceeab48 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -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); });
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc
index 41204fbd..9130287a 100644
--- a/libqpdf/QPDF_optimization.cc
+++ b/libqpdf/QPDF_optimization.cc
@@ -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);
diff --git a/libtests/qintc.cc b/libtests/qintc.cc
index 0cf3924f..5b985644 100644
--- a/libtests/qintc.cc
+++ b/libtests/qintc.cc
@@ -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