Changeset 3066 for trunk/external-alma


Ignore:
Timestamp:
11/25/15 12:55:08 (9 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Make NRO reader classes warning free.

Location:
trunk/external-alma/atnf/PKSIO
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/NRODataset.h

    r2783 r3066  
    112112  const std::string getLOSTM() const { return LOSTM ; } ;
    113113  const std::string getLOETM() const { return LOETM ; } ;
    114   const int getARYNM() const { return ARYNM ; } ;
    115   const int getNSCAN() const { return NSCAN ; } ;
     114  int getARYNM() const { return ARYNM ; } ;
     115  int getNSCAN() const { return NSCAN ; } ;
    116116  const std::string getTITLE() const { return TITLE ; } ;
    117117  const std::string getOBJ() const { return OBJ ; } ;
    118118  const std::string getEPOCH() const { return EPOCH ; } ;
    119   const double getRA0() const { return RA0 ; } ;
    120   const double getDEC0() const { return DEC0 ; } ;
    121   const double getGLNG0() const { return GLNG0 ; } ;
    122   const double getGLAT0() const { return GLAT0 ; } ;
    123   const int getNCALB() const { return NCALB ; } ;
    124   const int getSCNCD() const { return SCNCD ; } ;
     119  double getRA0() const { return RA0 ; } ;
     120  double getDEC0() const { return DEC0 ; } ;
     121  double getGLNG0() const { return GLNG0 ; } ;
     122  double getGLAT0() const { return GLAT0 ; } ;
     123  int getNCALB() const { return NCALB ; } ;
     124  int getSCNCD() const { return SCNCD ; } ;
    125125  const std::string getSCMOD() const { return SCMOD ; } ;
    126   const double getURVEL() const { return URVEL ; } ;
     126  double getURVEL() const { return URVEL ; } ;
    127127  const std::string getVREF() const { return VREF ; } ;
    128128  const std::string getVDEF() const { return VDEF ; } ;
    129129  const std::string getSWMOD() const { return SWMOD ; } ;
    130   const double getFRQSW() const { return FRQSW ; } ;   
    131   const double getDBEAM() const { return DBEAM ; } ;   
    132   const double getMLTOF() const { return MLTOF ; } ;   
    133   const double getCMTQ() const { return CMTQ ; } ;     
    134   const double getCMTE() const { return CMTE ; } ;
    135   const double getCMTSOM() const { return CMTSOM ; } ;
    136   const double getCMTNODE() const { return CMTNODE ; } ;
    137   const double getCMTI() const { return CMTI ; } ;
     130  double getFRQSW() const { return FRQSW ; } ;
     131  double getDBEAM() const { return DBEAM ; } ;
     132  double getMLTOF() const { return MLTOF ; } ;
     133  double getCMTQ() const { return CMTQ ; } ;
     134  double getCMTE() const { return CMTE ; } ;
     135  double getCMTSOM() const { return CMTSOM ; } ;
     136  double getCMTNODE() const { return CMTNODE ; } ;
     137  double getCMTI() const { return CMTI ; } ;
    138138  const std::string getCMTTM() const { return CMTTM ; } ;
    139   const double getSBDX() const { return SBDX ; } ;
    140   const double getSBDY() const { return SBDY ; } ;
    141   const double getSBDZ1() const { return SBDZ1 ; } ;
    142   const double getSBDZ2() const { return SBDZ2 ; } ;
    143   const double getDAZP() const { return DAZP ; } ;
    144   const double getDELP() const { return DELP ; } ;
    145   const int getCHBIND() const { return CHBIND ; } ;
    146   const int getNUMCH() const { return NUMCH ; } ;
    147   const int getCHMIN() const { return CHMIN ; } ;
    148   const int getCHMAX() const { return CHMAX ; } ;
    149   const double getALCTM() const { return ALCTM ; } ;
    150   const double getIPTIM() const { return IPTIM ; } ;
    151   const double getPA() const { return PA ; } ;
    152   const int getSCNLEN() const { return SCNLEN ; } ;
    153   const int getSBIND() const { return SBIND ; } ;
    154   const int getIBIT() const { return IBIT ; } ;
     139  double getSBDX() const { return SBDX ; } ;
     140  double getSBDY() const { return SBDY ; } ;
     141  double getSBDZ1() const { return SBDZ1 ; } ;
     142  double getSBDZ2() const { return SBDZ2 ; } ;
     143  double getDAZP() const { return DAZP ; } ;
     144  double getDELP() const { return DELP ; } ;
     145  int getCHBIND() const { return CHBIND ; } ;
     146  int getNUMCH() const { return NUMCH ; } ;
     147  int getCHMIN() const { return CHMIN ; } ;
     148  int getCHMAX() const { return CHMAX ; } ;
     149  double getALCTM() const { return ALCTM ; } ;
     150  double getIPTIM() const { return IPTIM ; } ;
     151  double getPA() const { return PA ; } ;
     152  int getSCNLEN() const { return SCNLEN ; } ;
     153  int getSBIND() const { return SBIND ; } ;
     154  int getIBIT() const { return IBIT ; } ;
    155155  const std::string getSITE() const { return SITE ; } ;
    156156  const std::vector<std::string> getRX() const { return RX ; } ;
     
    183183  const std::string getCDMY1() const { return CDMY1 ; } ;
    184184  const std::vector<double> getDSBFC() const { return DSBFC ;} ;
    185   const int getDataSize() const { return datasize_ ; } ;
    186   const int getRowNum() const { return rowNum_ ; } ;
     185  int getDataSize() const { return datasize_ ; } ;
     186  int getRowNum() const { return rowNum_ ; } ;
    187187
    188188  // get various parameters
  • trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc

    r2940 r3066  
    16841684    char ctmp[5] ;
    16851685    std::size_t retval = fread( ctmp, 1, 4, fp_ ) ;
     1686    if (retval < 4) {
     1687      os << LogIO::SEVERE << "Failed to read array configuration." << LogIO::EXCEPTION;
     1688    }
    16861689    ctmp[4] = '\0' ;
    16871690    //cout << "ctmp = " << ctmp << endl ;
     
    17681771  while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) {
    17691772    std::size_t retval = fread( buf, 1, 80, fp_ ) ;
     1773    if (retval < 80) {
     1774      LogIO os(LogOrigin("NROFITSDataset", "readHeader(string)", WHERE));
     1775      os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION;
     1776    }
    17701777    buf[80] = '\0' ;
    17711778    count++ ;
     
    18021809  while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) {
    18031810    std::size_t retval = fread( buf, 1, 80, fp_ ) ;
     1811    if (retval < 80) {
     1812      LogIO os(LogOrigin("NROFITSDataset", "readHeader(int)", WHERE));
     1813      os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION;
     1814    }
    18041815    buf[80] = '\0' ;
    18051816    //char bufo[9] ;
     
    18381849  while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) {
    18391850    std::size_t retval = fread( buf, 1, 80, fp_ ) ;
     1851    if (retval < 80) {
     1852      LogIO os(LogOrigin("NROFITSDataset", "readHeader(float)", WHERE));
     1853      os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION;
     1854    }
    18401855    buf[80] = '\0' ;
    18411856    //char bufo[9] ;
     
    18721887  while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) {
    18731888    std::size_t retval = fread( buf, 1, 80, fp_ ) ;
     1889    if (retval < 80) {
     1890      LogIO os(LogOrigin("NROFITSDataset", "readHeader(double)", WHERE));
     1891      os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION;
     1892    }
    18741893    buf[80] = '\0' ;
    18751894    char bufo[9] ;
     
    18951914}
    18961915
    1897 int NROFITSDataset::readTable( char *v, const char *name, int clen, int idx )
     1916int NROFITSDataset::readTable( char *v, const char *name, size_t clen, int idx )
    18981917{
    18991918  //
     
    19091928    return -1;
    19101929
    1911   int xsize = iter->second.size;
     1930  size_t xsize = iter->second.size;
    19121931
    19131932  // read data
    19141933  if ( xsize < clen ) {
    19151934    std::size_t retval = fread( v, 1, xsize, fp_ ) ;
     1935    if (retval < xsize) {
     1936      LogIO os(LogOrigin("NROFITSDataset", "readTable(char *)", WHERE));
     1937      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     1938    }
    19161939    //v[xsize] = '\0' ;
    19171940  }
     1941  else if (clen > 0) {
     1942    std::size_t retval = fread( v, 1, clen - 1, fp_ ) ;
     1943    if (retval < clen - 1) {
     1944      LogIO os(LogOrigin("NROFITSDataset", "readTable(char *)", WHERE));
     1945      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     1946    }
     1947    //v[clen-1] = '\0' ;
     1948  }
    19181949  else {
    1919     std::size_t retval = fread( v, 1, clen-1, fp_ ) ;
    1920     //v[clen-1] = '\0' ;
     1950    status = -1;
    19211951  }
    19221952
     
    19361966  // read data
    19371967  std::size_t retval = fread( &v, sizeof(int), 1, fp_ ) ;
     1968  if (retval < 1) {
     1969    LogIO os(LogOrigin("NROFITSDataset", "readTable(int)", WHERE));
     1970    os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     1971  }
    19381972  if ( b == 0 )
    19391973    convertEndian( v ) ;
     
    19541988  // read data
    19551989  std::size_t retval = fread( &v, sizeof(float), 1, fp_ ) ;
     1990  if (retval < 1) {
     1991    LogIO os(LogOrigin("NROFITSDataset", "readTable(float)", WHERE));
     1992    os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     1993  }
    19561994  if ( b == 0 )
    19571995    convertEndian( v ) ;
     
    19722010  // read data
    19732011  std::size_t retval = fread( &v, sizeof(double), 1, fp_ ) ;
     2012  if (retval < 1) {
     2013    LogIO os(LogOrigin("NROFITSDataset", "readTable(double)", WHERE));
     2014    os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2015  }
    19742016  if ( b == 0 )
    19752017    convertEndian( v ) ; 
     
    19912033    return -1;
    19922034
    1993   int xsize = iter->second.size;
     2035  size_t xsize = iter->second.size;
    19942036
    19952037  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    1996     int clen = strlen( v[i] ) ;
     2038    size_t clen = strlen( v[i] ) ;
    19972039    if ( clen > xsize ) {
    19982040      std::size_t retval = fread( v[i], 1, xsize, fp_ ) ;
     2041      if (retval < xsize) {
     2042        LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<char *>)", WHERE));
     2043        os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2044      }
    19992045      //v[i][xsize] = '\0' ;
    20002046    }
    20012047    else {
    20022048      std::size_t retval = fread( v[i], 1, clen, fp_ ) ;
     2049      if (retval < clen) {
     2050        LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<char *>)", WHERE));
     2051        os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2052      }
    20032053      //v[i][clen-1] = '\0' ;
    20042054    }
     
    20192069
    20202070  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2021     std::size_t retval = fread( &v[i], 1, sizeof(int), fp_ ) ;
     2071    std::size_t retval = fread( &v[i], sizeof(int), 1, fp_ ) ;
     2072    if (retval < 1) {
     2073      LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<int>)", WHERE));
     2074      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2075    }
    20222076    if ( b == 0 )
    20232077      convertEndian( v[i] ) ;
     
    20382092
    20392093  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2040     std::size_t retval = fread( &v[i], 1, sizeof(float), fp_ ) ;
     2094    std::size_t retval = fread( &v[i], sizeof(float), 1, fp_ ) ;
     2095    if (retval < 1) {
     2096      LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<float>)", WHERE));
     2097      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2098    }
    20412099    if ( b == 0 )
    20422100      convertEndian( v[i] ) ;
     
    20572115
    20582116  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2059     std::size_t retval = fread( &v[i], 1, sizeof(double), fp_ ) ;
     2117    std::size_t retval = fread( &v[i], sizeof(double), 1, fp_ ) ;
     2118    if (retval < 1) {
     2119      LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<double>)", WHERE));
     2120      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2121    }
    20602122    if ( b == 0 )
    20612123      convertEndian( v[i] ) ;
     
    20802142    return -1;
    20812143
    2082   int xsize = iter->second.size;
     2144  size_t xsize = iter->second.size;
    20832145
    20842146  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    20962158    char c[xsize+1] ;
    20972159    std::size_t retval = fread( c, 1, xsize, fp_ ) ;
     2160    if (retval < xsize) {
     2161      LogIO os(LogOrigin("NROFITSDataset", "readColumn(string)", WHERE));
     2162      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2163    }
    20982164    c[xsize] = '\0' ;
    20992165    v[i] = string( c ) ;
     
    21182184    int offset = scanLen_ * arrayid_[i] + sizeof(int) * idx ;
    21192185    fseek( fp_, offset, SEEK_CUR ) ;
    2120     std::size_t retval = fread( &v[i], 1, sizeof(int), fp_ ) ;
     2186    std::size_t retval = fread( &v[i], sizeof(int), 1, fp_ ) ;
     2187    if (retval < 1) {
     2188      LogIO os(LogOrigin("NROFITSDataset", "readColumn(int)", WHERE));
     2189      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2190    }
    21212191    if ( b == 0 )
    21222192      convertEndian( v[i] ) ;
     
    21422212    fseek( fp_, offset, SEEK_CUR ) ;
    21432213    std::size_t retval = fread( &v[i], 1, sizeof(float), fp_ ) ;
     2214    if (retval < 1) {
     2215      LogIO os(LogOrigin("NROFITSDataset", "readColumn(float)", WHERE));
     2216      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2217    }
    21442218    if ( b == 0 )
    21452219      convertEndian( v[i] ) ;
     
    21652239    fseek( fp_, offset, SEEK_CUR ) ;
    21662240    std::size_t retval = fread( &v[i], 1, sizeof(double), fp_ ) ;
     2241    if (retval < 1) {
     2242      LogIO os(LogOrigin("NROFITSDataset", "readColumn(double)", WHERE));
     2243      os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION;
     2244    }
    21672245    if ( b == 0 )
    21682246      convertEndian( v[i] ) ;
  • trunk/external-alma/atnf/PKSIO/NROFITSDataset.h

    r2812 r3066  
    101101  struct FieldProperty {
    102102    //string name;    // field name
    103     int size;         // data size [byte]
     103    size_t size;      // data size [byte]
    104104    //string unit;    // unit of the field
    105     long offset;      // offset from the head of scan record [byte]
     105    size_t offset;    // offset from the head of scan record [byte]
    106106  };
    107107
     
    111111  // Read char data
    112112  int readHeader( string &v, const char *name ) ;
    113   int readTable( char *v, const char *name, int clen, int idx=0 ) ;
     113  int readTable( char *v, const char *name, size_t clen, int idx=0 ) ;
    114114  int readTable( vector<char *> &v, const char *name, int idx=0 ) ;
    115115  int readColumn( vector<string> &v, const char *name, int idx=0 ) ;
  • trunk/external-alma/atnf/PKSIO/NROReader.cc

    r2940 r3066  
    8181  // Determine the type of input.
    8282  NROReader *reader = 0;
    83   std::size_t retval;
    8483  if ( inFile.isRegular() ) {
    8584    FILE *file ;
     
    8786    // read LOFIL0
    8887    char buf[9];
    89     retval = fread( buf, 4, 1, file ) ;
     88    size_t retval = fread( buf, 4, 1, file ) ;
     89    if (retval < 1) {
     90      os << LogIO::SEVERE << "Failed to read data" << LogIO::POST;
     91      fclose(file);
     92      return 0;
     93    }
    9094    buf[4] = '\0' ;
    9195    // DEBUG
     
    108112      delete d ;
    109113      fseek( file, size, SEEK_SET ) ;
    110       retval = fread( buf, 8, 1, file ) ;
     114      size_t retval = fread( buf, 8, 1, file ) ;
     115      if (retval < 1) {
     116        os << LogIO::SEVERE << "Failed to read data" << LogIO::POST;
     117        fclose(file);
     118        return 0;
     119      }
    111120      buf[8] = '\0' ;
    112121      // DEBUG
     
    124133        delete d ;
    125134        fseek( file, size, SEEK_SET ) ;
    126         retval = fread( buf, 8, 1, file ) ;
     135        size_t retval = fread( buf, 8, 1, file ) ;
     136        if (retval < 1) {
     137          os << LogIO::SEVERE << "Failed to read data" << LogIO::POST;
     138          fclose(file);
     139          return 0;
     140        }
    127141        buf[8] = '\0' ;
    128142        // DEBUG
Note: See TracChangeset for help on using the changeset viewer.