IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 20 years ago

Closed 20 years ago

Last modified 20 years ago

#764 closed defect (fixed)

use the PSIMAGE_SET_NUMCOLS, etc macros

Reported by: eugene Owned by: David.Robbins@…
Priority: high Milestone:
Component: mathtypes Version: 0.11.0
Severity: normal Keywords:
Cc:

Description

I have fixed a few examples of code that looks like this:

*(psMathType*)&out->type = image->type;
*(psS32*)&out->numCols = numCols;
*(psS32*)&out->numRows = numRows;

to use the macros defined for this purpose:

P_PSIMAGE_SET_TYPE(out, image->type);
P_PSIMAGE_SET_NUMCOLS(out, numCols);
P_PSIMAGE_SET_NUMROWS(out, numRows);

This operation overrides a 'const' element in a structure.

The danger of the first version, aside from being generally difficult code to
parse, is that the behavior depends on having the correct type set. If the type
is changed, or put in wrong, errors will occur.

I have fixed examples in:

psImageStructManip.c:111-113
psImageStructManip.c:357,358
psImage.c:

(also note that the col0,row0 elements do not need to be modified in this way
since they are not 'const').

Change History (2)

comment:1 by eugene, 20 years ago

Cc: price@… added
Summary: use the PSIMAGE_SET_NUMCOLS, etc macros use the PSIMAGE_SET_NUMCOLS, etc macros

I just discovered that the macro P_PSIMAGE_SET_NUMROWS had an error and was
setting the number of columns instead. Since it was not actually being used,
this didn't actually cause any problems, but still fairly worrisome...

comment:2 by Paul Price, 20 years ago

Resolution: fixed
Status: newclosed

Fixed by EAM.

Note: See TracTickets for help on using tickets.