Menu

#8 error: ignoring return value of ‘size_t fread(void*, size_t,

closed-fixed
Mark
Linux (2)
5
2011-11-30
2011-08-10
Floris
No

TWAIN DS fails to compile on Ubuntu Natty.

==
max@lynx:~/dev/TWAIN_DSM$ make
[ 33%] Building CXX object CMakeFiles/twaindsm.dir/dsm.o
cc1plus: warnings being treated as errors
/home/max/dev/TWAIN_DSM/src/dsm.cpp: In member function ‘TW_INT16 CTwnDsm::GetMatchingDefault(TW_IDENTITY*, TW_IDENTITY*)’:
/home/max/dev/TWAIN_DSM/src/dsm.cpp:2151:73: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
make[2]: *** [CMakeFiles/twaindsm.dir/dsm.o] Error 1
make[1]: *** [CMakeFiles/twaindsm.dir/all] Error 2
make: *** [all] Error 2
==

Need to check if fread() succeeds.
e.g. change it to:

==
if ( fread(pod.m_DefaultDSPath,1,sizeof(pod.m_DefaultDSPath)-1,pfile) > 0 )
{
bDefaultFound = true;
}
==

Discussion

  • Mark

    Mark - 2011-11-30
    • status: open --> closed-fixed
     
  • Mark

    Mark - 2011-11-30

    The fread and fwrite commands are used with the defaultds file. They've all been fixed to test the result of the call, though the only action is to log a message.

     
  • Mark

    Mark - 2011-11-30
    • assigned_to: nobody --> mlmcl