IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9750 for trunk/psLib/src/types


Ignore:
Timestamp:
Oct 25, 2006, 6:44:09 PM (20 years ago)
Author:
drobbin
Message:

Update MetadataConfig tests. Removed unreachable spots from psMetadataConfigParse.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r9736 r9750  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-10-25 00:16:33 $
     12*  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-10-26 04:44:09 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11661166    // Attempt to open specified file
    11671167    int fd = 0;
    1168     if (!(fd = open(filename, O_RDONLY))) {
     1168    fd = open(filename, O_RDONLY);
     1169    struct stat buf;                    // Results of stat() for file
     1170    if (fd < 0 || fstat(fd, &buf) != 0) {
    11691171        // XXX really should return strerror() here
    11701172        psError(PS_ERR_IO, true,
    11711173                _("Failed to open file '%s'. Check if it exists and it has the proper "
    11721174                  "permissions."), filename);
     1175        close(fd);
    11731176        return NULL;
    11741177    }
    1175 
    1176     struct stat buf;                    // Results of stat() for file
     1178    /*  This appears to be unreachable, but moving to check above just to be sure.
    11771179    if (fstat(fd, &buf) != 0) {
    11781180        psError(PS_ERR_IO, true, _("Unable to stat file '%s'.\n"), filename);
     
    11801182        return NULL;
    11811183    }
    1182 
     1184    */
    11831185    // psMetadataConfigParse() is going to read the entire file into memory so
    11841186    // we're trying to be nice by allowing the VM to flush the file out of
     
    11881190    if (file == MAP_FAILED) {
    11891191        psError(PS_ERR_IO, true, _("failed to mmap() file %s"), filename);
    1190         if (close(fd) != 0) {
    1191             // XXX really should return strerror() here
    1192             psError(PS_ERR_IO, true, _("Failed to close file '%s'."), filename);
    1193             return NULL;
    1194         }
     1192        /*        if (close(fd) != 0) {
     1193                    // XXX really should return strerror() here
     1194                    psError(PS_ERR_IO, true, _("Failed to close file '%s'."), filename);
     1195                    return NULL;
     1196                }
     1197        */
     1198        close(fd);
    11951199        return NULL;
    11961200    }
     
    11991203
    12001204    munmap(file, (size_t)buf.st_size);
    1201 
     1205    /*
    12021206    if (close(fd) != 0) {
    12031207        // XXX really should return strerror() here
     
    12051209        return NULL;
    12061210    }
    1207 
     1211    */
     1212    close(fd);
    12081213    return md;
    12091214}
     
    12411246
    12421247    psList *doc = psStringSplit(str, "\n", false);
    1243     if (!doc) {
     1248    if (!doc || doc->n == 0) {
     1249        if (doc != NULL)
     1250            psFree(doc);
    12441251        psFree(parseLevelInfoArray);
    12451252        psFree(md);
Note: See TracChangeset for help on using the changeset viewer.