Skip to content

Commit a20ace2

Browse files
committed
clang-tidy: manual clang-tidy fixes
clang-tidy has issues applying these. Signed-off-by: Rosen Penev <[email protected]>
1 parent ae66ece commit a20ace2

File tree

8 files changed

+41
-46
lines changed

8 files changed

+41
-46
lines changed

include/exiv2/bmffimage.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class EXIV2API BmffImage : public Image {
123123
@warning This function should only be called by readMetadata()
124124
*/
125125
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, const long pbox_end, int depth);
126-
[[nodiscard]] std::string indent(int i) const {
126+
[[nodiscard]] static std::string indent(int i) {
127127
return std::string(2 * i, ' ');
128128
}
129129

include/exiv2/slice.hpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ struct ConstSliceBase : SliceBase {
109109
/*!
110110
* Obtain a constant iterator to the first element in the slice.
111111
*/
112-
const_iterator cbegin() const noexcept {
112+
[[nodiscard]] const_iterator cbegin() const noexcept {
113113
return storage_.unsafeGetIteratorAt(begin_);
114114
}
115115

116116
/*!
117117
* Obtain a constant iterator to the first beyond the slice.
118118
*/
119-
const_iterator cend() const noexcept {
119+
[[nodiscard]] const_iterator cend() const noexcept {
120120
return storage_.unsafeGetIteratorAt(end_);
121121
}
122122

@@ -129,7 +129,7 @@ struct ConstSliceBase : SliceBase {
129129
* mutable_slice_base.
130130
*/
131131
template <typename slice_type>
132-
slice_type subSlice(size_t begin, size_t end) const {
132+
[[nodiscard]] slice_type subSlice(size_t begin, size_t end) const {
133133
this->rangeCheck(begin);
134134
// end == size() is a legal value, since end is the first
135135
// element beyond the slice
@@ -219,8 +219,8 @@ struct MutableSliceBase : public ConstSliceBase<storage_type, data_type> {
219219
* the appropriate `slice<const T>` and call its `subSlice() const`,
220220
* which returns the correct type.
221221
*/
222-
ConstSliceBase<storage_type, const data_type> to_const_base() const noexcept {
223-
return ConstSliceBase<storage_type, const data_type>(this->storage_.data_, this->begin_, this->end_);
222+
[[nodiscard]] ConstSliceBase<storage_type, const data_type> to_const_base() const noexcept {
223+
return {this->storage_.data_, this->begin_, this->end_};
224224
}
225225

226226
using base_type = ConstSliceBase<storage_type, data_type>;
@@ -281,11 +281,11 @@ struct ContainerStorage {
281281
*
282282
* @throw whatever container::at() throws
283283
*/
284-
const value_type& unsafeAt(size_t index) const {
284+
[[nodiscard]] const value_type& unsafeAt(size_t index) const {
285285
return data_.at(index);
286286
}
287287

288-
value_type& unsafeAt(size_t index) {
288+
[[nodiscard]] value_type& unsafeAt(size_t index) {
289289
return data_.at(index);
290290
}
291291

@@ -295,19 +295,19 @@ struct ContainerStorage {
295295
*
296296
* @throw whatever container::begin() and std::advance() throw
297297
*/
298-
iterator unsafeGetIteratorAt(size_t index) {
298+
[[nodiscard]] iterator unsafeGetIteratorAt(size_t index) {
299299
// we are screwed if the container got changed => try to catch it
300300
assert(index <= data_.size());
301301

302-
iterator it = data_.begin();
302+
auto it = data_.begin();
303303
std::advance(it, index);
304304
return it;
305305
}
306306

307-
const_iterator unsafeGetIteratorAt(size_t index) const {
307+
[[nodiscard]] const_iterator unsafeGetIteratorAt(size_t index) const {
308308
assert(index <= data_.size());
309309

310-
const_iterator it = data_.begin();
310+
auto it = data_.begin();
311311
std::advance(it, index);
312312
return it;
313313
}
@@ -346,11 +346,11 @@ struct PtrSliceStorage {
346346
*
347347
* @throw nothing
348348
*/
349-
value_type& unsafeAt(size_t index) noexcept {
349+
[[nodiscard]] value_type& unsafeAt(size_t index) noexcept {
350350
return data_[index];
351351
}
352352

353-
const value_type& unsafeAt(size_t index) const noexcept {
353+
[[nodiscard]] const value_type& unsafeAt(size_t index) const noexcept {
354354
return data_[index];
355355
}
356356

@@ -360,11 +360,11 @@ struct PtrSliceStorage {
360360
*
361361
* @throw nothing
362362
*/
363-
iterator unsafeGetIteratorAt(size_t index) noexcept {
363+
[[nodiscard]] iterator unsafeGetIteratorAt(size_t index) noexcept {
364364
return data_ + index;
365365
}
366366

367-
const_iterator unsafeGetIteratorAt(size_t index) const noexcept {
367+
[[nodiscard]] const_iterator unsafeGetIteratorAt(size_t index) const noexcept {
368368
return data_ + index;
369369
}
370370

@@ -462,7 +462,7 @@ struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, con
462462
* Constructs a new constant subSlice. Behaves otherwise exactly like
463463
* the non-const version.
464464
*/
465-
Slice<const container> subSlice(size_t begin, size_t end) const {
465+
[[nodiscard]] Slice<const container> subSlice(size_t begin, size_t end) const {
466466
return this->to_const_base().template subSlice<Slice<const container>>(begin, end);
467467
}
468468
};
@@ -534,7 +534,7 @@ struct Slice<T*> : public Internal::MutableSliceBase<Internal::PtrSliceStorage,
534534
return Internal::MutableSliceBase<Internal::PtrSliceStorage, T*>::template subSlice<Slice<T*>>(begin, end);
535535
}
536536

537-
Slice<const T*> subSlice(size_t begin, size_t end) const {
537+
[[nodiscard]] Slice<const T*> subSlice(size_t begin, size_t end) const {
538538
return this->to_const_base().template subSlice<Slice<const T*>>(begin, end);
539539
}
540540
};

include/exiv2/value.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,8 @@ class ValueType : public Value {
12511251
if (static_cast<decltype(v)>(std::numeric_limits<I>::min()) <= v &&
12521252
v <= static_cast<decltype(v)>(std::numeric_limits<I>::max())) {
12531253
return static_cast<I>(std::round(v));
1254-
} else {
1255-
return 0;
12561254
}
1255+
return 0;
12571256
}
12581257

12591258
//! Utility for toInt64, toUint32, etc.

src/crwimage_int.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,12 @@ class CiffDirectory : public CiffComponent {
371371
void doPrint(std::ostream& os, ByteOrder byteOrder, const std::string& prefix) const override;
372372

373373
//! See base class comment. A directory is empty if it has no components.
374-
bool doEmpty() const override;
374+
[[nodiscard]] bool doEmpty() const override;
375375

376376
// See base class comment
377377
[[nodiscard]] CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir) const override;
378378
//@}
379379

380-
private:
381380
// DATA
382381
Components components_; //!< List of components in this dir
383382
UniquePtr m_; // used by recursive doAdd
@@ -495,14 +494,14 @@ struct CrwMapping {
495494
//@{
496495
//! Default constructor
497496
CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, Internal::IfdId ifdId,
498-
const CrwDecodeFct& toExif, const CrwEncodeFct& fromExif) :
497+
CrwDecodeFct toExif, CrwEncodeFct fromExif) :
499498
crwTagId_(crwTagId),
500499
crwDir_(crwDir),
501500
size_(size),
502501
tag_(tag),
503502
ifdId_(ifdId),
504-
toExif_(toExif),
505-
fromExif_(fromExif) {
503+
toExif_(std::move(toExif)),
504+
fromExif_(std::move(fromExif)) {
506505
}
507506
//@}
508507

@@ -633,7 +632,6 @@ class CrwMap {
633632
//! Encode the thumbnail image
634633
static void encode0x2008(const Image& image, const CrwMapping* pCrwMapping, CiffHeader* pHead);
635634

636-
private:
637635
// DATA
638636
static const CrwMapping crwMapping_[]; //!< Metadata conversion table
639637
static const CrwSubDir crwSubDir_[]; //!< Ciff directory hierarchy

src/image_int.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct binaryToStringHelper;
4848
template <typename T>
4949
std::ostream& operator<<(std::ostream& stream, const binaryToStringHelper<T>& binToStr) {
5050
for (size_t i = 0; i < binToStr.buf_.size(); ++i) {
51-
int c = static_cast<int>(binToStr.buf_.at(i));
51+
auto c = static_cast<int>(binToStr.buf_.at(i));
5252
const bool bTrailingNull = c == 0 && i == binToStr.buf_.size() - 1;
5353
if (!bTrailingNull) {
5454
if (c < ' ' || c >= 127) {

src/pngchunk_int.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class PngChunk {
2525
*/
2626
enum TxtChunkType { tEXt_Chunk = 0, zTXt_Chunk = 1, iTXt_Chunk = 2 };
2727

28-
public:
2928
/*!
3029
@brief Decode PNG IHDR chunk data from a data buffer
3130
\em data and return image size to \em outWidth and \em outHeight.

src/tiffcomposite_int.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,20 @@ class TiffIfdMakernote : public TiffComponent {
11011101
~TiffIfdMakernote() override;
11021102
//@}
11031103

1104+
/*!
1105+
@name NOT implemented
1106+
1107+
Implementing the copy constructor and assignment operator will require
1108+
cloning the header, i.e., clone() functionality on the MnHeader
1109+
hierarchy.
1110+
*/
1111+
//@{
1112+
//! Copy constructor.
1113+
TiffIfdMakernote(const TiffIfdMakernote&) = delete;
1114+
//! Assignment operator.
1115+
TiffIfdMakernote& operator=(const TiffIfdMakernote&) = delete;
1116+
//@}
1117+
11041118
//! @name Manipulators
11051119
//@{
11061120
/*!
@@ -1213,20 +1227,6 @@ class TiffIfdMakernote : public TiffComponent {
12131227
[[nodiscard]] size_t doSizeImage() const override;
12141228
//@}
12151229

1216-
/*!
1217-
@name NOT implemented
1218-
1219-
Implementing the copy constructor and assignment operator will require
1220-
cloning the header, i.e., clone() functionality on the MnHeader
1221-
hierarchy.
1222-
*/
1223-
//@{
1224-
//! Copy constructor.
1225-
TiffIfdMakernote(const TiffIfdMakernote&) = delete;
1226-
//! Assignment operator.
1227-
TiffIfdMakernote& operator=(const TiffIfdMakernote&) = delete;
1228-
//@}
1229-
12301230
private:
12311231
// DATA
12321232
MnHeader* pHeader_; //!< Makernote header

src/tiffimage_int.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class TiffHeader : public TiffHeaderBase {
115115
//! @name Creators
116116
//@{
117117
//! Default constructor
118-
TiffHeader(ByteOrder byteOrder = littleEndian, uint32_t offset = 0x00000008, bool hasImageTags = true);
118+
explicit TiffHeader(ByteOrder byteOrder = littleEndian, uint32_t offset = 0x00000008, bool hasImageTags = true);
119119
//! Destructor
120120
~TiffHeader() override = default;
121121
//@}
@@ -371,13 +371,12 @@ class OffsetWriter {
371371
//! Data structure for the offset list.
372372
struct OffsetData {
373373
//! Default constructor
374-
OffsetData() {
375-
}
374+
OffsetData() = default;
376375
//! Constructor
377376
OffsetData(uint32_t origin, ByteOrder byteOrder) : origin_(origin), byteOrder_(byteOrder) {
378377
}
379378
// DATA
380-
uint32_t origin_{0}; //!< Origin address
379+
uint32_t origin_{}; //!< Origin address
381380
uint32_t target_{}; //!< Target address
382381
ByteOrder byteOrder_{littleEndian}; //!< Byte order to use to encode target address
383382
};

0 commit comments

Comments
 (0)