From 75f44d3f2beb4680ae6d69ed9fb56fbb48c710d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Mon, 26 Oct 2020 11:25:47 +0100 Subject: [PATCH] Fix LTO and _FORTIFY_SOURCE=2 warnings (fixes #5965) Tested with GCC 9 and 10 on AMD64. --- rtengine/dcraw.cc | 4 ++-- rtengine/histmatching.cc | 2 +- rtengine/myfile.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index ed2eea212..fd9f9211b 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1399,7 +1399,7 @@ void CLASS nikon_load_raw() void CLASS nikon_yuv_load_raw() { - int row, col, yuv[4], rgb[3], b, c; + int row, col, yuv[4] = {}, rgb[3], b, c; UINT64 bitbuf=0; for (row=0; row < raw_height; row++) @@ -5620,7 +5620,7 @@ nf: order = 0x4949; if (tag == 2 && strstr(make,"NIKON") && !iso_speed) iso_speed = (get2(),get2()); if ((tag == 0x25 || tag == 0x28) && strstr(make,"NIKON") && !iso_speed) { // Nikon ISOInfo Tags/ISO & ISO2 - uchar iso[1]; + uchar iso[1] = {}; fread (iso, 1, 1, ifp); iso_speed = 100 * pow(2,(float)iso[0]/12.0-5); } diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index 0053cb0d4..d3c5d0190 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -279,7 +279,7 @@ void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, st { RawMetaDataLocation rml; eSensorType sensor_type; - int w, h; + int w = 0, h = 0; std::unique_ptr thumb(Thumbnail::loadQuickFromRaw(getFileName(), rml, sensor_type, w, h, 1, false, true, true)); if (!thumb) { if (settings->verbose) { diff --git a/rtengine/myfile.h b/rtengine/myfile.h index 423edea9a..34b90c525 100644 --- a/rtengine/myfile.h +++ b/rtengine/myfile.h @@ -107,13 +107,13 @@ inline int getc (IMFILE* f) return fgetc(f); } -inline int fread (void* dst, int es, int count, IMFILE* f) +inline int fread (void* dst, size_t es, size_t count, IMFILE* f) { - int s = es * count; - int avail = f->size - f->pos; + size_t s = es * count; + size_t avail = static_cast(f->size) - static_cast(f->pos); - if (s <= avail) { + if (static_cast(s) <= static_cast(avail)) { memcpy (dst, f->data + f->pos, s); f->pos += s;