fongoses / leptonica

Automatically exported from code.google.com/p/leptonica
0 stars 0 forks source link

A few 'do what I mean not what I say' bugs #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I am studying the code base so I can start using it. I ran a static 
analyisis program on the code. It pointed out what appear to be some typo 
bugs.

There is more that I hope to filter through later but these looked fairly 
straight forward.

-----------

arithlow.c, line 284

'lined' is unsigned so the result of the subtraction will be unsigned.
Unsigned can never be less than 0.

 if (*(lined + j) - threshval >= 0)

-----------

arithlow.c, line 304

'lined' is unsigned so the result of the subtraction will be unsigned.
Unsigned can never be less than 0.

 if (*(lined + j) - threshval <= 0)

-----------

blend.c, line 1508

need test of 'box' for NULL. pixs already tested right above.

is        --> if (!pixs) 
should be --> if (!box) with changed error message.

-----------

colorseg.c, line 1264

need equality test to variable 'type'

is        --> if (L_HS_HISTO || L_HV_HISTO) { 
should be --> if (type == L_HS_HISTO || type == L_HV_HISTO) {

-----------

pix4.c, line 2415

 if (boxs) {

'boxs' can not be NULL (see NULL test above this line). Could simplify 
code by removing if / else statement.

----------

pixabasic.c, line 1068

need equality test to variable 'type'

is        --> if (L_CHOOSE_CONSECUTIVE)
should be --> if (type == L_CHOOSE_CONSECUTIVE)

----------
ptra.c, line 369

need equality test to variable 'shiftflag'

is        --> else if (L_AUTO_DOWNSHIFT) {
should be --> else if (shiftflag == L_AUTO_DOWNSHIFT) {

----------
ptra.c, line 1056

need equality test to variable 'sortorder'

is        --> if (L_SORT_INCREASING) {
should be --> if (sortorder == L_SORT_INCREASING) {

----------
scale.c, line 2660

Use of assigment instead of equality test

is        --> if (type = L_CHOOSE_MIN)
should be --> if (type == L_CHOOSE_MIN)

---------
scale.c, line 2662

Use of assigment instead of equality test

is        --> else if (type = L_CHOOSE_MAX)
should be --> else if (type == L_CHOOSE_MAX)

What is the expected output? What do you see instead?

I did not run the code to verify these are defects.

What version of the product are you using? On what operating system?

Line numbers came from version 1.62

Please provide any additional information below.

Original issue reported on code.google.com by gldray...@gmail.com on 7 Oct 2009 at 2:54

GoogleCodeExporter commented 9 years ago
Thank you.  This is very helpful, and somewhat embarrassing as well  :-)

All suggested changes are accurate, and are fixed in 1.63, which should
come out within a week.

Original comment by dan.bloo...@gmail.com on 7 Oct 2009 at 4:16