Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up some tidy nits #693

Merged
merged 6 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,12 @@ Checks: >
-misc-unused-parameters,
-misc-unused-using-decls,
-modernize-use-trailing-return-type,
-openmp-exception-escape,
-portability-simd-intrinsics,
-readability-container-data-pointer,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-inconsistent-declaration-parameter-name,
-readability-magic-numbers,
-readability-avoid-nested-conditional-operator,

-rawspeed-std-array-no-operator-at
WarningsAsErrors: '*'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
eatmydata apt-get install clang-format-${{ inputs.compiler-version }} clang-tidy-${{ inputs.compiler-version }}

eatmydata apt-get install curl gpg
echo 'deb http://download.opensuse.org/repositories/graphics:/darktable:/master/Debian_Unstable/ /' | tee /etc/apt/sources.list
echo 'deb https://ftp.gwdg.de//pub/opensuse/repositories/graphics%3A/darktable%3A/master/Debian_Unstable/ /' | tee /etc/apt/sources.list
curl -fsSL https://download.opensuse.org/repositories/graphics:darktable:master/Debian_Unstable/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/graphics_darktable_master.gpg > /dev/null
apt-get update
eatmydata apt-get install rawspeed-clang-tidy-module
Expand Down
1 change: 0 additions & 1 deletion bench/librawspeed/bitstreams/BitStreamerBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ inline void CustomArguments(benchmark::internal::Benchmark* b) {
}

b->RangeMultiplier(2);
// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((true)) {
b->Arg(256 << 20);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ void CustomArguments(benchmark::internal::Benchmark* b) {
return;
}

// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((true)) {
b->Arg(MaxBytesOptimal);
} else {
Expand Down
1 change: 0 additions & 1 deletion bench/librawspeed/bitstreams/BitVacuumerBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ void CustomArguments(benchmark::internal::Benchmark* b) {
return;
}

// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((true)) {
b->Arg(MaxBytesOptimal);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ void CustomArguments(benchmark::internal::Benchmark* b) {
return;
}

// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((true)) {
b->Arg(MaxBytesOptimal);
} else {
Expand Down
1 change: 0 additions & 1 deletion bench/librawspeed/common/CommonBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ inline void CustomArguments(benchmark::internal::Benchmark* b) {
}

b->RangeMultiplier(2);
// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((false)) {
b->Arg(MaxPixelsOptimal);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ inline void BM_DeflateDecompressor(benchmark::State& state) {
break;
}

std::unique_ptr<unsigned char[]> uBuffer; // NOLINT
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
std::unique_ptr<unsigned char[]> uBuffer;

for (auto _ : state) {
DeflateDecompressor d(buf, mRaw, predictor, BPS::value);
Expand All @@ -127,7 +128,6 @@ inline void CustomArgs(benchmark::internal::Benchmark* b) {

b->RangeMultiplier(2);
// FIXME: appears to not like 1GPix+ buffers
// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((true)) {
b->Arg(128 << 20);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ inline void CustomArguments(benchmark::internal::Benchmark* b) {
}

b->RangeMultiplier(2);
// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((true)) {
b->Arg(2 * 3 * 2 * 1'000'000);
} else {
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/CheckJPEGSymbols.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")
# Workaround cmake-3.25 bug.
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-newline-eof")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-old-style-cast")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-unsafe-buffer-usage")

set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES_SAVE};${JPEG_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_SAVE};${JPEG_LIBRARIES}")
Expand Down
3 changes: 2 additions & 1 deletion src/external/AddressSanitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ inline void ASan::UnPoisonMemoryRegion(const volatile void* addr, size_t size) {
__asan_unpoison_memory_region(addr, size);
}
inline bool ASan::RegionIsPoisoned(const volatile void* addr, size_t size) {
auto* beg = const_cast<void*>(addr); // NOLINT
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
auto* beg = const_cast<void*>(addr);
return nullptr != __asan_region_is_poisoned(beg, size);
}
#else
Expand Down
1 change: 0 additions & 1 deletion src/librawspeed/codes/PrefixCodeLookupDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class PrefixCodeLookupDecoder : public AbstractPrefixCodeDecoder<CodeTag> {

PrefixCodeLookupDecoder(PrefixCode<CodeTag>) = delete;
PrefixCodeLookupDecoder(const PrefixCode<CodeTag>&) = delete;
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
PrefixCodeLookupDecoder(PrefixCode<CodeTag>&&) = delete;

protected:
Expand Down
1 change: 0 additions & 1 deletion src/librawspeed/decoders/Cr2Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ getBlackAndWhiteLevelOffsetsInColorData(ColorDataFormat f,
__builtin_unreachable();
}
case ColorData6:
// NOLINTNEXTLINE(hicpp-multiway-paths-covered)
switch (*colorDataVersion) {
case 10:
return {{479, 484}};
Expand Down
14 changes: 10 additions & 4 deletions src/librawspeed/decoders/NefDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,16 @@ std::vector<uint16_t> NefDecoder::gammaCurve(double pwr, double ts, int imax) {
const double r = static_cast<double>(i) / imax;
if (r >= 1)
continue;
auto v =
(r < g[2] ? r / g[1]
: (std::abs(g[0]) > 0 ? pow((r + g[4]) / (1 + g[4]), 1 / g[0])
: exp((r - 1) / g[2])));
double v;
if (r < g[2]) {
v = r / g[1];
} else {
if (std::abs(g[0]) > 0) {
v = pow((r + g[4]) / (1 + g[4]), 1 / g[0]);
} else {
v = exp((r - 1) / g[2]);
}
}
curve[i] = static_cast<uint16_t>(0x10000 * v);
}

Expand Down
3 changes: 2 additions & 1 deletion src/librawspeed/decompressors/AbstractDngDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ template <> void AbstractDngDecompressor::decompressThread<7>() const noexcept {

#ifdef HAVE_ZLIB
template <> void AbstractDngDecompressor::decompressThread<8>() const noexcept {
std::unique_ptr<unsigned char[]> uBuffer; // NOLINT
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
std::unique_ptr<unsigned char[]> uBuffer;

#ifdef HAVE_OPENMP
#pragma omp for schedule(static)
Expand Down
14 changes: 8 additions & 6 deletions src/librawspeed/decompressors/DeflateDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <array>
#include <climits>
#include <cstdint>
#include <memory>
#include <utility>
#include <zconf.h>
#include <zlib.h>
Expand Down Expand Up @@ -130,17 +131,18 @@ inline void decodeFPDeltaRow(Array1DRef<const unsigned char> src,

} // namespace

void DeflateDecompressor::decode(
std::unique_ptr<unsigned char[]>* uBuffer, // NOLINT
iPoint2D maxDim, iPoint2D dim, iPoint2D off) {
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
void DeflateDecompressor::decode(std::unique_ptr<unsigned char[]>* uBuffer,
iPoint2D maxDim, iPoint2D dim, iPoint2D off) {
int bytesps = bps / 8;
invariant(bytesps >= 2 && bytesps <= 4);

auto dstLen = implicit_cast<uLongf>(bytesps * maxDim.area());

if (!*uBuffer)
*uBuffer =
std::unique_ptr<unsigned char[]>(new unsigned char[dstLen]); // NOLINT
if (!*uBuffer) {
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
*uBuffer = std::unique_ptr<unsigned char[]>(new unsigned char[dstLen]);
}

Array2DRef<unsigned char> tmp(uBuffer->get(), bytesps * maxDim.x, maxDim.y);

Expand Down
5 changes: 3 additions & 2 deletions src/librawspeed/decompressors/DeflateDecompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ class DeflateDecompressor final : public AbstractDecompressor {
public:
DeflateDecompressor(Buffer bs, RawImage img, int predictor, int bps_);

void decode(std::unique_ptr<unsigned char[]>* uBuffer, // NOLINT
iPoint2D maxDim, iPoint2D dim, iPoint2D off);
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
void decode(std::unique_ptr<unsigned char[]>* uBuffer, iPoint2D maxDim,
iPoint2D dim, iPoint2D off);
};

} // namespace rawspeed
Expand Down
5 changes: 1 addition & 4 deletions src/librawspeed/decompressors/PanasonicV5Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ void PanasonicV5Decompressor::decompressInternal() const noexcept {
schedule(static) default(none)
#endif
for (const auto& block :
Array1DRef(blocks.data(),
implicit_cast<int>(
blocks.size()))) { // NOLINT(openmp-exception-escape): we
// have checked size already.
Array1DRef(blocks.data(), implicit_cast<int>(blocks.size()))) {
try {
processBlock<dsc>(block);
} catch (...) {
Expand Down
6 changes: 1 addition & 5 deletions src/librawspeed/decompressors/PanasonicV6Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ PanasonicV6Decompressor::PanasonicV6Decompressor(RawImage img,

template <const PanasonicV6Decompressor::BlockDsc& dsc>
inline void __attribute__((always_inline))
// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
PanasonicV6Decompressor::decompressBlock(ByteStream& rowInput, int row,
int col) const noexcept {
const Array2DRef<uint16_t> out(mRaw->getU16DataAsUncroppedArray2DRef());
Expand Down Expand Up @@ -220,7 +219,6 @@ PanasonicV6Decompressor::decompressBlock(ByteStream& rowInput, int row,
}
}

// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
template <const PanasonicV6Decompressor::BlockDsc& dsc>
void PanasonicV6Decompressor::decompressRow(int row) const noexcept {
invariant(mRaw->dim.x % dsc.PixelsPerBlock == 0);
Expand All @@ -239,9 +237,7 @@ void PanasonicV6Decompressor::decompressInternal() const noexcept {
#pragma omp parallel for num_threads(rawspeed_get_number_of_processor_cores()) \
schedule(static) default(none)
#endif
for (int row = 0; row < mRaw->dim.y;
++row) { // NOLINT(openmp-exception-escape): we know no exceptions will
// be thrown.
for (int row = 0; row < mRaw->dim.y; ++row) {
try {
decompressRow<dsc>(row);
} catch (...) {
Expand Down
2 changes: 0 additions & 2 deletions src/librawspeed/decompressors/PanasonicV6Decompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ class PanasonicV6Decompressor final : public AbstractDecompressor {

template <const BlockDsc& dsc>
inline void __attribute__((always_inline))
// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
decompressBlock(ByteStream& rowInput, int row, int col) const noexcept;

// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
template <const BlockDsc& dsc> void decompressRow(int row) const noexcept;

template <const BlockDsc& dsc> void decompressInternal() const noexcept;
Expand Down
6 changes: 1 addition & 5 deletions src/librawspeed/decompressors/PanasonicV7Decompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ PanasonicV7Decompressor::PanasonicV7Decompressor(RawImage img,
}

inline void __attribute__((always_inline))
// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
PanasonicV7Decompressor::decompressBlock(
ByteStream block, CroppedArray1DRef<uint16_t> out) noexcept {
invariant(out.size() == PixelsPerBlock);
Expand All @@ -74,7 +73,6 @@ PanasonicV7Decompressor::decompressBlock(
out(pix) = implicit_cast<uint16_t>(pump.getBits(BitsPerSample));
}

// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
void PanasonicV7Decompressor::decompressRow(int row) const noexcept {
const Array2DRef<uint16_t> out(mRaw->getU16DataAsUncroppedArray2DRef());
Array1DRef<uint16_t> outRow = out[row];
Expand All @@ -95,9 +93,7 @@ void PanasonicV7Decompressor::decompress() const {
#pragma omp parallel for num_threads(rawspeed_get_number_of_processor_cores()) \
schedule(static) default(none)
#endif
for (int row = 0; row < mRaw->dim.y;
++row) { // NOLINT(openmp-exception-escape): we know no exceptions will
// be thrown.
for (int row = 0; row < mRaw->dim.y; ++row) {
try {
decompressRow(row);
} catch (...) {
Expand Down
2 changes: 0 additions & 2 deletions src/librawspeed/decompressors/PanasonicV7Decompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ class PanasonicV7Decompressor final : public AbstractDecompressor {
(CHAR_BIT * BytesPerBlock) / BitsPerSample;

static inline void __attribute__((always_inline))
// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
decompressBlock(ByteStream block, CroppedArray1DRef<uint16_t> out) noexcept;

// NOLINTNEXTLINE(bugprone-exception-escape): no exceptions will be thrown.
void decompressRow(int row) const noexcept;

public:
Expand Down
1 change: 0 additions & 1 deletion src/librawspeed/tiff/TiffEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ TiffEntry::TiffEntry(TiffIFD* parent_, ByteStream& bs)
TiffTag::MAKERNOTE_ALT, TiffTag::FUJI_RAW_IFD,
TiffTag::SUBIFDS, TiffTag::EXIFIFDPOINTER})) {
// preserve offset for SUB_IFD/EXIF/MAKER_NOTE data
// NOLINTNEXTLINE(readability-simplify-boolean-expr)
if constexpr ((false)) {
// limit access to range from 0 to data_offset+byte_size
data = bs.getSubStream(data_offset, byte_size);
Expand Down
3 changes: 2 additions & 1 deletion src/utilities/identify/rawspeed-identify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ using rawspeed::RawParser;
using rawspeed::RawspeedException;
using rawspeed::identify::find_cameras_xml;

int main(int argc_, char* argv_[]) { // NOLINT
// NOLINTNEXTLINE(readability-function-size)
int main(int argc_, char* argv_[]) {
auto argv = rawspeed::Array1DRef(argv_, argc_);

if (argv.size() != 2) {
Expand Down
4 changes: 2 additions & 2 deletions test/librawspeed/metadata/CameraSensorInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ TEST_P(CameraSensorInfoTestDumb, AssignmentConstructor) {
ASSERT_NO_THROW({
const CameraSensorInfo InfoOrig(mBlackLevel, mWhiteLevel, mMinIso, mMaxIso,
mBlackLevelSeparate);
CameraSensorInfo Info(InfoOrig); // NOLINT(foo): trying to test the copy
CameraSensorInfo Info(InfoOrig);
});

ASSERT_NO_THROW({
Expand All @@ -146,7 +146,7 @@ TEST_P(CameraSensorInfoTestDumb, AssignmentConstructorGetters) {
{
const CameraSensorInfo InfoOrig(mBlackLevel, mWhiteLevel, mMinIso, mMaxIso,
mBlackLevelSeparate);
CameraSensorInfo Info(InfoOrig); // NOLINT
CameraSensorInfo Info(InfoOrig);

checkHelper(Info);
checkHelper(Info, InfoOrig);
Expand Down
Loading