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.

Location:
trunk/psModules/src/camera
Files:
15 edited

Legend:

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

    r7017 r7278  
    4141                          )
    4242{
     43    assert(bounds);
     44    assert(chip);
     45
    4346    if (primary) {
    4447        *bounds = psRegionSet(INFINITY, 0, INFINITY, 0);
     
    104107                         )
    105108{
     109    assert(xBinChip);
     110    assert(yBinChip);
     111    assert(chip);
     112
    106113    // Check that we've got the HDU in the chip or the FPA
    107114    if ((!chip->hdu || !chip->hdu->images) && (!chip->parent->hdu || !chip->parent->hdu->images)) {
     
    358365                        )
    359366{
     367    assert(target);
     368    assert(sources);
     369    assert(xBin > 0 && yBin > 0);
     370    assert(trimsec);
     371
    360372    bool success = true;                // Result of setting everything
    361373    float gain       = 0.0;             // Gain
     
    433445    }
    434446
    435 
    436447    return success;
    437448}
     
    446457               )
    447458{
     459    assert(mosaicImage);
     460    assert(mosaicMask);
     461    assert(mosaicWeights);
     462    assert(chip);
     463
    448464    psArray *cells = chip->cells;       // The array of cells
    449465    int numCells = cells->n;            // Number of cells
     
    587603                 )
    588604{
     605    PS_ASSERT_PTR_NON_NULL(chip, false);
     606
    589607    psImage *mosaicImage   = NULL;      // The mosaic image
    590608    psImage *mosaicMask    = NULL;      // The mosaic mask
  • trunk/psModules/src/camera/pmFPA.c

    r7274 r7278  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-06-01 22:43:26 $
     14*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-06-02 00:55:22 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    399399}
    400400
    401 bool pmChipSetFileStatus pmChip *chip, bool status)
     401bool pmChipSetFileStatus(pmChip *chip, bool status)
    402402{
    403403    PS_ASSERT_PTR_NON_NULL(chip, false);
  • trunk/psModules/src/camera/pmFPAConstruct.c

    r7168 r7278  
    2121                              )
    2222{
     23    assert(format);
     24    assert(cellName && strlen(cellName) > 0);
     25
    2326    bool status = true;                 // Result of MD lookup
    2427    psMetadata *cells = psMetadataLookupMD(&status, format, "CELLS"); // The CELLS
     
    4346                        )
    4447{
     48    assert(first);
     49    assert(second);
     50    assert(third);
     51    assert(string && strlen(string) > 0);
     52
    4553    bool allOK = true;                  // Everything was OK?
    4654    psList *values = psStringSplit(string, " ,;", true); // List of the parts
     
    96104                                 )
    97105{
     106    assert(name && strlen(name) > 0);
     107    assert(fileInfo);
     108    assert(header);
     109
    98110    bool mdok = true;                   // Result of MD lookup
    99111    psString keyword = psMetadataLookupStr(&mdok, fileInfo, name);
     
    188200                             )
    189201{
     202    assert(fileInfo);
     203    assert(contents);
     204    assert(header);
     205
    190206    bool mdok = true;                   // Status of MD lookup
    191207    const char *contentHeaders = psMetadataLookupStr(&mdok, fileInfo, "CONTENT"); // Headers for content
     
    237253    assert(contents && strlen(contents) > 0);
    238254    assert(!cell || (cell && chip));    // Need both chip and cell if given a cell
     255    assert(format);
    239256
    240257    if (hdu && level == PM_FPA_LEVEL_FPA) {
     
    329346                          )
    330347{
     348    assert(format);
     349
    331350    bool mdok = true;                   // Status of MD lookup
    332351    psMetadata *file = psMetadataLookupMD(&mdok, format, "FILE"); // File information
     
    363382                     )
    364383{
     384    PS_ASSERT_PTR_NON_NULL(camera, NULL);
     385
    365386    pmFPA *fpa = pmFPAAlloc(camera);    // The FPA to fill out
    366387
     
    400421                           )
    401422{
    402     assert(fpa);
    403     assert(phuView);
    404     assert(format);
     423    PS_ASSERT_PTR_NON_NULL(fpa, false);
     424    PS_ASSERT_PTR_NON_NULL(phuView, false);
     425    PS_ASSERT_PTR_NON_NULL(format, false);
    405426
    406427    // Where does the PHU go?
     
    495516                                   )
    496517{
    497     assert(fpa);
    498     assert(phu);
    499     assert(format);
     518    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
     519    PS_ASSERT_PTR_NON_NULL(phu, NULL);
     520    PS_ASSERT_PTR_NON_NULL(format, NULL);
    500521
    501522    bool mdok = true;                   // Status from metadata lookups
     
    689710               )
    690711{
     712    PS_ASSERT_PTR_NON_NULL(fpa,);
     713
    691714    psTrace(__func__, 1, "FPA:\n");
    692715    if (fpa->hdu) {
  • 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}
  • trunk/psModules/src/camera/pmFPACopy.h

    r7017 r7278  
    33
    44// Copy the FPA components, including the pixels
    5 int pmFPACopy(pmFPA *target,            // The target FPA
    6               pmFPA *source             // The source FPA, to be copied
    7              );
    8 int pmChipCopy(pmChip *target,          // The target chip
    9                pmChip *source           // The source chip, to be copied
     5bool pmFPACopy(pmFPA *target,            // The target FPA
     6               pmFPA *source             // The source FPA, to be copied
    107              );
    11 int pmCellCopy(pmCell *target,          // The target cell
    12                pmCell *source           // The source cell, to be copied
    13               );
     8bool pmChipCopy(pmChip *target,          // The target chip
     9                pmChip *source           // The source chip, to be copied
     10               );
     11bool pmCellCopy(pmCell *target,          // The target cell
     12                pmCell *source           // The source cell, to be copied
     13               );
    1414
    1515// Versions that copy the structure and not the pixels; they also allow binning
    16 int pmFPACopyStructure(pmFPA *target,   // The target FPA
    17                        pmFPA *source,   // The source FPA, to be copied
    18                        int xBin, int yBin     // Binning factors in x and y
    19                       );
    20 int pmChipCopyStructure(pmChip *target, // The target chip
    21                         pmChip *source, // The source chip, to be copied
    22                         int xBin, int yBin   // Binning factors in x and y
     16bool pmFPACopyStructure(pmFPA *target,   // The target FPA
     17                        pmFPA *source,   // The source FPA, to be copied
     18                        int xBin, int yBin     // Binning factors in x and y
    2319                       );
    24 int pmCellCopyStructure(pmCell *target, // The target cell
    25                         pmCell *source, // The source cell, to be copied
    26                         int xBin, int yBin // Binning factors in x and y
    27                        );
     20bool pmChipCopyStructure(pmChip *target, // The target chip
     21                         pmChip *source, // The source chip, to be copied
     22                         int xBin, int yBin   // Binning factors in x and y
     23                        );
     24bool pmCellCopyStructure(pmCell *target, // The target cell
     25                         pmCell *source, // The source cell, to be copied
     26                         int xBin, int yBin // Binning factors in x and y
     27                        );
    2828
    2929
  • trunk/psModules/src/camera/pmFPAHeader.c

    r7274 r7278  
    1515                        )
    1616{
     17    assert(chip);
     18
    1719    bool status = true;                 // Status of concept reading
    1820    status |= pmConceptsReadChip(chip, PM_CONCEPT_SOURCE_HEADER, false, NULL);
     
    3335                       )
    3436{
     37    assert(fpa);
     38
    3539    bool status = true;                 // Status of concept reading
    3640    status |= pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL);
  • trunk/psModules/src/camera/pmFPARead.c

    r7274 r7278  
    2727                        )
    2828{
     29    assert(readout);
     30    assert(image);
     31    assert(trimsec);
     32    assert(biassecs);
     33
    2934    // The image corresponding to the trim region
    3035    if (psRegionIsBad(*trimsec)) {
     
    8590                             )
    8691{
     92    assert(fits);
     93    assert(region);
     94
    8795    bool resize = false;                // Do we need to resize the image once read?
    8896    psRegion toRead = psRegionSet(region->x0, region->x1, region->y0, region->y1); // Region to read
     
    158166                      )
    159167{
     168    PS_ASSERT_PTR_NON_NULL(readout, false);
     169    PS_ASSERT_PTR_NON_NULL(fits, false);
     170    PS_ASSERT_INT_NONNEGATIVE(z, false);
     171    PS_ASSERT_INT_NONNEGATIVE(numScans, false);
     172
    160173    // Get the HDU and read the header
    161174    pmCell *cell = readout->parent;     // The parent cell
     
    298311               )
    299312{
     313    PS_ASSERT_PTR_NON_NULL(cell, false);
     314    PS_ASSERT_PTR_NON_NULL(fits, false);
     315
    300316    pmHDU *hdu = pmHDUFromCell(cell);   // The HDU
    301317    if (!hdu) {
     
    345361               )
    346362{
     363    PS_ASSERT_PTR_NON_NULL(chip, false);
     364    PS_ASSERT_PTR_NON_NULL(fits, false);
     365
    347366    bool success = false;               // Were we able to read at least one HDU?
    348367    psArray *cells = chip->cells;       // Array of cells
     
    366385              )
    367386{
     387    PS_ASSERT_PTR_NON_NULL(fpa, false);
     388    PS_ASSERT_PTR_NON_NULL(fits, false);
     389
    368390    bool success = false;               // Were we able to read at least one HDU?
    369391    psArray *chips = fpa->chips;        // Array of chips
  • trunk/psModules/src/camera/pmFPAUtils.c

    r7017 r7278  
    99                 )
    1010{
    11     psArray *chips = fpa->chips;    // Array of chips
     11    PS_ASSERT_PTR_NON_NULL(fpa, -1);
     12    PS_ASSERT_PTR_NON_NULL(name, -1);
     13    if (strlen(name) == 0) {
     14        return -1;
     15    }
     16
     17    psArray *chips = fpa->chips;        // Array of chips
    1218    for (int i = 0; i < chips->n; i++) {
    1319        pmChip *chip = chips->data[i]; // The chip of interest
     
    2733                  )
    2834{
     35    PS_ASSERT_PTR_NON_NULL(chip, -1);
     36    PS_ASSERT_PTR_NON_NULL(name, -1);
     37    if (strlen(name) == 0) {
     38        return -1;
     39    }
     40
    2941    psArray *cells = chip->cells;    // Array of cells
    3042    for (int i = 0; i < cells->n; i++) {
  • trunk/psModules/src/camera/pmFPAWrite.c

    r7249 r7278  
    1616                       )
    1717{
     18    PS_ASSERT_PTR_NON_NULL(readout, false);
     19    PS_ASSERT_PTR_NON_NULL(fits, false);
     20
    1821    pmHDU *hdu = pmHDUFromReadout(readout); // The HDU to which to write
    1922    if (!hdu) {
     
    8790                )
    8891{
     92    PS_ASSERT_PTR_NON_NULL(cell, false);
     93    PS_ASSERT_PTR_NON_NULL(fits, false);
     94
    8995    pmHDU *hdu = cell->hdu;             // The HDU
    9096    if (!hdu) {
     
    118124                )
    119125{
     126    PS_ASSERT_PTR_NON_NULL(chip, false);
     127    PS_ASSERT_PTR_NON_NULL(fits, false);
     128
    120129    pmHDU *hdu = chip->hdu;             // The HDU
    121130    if (!hdu) {
     
    156165               )
    157166{
     167    PS_ASSERT_PTR_NON_NULL(fpa, false);
     168    PS_ASSERT_PTR_NON_NULL(fits, false);
     169
    158170    pmHDU *hdu = fpa->hdu;              // The HDU
    159171    if (!hdu) {
  • trunk/psModules/src/camera/pmFPA_JPEG.c

    r7017 r7278  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-05-01 01:55:43 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-06-02 00:55:22 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828
    2929
    30 bool pmFPAviewWriteJPEG (const pmFPAview *view, pmFPAfile *file)
     30bool pmFPAviewWriteJPEG(const pmFPAview *view, pmFPAfile *file)
    3131{
     32    PS_ASSERT_PTR_NON_NULL(view, false);
     33    PS_ASSERT_PTR_NON_NULL(file, false);
    3234
    3335    pmFPA *fpa = file->fpa;
     
    7072bool pmFPAWriteJPEG (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
    7173{
     74    PS_ASSERT_PTR_NON_NULL(fpa, false);
     75    PS_ASSERT_PTR_NON_NULL(view, false);
     76    PS_ASSERT_PTR_NON_NULL(file, false);
    7277
    7378    for (int i = 0; i < fpa->chips->n; i++) {
     
    8287bool pmChipWriteJPEG (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
    8388{
     89    PS_ASSERT_PTR_NON_NULL(chip, false);
     90    PS_ASSERT_PTR_NON_NULL(view, false);
     91    PS_ASSERT_PTR_NON_NULL(file, false);
    8492
    8593    for (int i = 0; i < chip->cells->n; i++) {
     
    94102bool pmCellWriteJPEG (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
    95103{
     104    PS_ASSERT_PTR_NON_NULL(cell, false);
     105    PS_ASSERT_PTR_NON_NULL(view, false);
     106    PS_ASSERT_PTR_NON_NULL(file, false);
    96107
    97108    for (int i = 0; i < cell->readouts->n; i++) {
     
    106117bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
    107118{
     119    PS_ASSERT_PTR_NON_NULL(readout, false);
     120    PS_ASSERT_PTR_NON_NULL(view, false);
     121    PS_ASSERT_PTR_NON_NULL(file, false);
     122
    108123    char *name, *mode, *word, *mapname;
    109124    psArray *range;
  • trunk/psModules/src/camera/pmFPAfile.c

    r7249 r7278  
    2222#include "pmFPA_JPEG.h"
    2323
    24 static void pmFPAfileFree (pmFPAfile *file)
    25 {
    26 
    27     if (file == NULL)
     24static void pmFPAfileFree(pmFPAfile *file)
     25{
     26    if (!file) {
    2827        return;
     28    }
    2929
    3030    psFree (file->fpa);
     
    5454}
    5555
    56 pmFPAfile *pmFPAfileAlloc ()
    57 {
    58 
    59     pmFPAfile *file = psAlloc (sizeof(pmFPAfile));
    60     psMemSetDeallocator (file, (psFreeFunc) pmFPAfileFree);
     56pmFPAfile *pmFPAfileAlloc()
     57{
     58    pmFPAfile *file = psAlloc(sizeof(pmFPAfile));
     59    psMemSetDeallocator(file, (psFreeFunc) pmFPAfileFree);
    6160
    6261    file->phu = NULL;
     
    8382    file->state = PM_FPA_STATE_CLOSED;
    8483
    85     return (file);
    86 }
    87 
    88 pmFPAfile *pmFPAfileDefine (psMetadata *files, psMetadata *camera, pmFPA *fpa, char *name)
    89 {
     84    return file;
     85}
     86
     87pmFPAfile *pmFPAfileDefine(psMetadata *files, psMetadata *camera, pmFPA *fpa, char *name)
     88{
     89    PS_ASSERT_PTR_NON_NULL(files, NULL);
     90    PS_ASSERT_PTR_NON_NULL(camera, NULL);
     91    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
     92    PS_ASSERT_PTR_NON_NULL(name, NULL);
     93    PS_ASSERT_INT_POSITIVE(strlen(name), NULL);
    9094
    9195    bool status;
     
    243247bool pmFPAfileOpen (pmFPAfile *file, const pmFPAview *view)
    244248{
     249    PS_ASSERT_PTR_NON_NULL(file, false);
     250    PS_ASSERT_PTR_NON_NULL(view, false);
    245251
    246252    bool status;
     
    325331}
    326332
    327 bool pmFPAfileRead (pmFPAfile *file, const pmFPAview *view)
    328 {
     333bool pmFPAfileRead(pmFPAfile *file, const pmFPAview *view)
     334{
     335    PS_ASSERT_PTR_NON_NULL(file, false);
     336    PS_ASSERT_PTR_NON_NULL(view, false);
     337
    329338    if (file->state & PM_FPA_STATE_INACTIVE)
    330339        return false;
     
    378387}
    379388
    380 bool pmFPAfileWrite (pmFPAfile *file, const pmFPAview *view)
    381 {
     389bool pmFPAfileWrite(pmFPAfile *file, const pmFPAview *view)
     390{
     391    PS_ASSERT_PTR_NON_NULL(file, false);
     392    PS_ASSERT_PTR_NON_NULL(view, false);
    382393
    383394    if (file->state & PM_FPA_STATE_INACTIVE) {
     
    436447bool pmFPAfileCreate (pmFPAfile *file, const pmFPAview *view)
    437448{
     449    PS_ASSERT_PTR_NON_NULL(file, false);
     450    PS_ASSERT_PTR_NON_NULL(view, false);
     451
    438452    if (file->state & PM_FPA_STATE_INACTIVE) {
    439453        return false;
     
    478492bool pmFPAfileClose (pmFPAfile *file, const pmFPAview *view)
    479493{
     494    PS_ASSERT_PTR_NON_NULL(file, false);
     495    PS_ASSERT_PTR_NON_NULL(view, false);
     496
    480497    if (file->state & PM_FPA_STATE_INACTIVE) {
    481498        return false;
     
    524541bool pmFPAfileActivate (psMetadata *files, bool state, char *name)
    525542{
    526     if (name == NULL) {
     543    PS_ASSERT_PTR_NON_NULL(files, false);
     544
     545    if (!name) {
    527546        psMetadataItem *item = NULL;
    528547        psMetadataIterator *iter = psMetadataIteratorAlloc (files, PS_LIST_HEAD, NULL);
     
    555574bool pmFPAfileIOChecks (psMetadata *files, const pmFPAview *view, pmFPAfilePlace place)
    556575{
     576    PS_ASSERT_PTR_NON_NULL(files, false);
     577    PS_ASSERT_PTR_NON_NULL(view, false);
     578
    557579    // recipe override values (command-line options):
    558580    psMetadataItem *item = NULL;
     
    577599pmReadout *pmFPAfileCreateInternal (psMetadata *files, char *name, int Nx, int Ny, int type)
    578600{
    579     pmReadout *readout = pmReadoutAlloc (NULL);
    580     readout->image = psImageAlloc (Nx, Ny, type);
     601    PS_ASSERT_PTR_NON_NULL(files, false);
     602    PS_ASSERT_PTR_NON_NULL(name, false);
     603    PS_ASSERT_INT_POSITIVE(strlen(name), false);
     604
     605    pmReadout *readout = pmReadoutAlloc(NULL);
     606    readout->image = psImageAlloc(Nx, Ny, type);
    581607
    582608    // I want an image from the
     
    585611
    586612    file->readout = readout;
    587     psMetadataAddPtr (files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file);
    588     psFree (file);
     613    psMetadataAddPtr(files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file);
     614    psFree(file);
    589615    // we free this copy of file, but 'files' still has a copy
    590616
    591     return (readout);
    592 }
    593 
    594 bool pmFPAfileDropInternal (psMetadata *files, char *name)
    595 {
     617    return readout;
     618}
     619
     620bool pmFPAfileDropInternal(psMetadata *files, char *name)
     621{
     622    PS_ASSERT_PTR_NON_NULL(files, false);
     623    PS_ASSERT_PTR_NON_NULL(name, false);
     624    PS_ASSERT_INT_POSITIVE(strlen(name), false);
     625
    596626    bool status;
    597627
     
    610640pmReadout *pmFPAfileThisReadout (psMetadata *files, const pmFPAview *view, const char *name)
    611641{
     642    PS_ASSERT_PTR_NON_NULL(files, false);
     643    PS_ASSERT_PTR_NON_NULL(view, false);
     644    PS_ASSERT_PTR_NON_NULL(name, false);
     645    PS_ASSERT_INT_POSITIVE(strlen(name), false);
     646
    612647    bool status;
    613648
     
    629664bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file)
    630665{
     666    PS_ASSERT_PTR_NON_NULL(view, false);
     667    PS_ASSERT_PTR_NON_NULL(file, false);
     668
    631669    bool status;
    632670    pmFPA *fpa = file->fpa;
     
    680718bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file)
    681719{
     720    PS_ASSERT_PTR_NON_NULL(view, false);
     721    PS_ASSERT_PTR_NON_NULL(file, false);
    682722
    683723    pmFPA *fpa = file->fpa;
     
    748788pmFPAfile *pmFPAfileFromArgs (bool *found, pmConfig *config, char *filename, char *argname)
    749789{
     790    PS_ASSERT_PTR_NON_NULL(config, false);
     791    PS_ASSERT_PTR_NON_NULL(filename, false);
     792    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
     793    PS_ASSERT_PTR_NON_NULL(argname, false);
     794    PS_ASSERT_INT_POSITIVE(strlen(argname), false);
     795
    750796    bool status;
    751797    pmFPA *fpa = NULL;
     
    755801    psMetadata *format = NULL;
    756802
    757     if (*found)
    758         return NULL;
     803    if (*found) {
     804        return NULL;
     805    }
    759806
    760807    // we search the argument data for the named fileset (argname)
    761808    psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname);
    762     if (!status)
    763         return NULL;
    764     if (infiles->n < 1)
    765         return NULL;
     809    if (!status) {
     810        return NULL;
     811    }
     812    if (infiles->n < 1) {
     813        return NULL;
     814    }
    766815
    767816    // determine the current format from the header
     
    836885pmFPAfile *pmFPAfileSetFromArgs (bool *found, pmConfig *config, char *filename, char *argname)
    837886{
     887    PS_ASSERT_PTR_NON_NULL(config, false);
     888    PS_ASSERT_PTR_NON_NULL(filename, false);
     889    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
     890    PS_ASSERT_PTR_NON_NULL(argname, false);
     891    PS_ASSERT_INT_POSITIVE(strlen(argname), false);
     892
    838893    bool status;
    839894    pmFPA *fpa = NULL;
     
    848903    // we search the argument data for the named fileset (argname)
    849904    psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname);
    850     if (!status)
    851         return NULL;
    852     if (infiles->n < 1)
    853         return NULL;
     905    if (!status) {
     906        return NULL;
     907    }
     908    if (infiles->n < 1) {
     909        return NULL;
     910    }
    854911
    855912    // determine the current format from the header
     
    914971pmFPAfile *pmFPAfileFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, char *filename)
    915972{
     973    PS_ASSERT_PTR_NON_NULL(config, false);
     974    PS_ASSERT_PTR_NON_NULL(src, false);
     975    PS_ASSERT_PTR_NON_NULL(filename, false);
     976    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
     977
    916978    // XXX pmFPAConstruct has many leaks (6919)
    917979    pmFPA *fpa = pmFPAConstruct (config->camera);
     
    928990pmFPAfile *pmFPAfileFromConf (bool *found, pmConfig *config, char *filename, pmFPA *input)
    929991{
     992    PS_ASSERT_PTR_NON_NULL(config, false);
     993    PS_ASSERT_PTR_NON_NULL(filename, false);
     994    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
     995    PS_ASSERT_PTR_NON_NULL(input, false);
     996
    930997    psFits *fits = NULL;
    931998    pmFPAfile *file = NULL;
     
    9341001    psArray *infiles = NULL;
    9351002
    936     if (*found)
    937         return NULL;
     1003    if (*found) {
     1004        return NULL;
     1005    }
    9381006
    9391007    // a camera config is needed (as source of file rule)
     
    9511019
    9521020    // image names come from the file->name list?
    953     if (!strcasecmp (file->filerule, "@FILES"))
     1021    if (!strcasecmp (file->filerule, "@FILES")) {
    9541022        psAbort ("pmFPAfileFromConfig", "programming error");
     1023    }
    9551024
    9561025    // image needs to come from the detrend database
     
    9641033        infiles->data[0] = psStringCopy (file->filerule);
    9651034    }
    966     if (infiles == NULL)
    967         return NULL;
     1035    if (infiles == NULL) {
     1036        return NULL;
     1037    }
    9681038    if (infiles->n < 1) {
    9691039        psFree (infiles);
     
    10181088bool pmFPAfileAddFileNames (psMetadata *files, char *name, char *value, int mode)
    10191089{
     1090    PS_ASSERT_PTR_NON_NULL(files, false);
     1091    PS_ASSERT_PTR_NON_NULL(name, false);
     1092    PS_ASSERT_INT_POSITIVE(strlen(name), false);
     1093    PS_ASSERT_PTR_NON_NULL(value, false);
     1094    PS_ASSERT_INT_POSITIVE(strlen(value), false);
    10201095
    10211096    // add the output names to the output-type files
     
    10361111char *pmFPAfileNameFromRule (char *rule, pmFPAfile *file, const pmFPAview *view)
    10371112{
     1113    PS_ASSERT_PTR_NON_NULL(rule, NULL);
     1114    PS_ASSERT_INT_POSITIVE(strlen(rule), NULL);
     1115    PS_ASSERT_PTR_NON_NULL(file, NULL);
     1116    PS_ASSERT_PTR_NON_NULL(view, NULL);
    10381117
    10391118    char *newName = NULL;     // destination for resulting name
     
    10781157bool pmFPAfileCopyView (pmFPA *out, pmFPA *in, const pmFPAview *view)
    10791158{
     1159    PS_ASSERT_PTR_NON_NULL(out, false);
     1160    PS_ASSERT_PTR_NON_NULL(in, false);
     1161    PS_ASSERT_PTR_NON_NULL(view, false);
     1162
    10801163    // pmFPAWrite takes care of all PHUs as needed
    10811164    if (view->chip == -1) {
     
    11121195bool pmFPAfileCopyStructureView (pmFPA *out, pmFPA *in, psMetadata *format, int xBin, int yBin, const pmFPAview *view)
    11131196{
     1197    PS_ASSERT_PTR_NON_NULL(out, false);
     1198    PS_ASSERT_PTR_NON_NULL(in, false);
     1199    PS_ASSERT_PTR_NON_NULL(format, false);
     1200    PS_ASSERT_PTR_NON_NULL(view, false);
     1201
    11141202    // pmFPAWrite takes care of all PHUs as needed
    11151203    if (view->chip == -1) {
  • trunk/psModules/src/camera/pmFPAview.c

    r7017 r7278  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-05-01 01:55:43 $
     5 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-06-02 00:55:22 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1919#include "pmFPAview.h"
    2020
    21 static void pmFPAviewFree (pmFPAview *view)
    22 {
    23     if (view == NULL)
    24         return;
     21static void pmFPAviewFree(pmFPAview *view)
     22{
     23    // No reason to keep this function, apart from the fact that it allows us to type the memBlock
    2524    return;
    2625}
    2726
    28 pmFPAview *pmFPAviewAlloc (int nRows)
    29 {
    30     pmFPAview *view = psAlloc (sizeof(pmFPAview));
    31     psMemSetDeallocator (view, (psFreeFunc) pmFPAviewFree);
     27pmFPAview *pmFPAviewAlloc(int nRows)
     28{
     29    pmFPAview *view = psAlloc(sizeof(pmFPAview));
     30    psMemSetDeallocator(view, (psFreeFunc) pmFPAviewFree);
    3231
    3332    view->chip    = -1;
     
    3635    view->iRows   =  0;
    3736    view->nRows   = nRows;
    38     return (view);
    39 }
    40 
    41 pmFPAdepth pmFPAviewDepth (const pmFPAview *view)
    42 {
     37    return view;
     38}
     39
     40pmFPAdepth pmFPAviewDepth(const pmFPAview *view)
     41{
     42    PS_ASSERT_PTR_NON_NULL(view, PM_FPA_DEPTH_NONE);
    4343
    4444    if (view->chip < 0) {
     
    5454}
    5555
    56 pmChip *pmFPAviewThisChip (const pmFPAview *view, pmFPA *fpa)
    57 {
     56pmChip *pmFPAviewThisChip(const pmFPAview *view, pmFPA *fpa)
     57{
     58    PS_ASSERT_PTR_NON_NULL(view, NULL);
     59    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    5860
    5961    if (view->chip < 0) {
     
    6971}
    7072
    71 pmChip *pmFPAviewNextChip (pmFPAview *view, pmFPA *fpa, int nStep)
    72 {
     73pmChip *pmFPAviewNextChip(pmFPAview *view, pmFPA *fpa, int nStep)
     74{
     75    PS_ASSERT_PTR_NON_NULL(view, NULL);
     76    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
     77
    7378    view->cell = -1;
    7479    view->readout = -1;
     
    100105}
    101106
    102 pmCell *pmFPAviewThisCell (const pmFPAview *view, pmFPA *fpa)
    103 {
     107pmCell *pmFPAviewThisCell(const pmFPAview *view, pmFPA *fpa)
     108{
     109    PS_ASSERT_PTR_NON_NULL(view, NULL);
     110    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    104111
    105112    if (view->cell < 0) {
     
    108115
    109116    pmChip *chip = pmFPAviewThisChip (view, fpa);
    110     if (chip == NULL) {
    111         return NULL;
    112     }
     117    PS_ASSERT_PTR_NON_NULL(chip, NULL);
    113118
    114119    if (view->cell >= chip->cells->n) {
     
    122127pmCell *pmFPAviewNextCell (pmFPAview *view, pmFPA *fpa, int nStep)
    123128{
     129    PS_ASSERT_PTR_NON_NULL(view, NULL);
     130    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    124131
    125132    pmChip *chip = pmFPAviewThisChip (view, fpa);
    126     if (chip == NULL) {
    127         return NULL;
    128     }
     133    PS_ASSERT_PTR_NON_NULL(chip, NULL);
    129134
    130135    view->readout = -1;
     
    158163pmReadout *pmFPAviewThisReadout (const pmFPAview *view, pmFPA *fpa)
    159164{
     165    PS_ASSERT_PTR_NON_NULL(view, NULL);
     166    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    160167
    161168    if (view->readout < 0) {
     
    164171
    165172    pmCell *cell = pmFPAviewThisCell (view, fpa);
    166     if (cell == NULL) {
    167         return NULL;
    168     }
     173    PS_ASSERT_PTR_NON_NULL(cell, NULL);
    169174
    170175    if (view->readout >= cell->readouts->n) {
     
    178183pmReadout *pmFPAviewNextReadout (pmFPAview *view, pmFPA *fpa, int nStep)
    179184{
     185    PS_ASSERT_PTR_NON_NULL(view, NULL);
     186    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    180187
    181188    pmCell *cell = pmFPAviewThisCell (view, fpa);
    182     if (cell == NULL) {
    183         return NULL;
    184     }
     189    PS_ASSERT_PTR_NON_NULL(cell, NULL);
    185190
    186191    view->iRows = 0;
     
    211216}
    212217
    213 pmHDU *pmFPAviewThisHDU (const pmFPAview *view, pmFPA *fpa)
    214 {
     218pmHDU *pmFPAviewThisHDU(const pmFPAview *view, pmFPA *fpa)
     219{
     220    PS_ASSERT_PTR_NON_NULL(view, NULL);
     221    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
     222
    215223    // the HDU is attached to a cell, chip or fpa
    216224    // if this view has a -1 for the level which contains the hdu,
     
    229237}
    230238
    231 pmHDU *pmFPAviewThisPHU (const pmFPAview *view, pmFPA *fpa)
    232 {
     239pmHDU *pmFPAviewThisPHU(const pmFPAview *view, pmFPA *fpa)
     240{
     241    PS_ASSERT_PTR_NON_NULL(view, NULL);
     242    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
     243
    233244    // select the HDU which corresponds to the PHU containing this view
    234245
  • trunk/psModules/src/camera/pmHDU.c

    r7241 r7278  
    6161    psMemSetDeallocator(hdu, (psFreeFunc)hduFree);
    6262
    63     if (! extname || strlen(extname) == 0) {
     63    if (!extname || strlen(extname) == 0) {
    6464        hdu->phu = true;
    6565        hdu->extname = psStringCopy("PHU");
     
    8686                    )
    8787{
    88     assert(hdu);
    89     assert(fits);
     88    PS_ASSERT_PTR_NON_NULL(hdu, false);
     89    PS_ASSERT_PTR_NON_NULL(fits, false);
    9090
    9191    // Move to the appropriate extension
     
    113113              )
    114114{
    115     assert(hdu);
    116     assert(fits);
     115    PS_ASSERT_PTR_NON_NULL(hdu, false);
     116    PS_ASSERT_PTR_NON_NULL(fits, false);
    117117
    118118    // Read the header; includes the move
     
    159159               )
    160160{
    161     assert(hdu);
    162     assert(fits);
     161    PS_ASSERT_PTR_NON_NULL(hdu, false);
     162    PS_ASSERT_PTR_NON_NULL(fits, false);
    163163
    164164    psTrace(__func__, 7, "Writing HDU %s\n", hdu->extname);
  • trunk/psModules/src/camera/pmHDUGenerate.c

    r7257 r7278  
    437437                         )
    438438{
     439    PS_ASSERT_PTR_NON_NULL(cell, false);
     440
    439441    // Get the HDU and a list of cells below it
    440442    pmHDU *hdu = pmHDUFromCell(cell); // The HDU in the cell
     
    487489                         )
    488490{
     491    PS_ASSERT_PTR_NON_NULL(chip, false);
     492
    489493    // Get the HDU and a list of cells below it
    490494    pmHDU *hdu = pmHDUFromChip(chip);   // The HDU in the chip
     
    536540                        )
    537541{
     542    PS_ASSERT_PTR_NON_NULL(fpa, false);
     543
    538544    // Get the HDU and a list of cells below it
    539545    pmHDU *hdu = pmHDUFromFPA(fpa);     // The HDU in the FPA
  • trunk/psModules/src/camera/pmHDUUtils.c

    r7168 r7278  
    88                   )
    99{
     10    PS_ASSERT_PTR_NON_NULL(fpa, NULL);
    1011    return fpa->hdu;
    1112}
     
    1415                    )
    1516{
     17    PS_ASSERT_PTR_NON_NULL(chip, NULL);
     18
    1619    pmHDU *hdu = chip->hdu;             // The HDU information
    1720    if (!hdu) {
     
    2528                    )
    2629{
     30    PS_ASSERT_PTR_NON_NULL(cell, NULL);
     31
    2732    pmHDU *hdu = cell->hdu;             // The HDU information
    2833    if (!hdu) {
     
    3338}
    3439
    35 pmHDU *pmHDUFromReadout (pmReadout *readout)
     40pmHDU *pmHDUFromReadout(pmReadout *readout)
    3641{
     42    PS_ASSERT_PTR_NON_NULL(readout, NULL);
    3743
    3844    pmCell *cell = readout->parent; // cell containing this readout;
    39     pmHDU *hdu = pmHDUFromCell (cell);
     45    pmHDU *hdu = pmHDUFromCell(cell);
    4046    return hdu;
    4147}
     
    6470               )
    6571{
     72    PS_ASSERT_PTR_NON_NULL(hdu,);
     73
    6674    if (hdu->phu) {
    6775        psTrace(__func__, level, "HDU: %s (PHU)\n", hdu->extname);
Note: See TracChangeset for help on using the changeset viewer.