DanBloomberg / leptonica

Leptonica is an open source library containing software that is broadly useful for image processing and image analysis applications. The official github repository for Leptonica is: danbloomberg/leptonica. See leptonica.org for more documentation.
Other
1.74k stars 387 forks source link

compiler warnings: -Wunused-but-set-variable -Wunused-variable -Wunused-function #655

Closed zdenop closed 1 year ago

zdenop commented 1 year ago

Clang on Windows report quite a lot of warnings regarding unused variables:

[4/181] Building CXX object src\CMakeFiles\leptonica.dir\dnafunc1.c.obj
F:\Projects\Community\leptonica\src\dnafunc1.c(513,14): warning: variable 'hitem' set but not used [-Wunused-but-set-variable]
L_HASHITEM  *hitem;
             ^
1 warning generated.
[18/181] Building CXX object src\CMakeFiles\leptonica.dir\fhmtgenlow.1.c.obj
F:\Projects\Community\leptonica\src\fhmtgenlow.1.c(272,28): warning: variable 'wpls3' set but not used [-Wunused-but-set-variable]
l_int32             wpls2, wpls3, wpls4;
                           ^
F:\Projects\Community\leptonica\src\fhmtgenlow.1.c(273,21): warning: variable 'wpls5' set but not used [-Wunused-but-set-variable]
l_int32             wpls5, wpls6;
                    ^
F:\Projects\Community\leptonica\src\fhmtgenlow.1.c(272,35): warning: variable 'wpls4' set but not used [-Wunused-but-set-variable]
l_int32             wpls2, wpls3, wpls4;
                                  ^
3 warnings generated.
[23/181] Building CXX object src\CMakeFiles\leptonica.dir\gplot.c.obj
F:\Projects\Community\leptonica\src\gplot.c(1203,35): warning: variable 'ignore' set but not used [-Wunused-but-set-variable]
l_int32  outformat, ret, version, ignore;
                                  ^
F:\Projects\Community\leptonica\src\gplot.c(1202,47): warning: variable 'ignores' set but not used [-Wunused-but-set-variable]
char    *rootname, *title, *xlabel, *ylabel, *ignores;
                                              ^
2 warnings generated.
[40/181] Building CXX object src\CMakeFiles\leptonica.dir\kernel.c.obj
F:\Projects\Community\leptonica\src\kernel.c(538,48): warning: variable 'ignore' set but not used [-Wunused-but-set-variable]
l_int32    sy, sx, cy, cx, i, j, ret, version, ignore;
                                               ^
1 warning generated.
[52/181] Building CXX object src\CMakeFiles\leptonica.dir\numafunc2.c.obj
F:\Projects\Community\leptonica\src\numafunc2.c(1742,18): warning: variable 'k' set but not used [-Wunused-but-set-variable]
l_int32    i, j, k, nxvals, occup, count, bincount, binindex, binsize;
                 ^
1 warning generated.
[73/181] Building CXX object src\CMakeFiles\leptonica.dir\leptwin.c.obj
F:\Projects\Community\leptonica\src\leptwin.c(269,15): warning: variable 'nInfoSize' set but not used [-Wunused-but-set-variable]
l_int32       nInfoSize;
              ^
1 warning generated.
[98/181] Building CXX object src\CMakeFiles\leptonica.dir\colormap.c.obj
F:\Projects\Community\leptonica\src\colormap.c(1788,35): warning: variable 'ignore' set but not used [-Wunused-but-set-variable]
l_int32   rval, gval, bval, aval, ignore;
                                  ^
1 warning generated.
[103/181] Building CXX object src\CMakeFiles\leptonica.dir\partition.c.obj
F:\Projects\Community\leptonica\src\partition.c(201,28): warning: variable 'npush' set but not used [-Wunused-but-set-variable]
l_int32  i, w, h, n, nsub, npush, npop;
                           ^
1 warning generated.
[117/181] Building CXX object src\CMakeFiles\leptonica.dir\pixafunc2.c.obj
F:\Projects\Community\leptonica\src\pixafunc2.c(347,28): warning: variable 'size' set but not used [-Wunused-but-set-variable]
l_int32  i, n, x, y, w, h, size, depth, bordval;
                           ^
