use of assert() macro to check file problems

Hello,

There are several places in the netCDF library where the assert()
macro is the only check on file problems.  For example, in 
v1h_get_nc_type(), assert checks for a valid netCDF var type.  The
problem is, if an nc file gets corrupted (for example, truncated during
a copy etc.) this is the only way to catch the error.  If assert() 
catches the error, the program aborts.  

I have a distributed server application that allows remote access to netCDF
files through a CORBA interface.  If the server is linked with a version 
of the netCDF lib that includes assert(), then the server will crash 
(abort) as soon as a corrupted file is opened.  This, of course, is 
unacceptable for a server process.  On the other hand, if I link with a
NDEBUG version of the lib, the file errors are ignored and garbage is 
returned.  It would be much better if these assert()'s were replaced with
code to return an error value.  My understanding is that assert() should
only be used to catch programmer errors, not as an error handling for
external input (netCDF flies).

Thanks,

Mike McCarrick
--

Dr. Michael McCarrick                           (202) 223-8808 voice
Advanced Power Technologies, Inc., Wash DC      (202) 223-1377 fax


  • 1998 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: