IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2010, 2:57:57 PM (16 years ago)
Author:
Paul Price
Message:

Being better about errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastroMetadataStats.c

    r26897 r27065  
    4646    }
    4747
     48    psFree(view);
     49
    4850    // if we did not request any specific stats, the structure is empty
    4951    if (stats && stats->list->n == 0) {
    5052        psWarning ("stats output specified, but no requested stats entries in headers");
    51         psFree(view);
    5253        return true;
    5354    }
     
    6263    // convert to a real UNIX filename
    6364    psString resolved = pmConfigConvertFilename(filename, config, true, false); // Resolved filename
     65    if (!resolved) {
     66        psError(psErrorCodeLast(), false, "Unable to resolve statistics filename: %s", filename);
     67        psFree(statsMDC);
     68        return false;
     69    }
    6470    FILE *statsFile = fopen (resolved, "w");
    6571    if (!statsFile) {
    6672        psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);
    67         psFree(view);
    6873        psFree(statsMDC);
    6974        psFree(resolved);
     
    7277
    7378    // write the stats MDC to a file
    74     fprintf(statsFile, "%s", statsMDC);
    75     fclose(statsFile);
     79    if (fprintf(statsFile, "%s", statsMDC) != strlen(statsMDC)) {
     80        psError(PS_ERR_IO, false, "Unable to write statistics file %s", resolved);
     81        psFree(statsMDC);
     82        psFree(resolved);
     83        return false;
     84    }
     85    psFree(statsMDC);
     86    if (fclose(statsFile) == EOF) {
     87        psError(PS_ERR_IO, false, "Unable to write statistics file %s", resolved);
     88        psFree(resolved);
     89        return false;
     90    }
     91
     92    psFree(resolved);
    7693
    7794    pmConfigRunFilenameAddWrite(config, "STATS", filename);
    7895
    79     psFree(resolved);
    80     psFree(statsMDC);
    81     psFree(view);
    8296    return true;
    8397}
Note: See TracChangeset for help on using the changeset viewer.