1 warning generated.
[127/181] Building CXX object src\CMakeFiles\leptonica.dir\pix4.c.obj
F:\Projects\Community\leptonica\src\pix4.c(2652,19): warning: variable 'k' set but not used [-Wunused-but-set-variable]
l_int32     i, j, k, w, h, wpls, wplg;
                  ^
1 warning generated.
[131/181] Building CXX object src\CMakeFiles\leptonica.dir\ptafunc2.c.obj
F:\Projects\Community\leptonica\src\ptafunc2.c(636,14): warning: variable 'hitem' set but not used [-Wunused-but-set-variable]
L_HASHITEM  *hitem;
             ^
1 warning generated.
[132/181] Building CXX object src\CMakeFiles\leptonica.dir\pngio.c.obj
F:\Projects\Community\leptonica\src\pngio.c(191,30): warning: variable 'ncolors' set but not used [-Wunused-but-set-variable]
l_int32      i, j, k, index, ncolors, rval, gval, bval, valid;
                             ^
F:\Projects\Community\leptonica\src\pngio.c(1580,30): warning: variable 'ncolors' set but not used [-Wunused-but-set-variable]
l_int32      i, j, k, index, ncolors, rval, gval, bval, valid;
                             ^
2 warnings generated.
[134/181] Building CXX object src\CMakeFiles\leptonica.dir\pnmio.c.obj
F:\Projects\Community\leptonica\src\pnmio.c(1330,10): warning: unused variable 'ignore' [-Wunused-variable]
l_int32  ignore;
         ^
1 warning generated.
[145/181] Building CXX object src\CMakeFiles\leptonica.dir\rop.c.obj
F:\Projects\Community\leptonica\src\rop.c(541,1): warning: unused function 'checkRasteropCrop' [-Wunused-function]
checkRasteropCrop(l_int32 pixw,
^
1 warning generated.
[149/181] Building CXX object src\CMakeFiles\leptonica.dir\sarray2.c.obj
F:\Projects\Community\leptonica\src\sarray2.c(431,14): warning: variable 'hitem' set but not used [-Wunused-but-set-variable]
L_HASHITEM  *hitem;
             ^
1 warning generated.
[158/181] Building CXX object src\CMakeFiles\leptonica.dir\sel1.c.obj
F:\Projects\Community\leptonica\src\sel1.c(1354,41): warning: variable 'ignore' set but not used [-Wunused-but-set-variable]
l_int32  sy, sx, cy, cx, i, j, version, ignore;
                                        ^
1 warning generated.
[177/181] Building CXX object src\CMakeFiles\leptonica.dir\sarray1.c.obj
F:\Projects\Community\leptonica\src\sarray1.c(1389,47): warning: variable 'ignore' set but not used [-Wunused-but-set-variable]
l_int32  i, n, size, index, bufsize, version, ignore, success;
                                              ^
1 warning generated.
[179/181] Building CXX object src\CMakeFiles\leptonica.dir\utils2.c.obj
F:\Projects\Community\leptonica\src\utils2.c(2215,16): warning: unused variable 'realdir' [-Wunused-variable]
char    *dir, *realdir, *fname, *fullname;
               ^
F:\Projects\Community\leptonica\src\utils2.c(2660,10): warning: variable 'ret' set but not used [-Wunused-but-set-variable]
l_int32  ret;
         ^
DanBloomberg commented 1 year ago

Thank you for checking this.

Most of these are benign and needed for various reasons, such as to keep the compiler from complaining, or for debugging, or because it was removed by the preprocessor because it's on a different platform.

The few unused variables in fhmtgenlow.1.c would be very hard to remove (this is auto-generated code and these are edge cases).

I will remove these unused variables: k in numaDiscretizeHistoInBins() and pixGetBinnedColor() size in pixaDisplayLinear()

DanBloomberg commented 1 year ago

Fixed with commit 45dc614

zdenop commented 1 year ago

thank you Dan.