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

Libraw 0.19 Clang scan-build static analyzer trace #187

Closed
cgilles opened this issue Sep 12, 2018 · 13 comments
Closed

Libraw 0.19 Clang scan-build static analyzer trace #187

cgilles opened this issue Sep 12, 2018 · 13 comments

Comments

@cgilles
Copy link
Contributor

cgilles commented Sep 12, 2018

Hi,

Compiling digiKam 6 including libraw 0.19 source core with scan-build static analyzer report a lots of traces to considerate :

/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:331:5: warning: Null pointer passed as an argument to a 'nonnull' parameter
swab((char )pixel, (char )pixel, count * 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:822:54: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
if ((pixel[(block << 6) + i] = base[i & 1] += diffbuf[i]) >> 10)
~~~~~~~~~~~ ^
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:948:18: warning: The result of the '<<' expression is undefined
if ((diff & (1 << (len - 1))) == 0)
~~^~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:1035:5: warning: Value stored to 'jhigh' is never read
jhigh = 2;
^ ~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:1309:20: warning: The result of the '<<' expression is undefined
if ((coef & (1 << (len - 1))) == 0)
^~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:1502:9: warning: Value stored to 'red' during its initialization is never read
int red = fread(buf, 1, bufsize, ifp);
^
~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:2198:47: warning: Result of 'calloc' is converted to a pointer of type 'short [2]', which is incompatible with sizeof operand type 'unsigned short'
imgdata.rawdata.ph1_cblack = (short(
)[2])calloc(raw_height * 2, sizeof(ushort));
~~~~~~~~~~~ ^~~~~~ ~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:2200:47: warning: Result of 'calloc' is converted to a pointer of type 'short [2]', which is incompatible with sizeof operand type 'unsigned short'
imgdata.rawdata.ph1_rblack = (short(
)[2])calloc(raw_width * 2, sizeof(ushort));
~~~~~~~~~~~ ^~~~~~ ~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:2292:47: warning: Result of 'calloc' is converted to a pointer of type 'short [2]', which is incompatible with sizeof operand type 'unsigned short'
imgdata.rawdata.ph1_cblack = (short(
)[2])calloc(raw_height * 2, sizeof(ushort));
~~~~~~~~~~~ ^~~~~~ ~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:2295:47: warning: Result of 'calloc' is converted to a pointer of type 'short [2]', which is incompatible with sizeof operand type 'unsigned short'
imgdata.rawdata.ph1_rblack = (short(*)[2])calloc(raw_width * 2, sizeof(ushort));
~~~~~~~~~~~ ^~~~~~ ~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:2488:41: warning: Array access (from variable 'pixel') results in a null pointer dereference
image[row * width + col][c] = pixel[col + left_margin];
^~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:2911:19: warning: Array access (from variable 'bytes') results in a null pointer dereference
bytes[byte] = buf[vpos++];
~~~~~ ^
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:3404:21: warning: Value stored to 'myerr' during its initialization is never read
jpegErrorManager *myerr = (jpegErrorManager )cinfo->err;
^~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:3899:12: warning: Assigned value is garbage or undefined
cb += bp[4];
^ ~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:4099:16: warning: Value stored to 'bit' is never read
for (bit = 30, i = 0; i < 16; i++)
^ ~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:4168:42: warning: The left operand of '<<' is a garbage value
RAW(row, col) = curve[pix[i] << 1];
~~~~~~ ^
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:5756:27: warning: The right operand of '>' is a garbage value
d = dir[i = diff[0] > diff[1]];
^ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:5789:19: warning: The right operand of '!=' is a garbage value
if (diff[0] != diff[1])
^ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:6295:7: warning: Value stored to 'tc' is never read
tc = col - left;
^ ~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:6582:27: warning: The left operand of '>' is a garbage value
if (med[opt[i]] > med[opt[i + 1]])
~~~~~~~~~~~ ^
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:6582:27: warning: The right operand of '>' is a garbage value
if (med[opt[i]] > med[opt[i + 1]])
^ ~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:6674:26: warning: The right operand of '/' is a garbage value
if (pixel[c] / hsat[c] == 1 && pixel[kc] > 24000)
^ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:6724:26: warning: The right operand of '/' is a garbage value
if (pixel[c] / hsat[c] > 1)
^ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:7315:44: warning: Array subscript is undefined
imgdata.lens.nikon.NikonLensIDNumber = LensData[i];
^~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8495:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " STF");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8497:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " Reflex");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8499:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " Fisheye");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8502:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " SSM");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8504:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " SAM");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8507:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " OSS");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8510:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " LE");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8513:5: warning: Size argument is greater than the free space in the destination buffer
strnXcat(imgdata.lens.makernotes.LensFeatures_suf, " II");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:8443:31: note: expanded from macro 'strnXcat'
#define strnXcat(buf, string) strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:10834:9: warning: Value stored to 'ntags' is never read
ntags = get2();
^ ~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:11566:46: warning: The right operand of '-' is a garbage value
FORC4 cam_mul[c ^ (c >> 1)] = get4() - SamsungKey[c];
^ ~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:11570:79: warning: The right operand of '-' is a garbage value
FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_Auto][c ^ (c >> 1)] = get4() - SamsungKey[c + 4];
^ ~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:11580:63: warning: The right operand of '-' is a garbage value
imgdata.color.WB_Coeffs[LIBRAW_WBI_Ill_A][0] = get4() - SamsungKey[8];
^ ~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:11592:78: warning: The right operand of '-' is a garbage value
FORC4 imgdata.color.WB_Coeffs[LIBRAW_WBI_D65][c ^ (c >> 1)] = get4() - SamsungKey[c + 1];
^ ~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:11614:45: warning: The right operand of '-' is a garbage value
FORC4 cblack[c ^ (c >> 1)] = get4() - SamsungKey[c];
^ ~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:12052:7: warning: Value stored to 'nwords' is never read
nwords = getwords(buffer, words, 4, sizeof(imgdata.shootinginfo.BodySerial));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:12061:7: warning: Value stored to 'nwords' is never read
nwords = getwords(buffer, words, 4, sizeof(imgdata.shootinginfo.InternalBodySerial));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:12062:7: warning: Function call argument is an uninitialized value
strcpy(imgdata.shootinginfo.InternalBodySerial, words[0]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:13789:13: warning: Value stored to 'makernote_found' is never read
makernote_found = 1;
^ ~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:13806:15: warning: Value stored to 'MakN_length' is never read
MakN_length = get4();
^ ~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:13973:11: warning: Value stored to 'makernote_found' is never read
makernote_found = 1;
^ ~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:15238:11: warning: Value stored to 'k' during its initialization is never read
int k = get2();
^ ~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:15239:11: warning: Value stored to 'l' during its initialization is never read
int l = get2(); /
margins? /
^ ~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:15240:11: warning: Value stored to 'm' during its initialization is never read
int m = get2(); /
margins? */
^ ~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:15241:11: warning: Value stored to 'n' during its initialization is never read
int n = get2();
^ ~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:19508:11: warning: Value stored to 'ill' during its initialization is never read
int ill = tiff_ifd[sidx].dng_color[i].illuminant;
^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 warnings generated.

In file included from /mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/demosaic_packs.cpp:29:
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dht_demosaic.cpp:124:9: warning: Value stored to 'hru' during its initialization is never read
float hru = nraw[nr_offset(y - 1, x + 1)][1] / nraw[nr_offset(y - 1, x + 1)][kc];
^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dht_demosaic.cpp:125:9: warning: Value stored to 'hld' during its initialization is never read
float hld = nraw[nr_offset(y + 1, x - 1)][1] / nraw[nr_offset(y + 1, x - 1)][kc];
^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dht_demosaic.cpp:562:8: warning: Value stored to 'codir' during its initialization is never read
bool codir =
^~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dht_demosaic.cpp:667:7: warning: Value stored to 'l' during its initialization is never read
int l = ndir[nr_offset(y, x)] & 8;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/demosaic_packs.cpp:34:
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dcb_demosaicing.c:46:25: warning: Value stored to 'v' during its initialization is never read
int row, col, u=width, v=2u, indx;
^ ~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dcb_demosaicing.c:60:25: warning: Value stored to 'v' during its initialization is never read
int row, col, u=width, v=2
u, indx;
^ ~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dcb_demosaicing.c:253:30: warning: Value stored to 'v' during its initialization is never read
int row,col,c,d,i,j,u=width,v=2u,w=3u,indx, g1, g2;
^ ~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dcb_demosaicing.c:325:37: warning: Value stored to 'v' during its initialization is never read
int current, row, col, c, u=width, v=2u, indx;
^ ~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/./dcb_demosaicing.c:517:15: warning: Value stored to 'u' during its initialization is never read
int indx, u=width, v=2
width;
^ ~~~~~
9 warnings generated.

In file included from /mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:32:
In file included from /mnt/devel/GIT/6.x/core/libs/rawengine/libraw/libraw/libraw.h:39:
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/libraw/libraw_alloc.h:65:17: warning: Call to 'calloc' has an allocation size of 0 bytes
void *ptr = ::calloc(n + (extra_bytes + sz - 1) / (sz ? sz : 1), sz);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:55:
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_fuji_compressed.cpp:957:3: warning: Value stored to 'line_size' is never read
line_size = sizeof(ushort) * (common_info.line_width + 2);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:689:7: warning: Value stored to 'rawdata' during its initialization is never read
int rawdata = (imgdata.idata.filters || P1.colors == 1);
^~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:1872:7: warning: Value stored to 'tiff_compress' during its initialization is never read
int tiff_compress = libraw_internal_data.unpacker_data.tiff_compress;
^~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:1889:5: warning: Value stored to 'bwide' is never read
bwide = bwide * 16 / 15;
^ ~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:2776:11: warning: Value stored to 'rr' during its initialization is never read
int rr = try_dngsdk();
^~ ~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:3442:14: warning: Value stored to 'save_width' during its initialization is never read
unsigned save_width = S.width;
^~~~~~~~~~ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:4336:17: warning: Value stored to 'remain' is never read
remain -= sz;
^ ~~
In file included from /mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:6097:
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/../internal/libraw_x3f.cpp:782:35: warning: Value stored to 'DEH' during its initialization is never read
x3f_directory_entry_header_t *DEH = &DE->header;
^~~ ~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/../internal/libraw_x3f.cpp:1505:5: warning: Value stored to 'mask' is never read
mask = 0;
^ ~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/../internal/libraw_x3f.cpp:2140:35: warning: Result of 'malloc' is converted to a pointer of type 'char ', which is incompatible with sizeof operand type 'uint8_t '
entry->property_name = (char **)malloc(num
sizeof(uint8_t
));
~~~~~~~ ^~~~~~ ~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:6406:16: warning: Value stored to 'row0_3' during its initialization is never read
uint16_t row0_3 = row0[3];
^~~~~~ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:6408:16: warning: Value stored to 'row1_3' during its initialization is never read
uint16_t row1_3 = row1[3];
^~~~~~ ~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:6427:16: warning: Value stored to 'rowpitch' during its initialization is never read
unsigned int rowpitch = imgdata.rawdata.sizes.raw_pitch / 2; // in 16-bit words
^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/src/libraw_cxx.cpp:6501:16: warning: Value stored to 'rowpitch' during its initialization is never read
unsigned int rowpitch = imgdata.rawdata.sizes.raw_pitch / 2; // in 16-bit words
^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 warnings generated.

Libraw source code embed in digiKam is located here :

https://cgit.kde.org/digikam.git/tree/core/libs/rawengine/libraw

Best

Gilles Caulier

@cgilles
Copy link
Contributor Author

cgilles commented Sep 13, 2018

You can found the full clang scan-build reports generated from digiKam at this url :
https://www.digikam.org/reports/clang/master/
The whole digiKam source code is parsed but you will found all traces about libraw.

@LibRaw LibRaw closed this as completed Sep 18, 2018
@cgilles
Copy link
Contributor Author

cgilles commented Sep 18, 2018

This file have been closed without comment. Why ? There are some fixes in libraw source code about these clang reports ?

@LibRaw
Copy link
Owner

LibRaw commented Sep 18, 2018

Because one-time use of static analysis without suppression of false positives is useless

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

Sure there are certainly false positive, but i use everywhere static analyzer (open source and in my office), and i can said that only 20% of reports can be ignored. The rest is important, or very important to fixes.

Remember that DK is 1.4 M of C++ code lines, and we use 3 static analyzer :
1 cppcheck with few basic reports ignored.
2 krazy for the coding style.
3 clang scan-build which require compilation.

1 and 3 provide excelent HTML reports to analyze. You can identify quickly the problem, and if the reports can be ignored or not. If yes, few rules can be add in source code to ignore checks later.

In my office, where 500.000 code lines in C/C++ are used to control a nuclear reactor, we found petrol in source code. So, i can said 'thanks to static analyzers" for a first check of code before to use it in production.

Gilles Caulier

@LibRaw
Copy link
Owner

LibRaw commented Sep 19, 2018

Let's start from 1st problem reported:

/mnt/devel/GIT/6.x/core/libs/rawengine/libraw/internal/dcraw_common.cpp:822:54: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
if ((pixel[(block << 6) + i] = base[i & 1] += diffbuf[i]) >> 10)

===
In short: it is complete false report. I can explain if needed.

@LibRaw
Copy link
Owner

LibRaw commented Sep 19, 2018

sorry for bad formatting, markup worked not as expected

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

About this one, you must take a look about all conditions tested by clang to arrive at this conclusion. Look the report detail in HTML :

https://www.digikam.org/reports/clang/master/report-82616f.html#EndPath

Gilles Caulier

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

Look also all report about "Out-of-bound array access". This can be instructive...

https://www.digikam.org/reports/clang/master/

Gilles Caulier

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

There is also a divide by zero :

https://www.digikam.org/reports/clang/master/report-0b568e.html#EndPath

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

You have also some less important "Allocator sizeof operand mismatch". this is not cost to fix it...

Gilles Caulier

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

You have also 2 Dereference of null pointer to check.

Gilles

@cgilles
Copy link
Contributor Author

cgilles commented Sep 19, 2018

At least these reports are available for you, and i recommend to not ignore and check well if the information are right or not. In general clang is not too bad. This is my experience.

Gilles Caulier

@LibRaw
Copy link
Owner

LibRaw commented Sep 20, 2018

@cgilles:
1st: I do not see any change to get base[0,1] not initialized before use: pnum is initialized with 0, raw_width is non-zero (checked in open_datastream/identify), so if (pnum++ % raw_width == 0) will success at least once before base[0,1] get used.

2nd: yes, static analysis is, indeed, very helpful. But only if used systematically, on each code change, not as one-time run. Sometimes in future we'll use it (systematically), for now issue is still closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants