IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2006, 2:55:23 PM (20 years ago)
Author:
Paul Price
Message:

Addition of a vast quantity of assertions in public functions. Adopted a policy of using assert() within file-static functions (since they are only called internally, any errors there are problems with the program) and using the PS_ASSERT_WHATEVER() macros within public functions. Cleaned a few things up in the process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPACopy.c

    r7168 r7278  
    2424                          )
    2525{
     26    assert(source);
     27
    2628    psImage *copy = psMemIncrRefCounter(source);
    2729    bool copied = false;                // Have the pixels been copied?
     
    5153                     )
    5254{
     55    assert(region);
     56    assert(xBin > 0);
     57    assert(yBin > 0);
     58
    5359    // Want to include the lower bound: 1 binned by 4 --> 0; 3 binned by 4 --> 0; 4 binned by 4 --> 1
    5460    region->x0 = (int)(region->x0 / xBin);
     
    6268                     )
    6369{
     70    assert(cell);
     71
    6472    if (cell->hdu && cell->hdu->phu) {
    6573        return cell->hdu;
     
    274282    assert(target);
    275283    assert(source);
     284    assert(xBin > 0);
     285    assert(yBin > 0);
    276286
    277287    psArray *targetCells = target->cells; // The target cells
     
    300310}
    301311
    302 static int fpaCopy(pmFPA *target,            // The target FPA
    303                    pmFPA *source,            // The source FPA, to be copied
    304                    bool pixels,              // Copy the pixels?
    305                    int xBin, int yBin        // (Relative) binning factors in x and y
    306                   )
     312static bool fpaCopy(pmFPA *target,            // The target FPA
     313                    pmFPA *source,            // The source FPA, to be copied
     314                    bool pixels,              // Copy the pixels?
     315                    int xBin, int yBin        // (Relative) binning factors in x and y
     316                   )
    307317{
    308318    assert(target);
    309319    assert(source);
     320    assert(xBin > 0);
     321    assert(yBin > 0);
    310322
    311323    psArray *targetChips = target->chips; // The target chips
     
    338350//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    339351
    340 int pmFPACopy(pmFPA *target,            // The target FPA
    341               pmFPA *source             // The source FPA, to be copied
    342              )
    343 {
     352bool pmFPACopy(pmFPA *target,            // The target FPA
     353               pmFPA *source             // The source FPA, to be copied
     354              )
     355{
     356    PS_ASSERT_PTR_NON_NULL(target, false);
     357    PS_ASSERT_PTR_NON_NULL(source, false);
    344358    return fpaCopy(target, source, true, 1, 1);
    345359}
    346360
    347 int pmChipCopy(pmChip *target,          // The target chip
    348                pmChip *source           // The source chip, to be copied
    349               )
    350 {
     361bool pmChipCopy(pmChip *target,          // The target chip
     362                pmChip *source           // The source chip, to be copied
     363               )
     364{
     365    PS_ASSERT_PTR_NON_NULL(target, false);
     366    PS_ASSERT_PTR_NON_NULL(source, false);
    351367    return chipCopy(target, source, true, 1, 1);
    352368}
    353369
    354 int pmCellCopy(pmCell *target,          // The target cell
    355                pmCell *source           // The source cell, to be copied
    356               )
    357 {
     370bool pmCellCopy(pmCell *target,          // The target cell
     371                pmCell *source           // The source cell, to be copied
     372               )
     373{
     374    PS_ASSERT_PTR_NON_NULL(target, false);
     375    PS_ASSERT_PTR_NON_NULL(source, false);
    358376    return cellCopy(target, source, true, 1, 1);
    359377}
    360378
    361379
    362 int pmFPACopyStructure(pmFPA *target,   // The target FPA
    363                        pmFPA *source,   // The source FPA, to be copied
    364                        int xBin, int yBin // Binning factors in x and y
    365                       )
    366 {
    367     return fpaCopy(target, source, false, xBin, yBin);
    368 }
    369 
    370 int pmChipCopyStructure(pmChip *target, // The target chip
    371                         pmChip *source, // The source chip, to be copied
     380bool pmFPACopyStructure(pmFPA *target,   // The target FPA
     381                        pmFPA *source,   // The source FPA, to be copied
    372382                        int xBin, int yBin // Binning factors in x and y
    373383                       )
    374384{
     385    PS_ASSERT_PTR_NON_NULL(target, false);
     386    PS_ASSERT_PTR_NON_NULL(source, false);
     387    PS_ASSERT_INT_POSITIVE(xBin, false);
     388    PS_ASSERT_INT_POSITIVE(yBin, false);
     389    return fpaCopy(target, source, false, xBin, yBin);
     390}
     391
     392bool pmChipCopyStructure(pmChip *target, // The target chip
     393                         pmChip *source, // The source chip, to be copied
     394                         int xBin, int yBin // Binning factors in x and y
     395                        )
     396{
     397    PS_ASSERT_PTR_NON_NULL(target, false);
     398    PS_ASSERT_PTR_NON_NULL(source, false);
     399    PS_ASSERT_INT_POSITIVE(xBin, false);
     400    PS_ASSERT_INT_POSITIVE(yBin, false);
    375401    return chipCopy(target, source, false, xBin, yBin);
    376402}
    377403
    378 int pmCellCopyStructure(pmCell *target, // The target cell
    379                         pmCell *source, // The source cell, to be copied
    380                         int xBin, int yBin // Binning factors in x and y
    381                        )
    382 {
     404bool pmCellCopyStructure(pmCell *target, // The target cell
     405                         pmCell *source, // The source cell, to be copied
     406                         int xBin, int yBin // Binning factors in x and y
     407                        )
     408{
     409    PS_ASSERT_PTR_NON_NULL(target, false);
     410    PS_ASSERT_PTR_NON_NULL(source, false);
     411    PS_ASSERT_INT_POSITIVE(xBin, false);
     412    PS_ASSERT_INT_POSITIVE(yBin, false);
    383413    return cellCopy(target, source, false, xBin, yBin);
    384414}
Note: See TracChangeset for help on using the changeset viewer.