Fix ignoring return value compiler warnings
Add code to handle situation where realpath might return a NULL value. Prior to this change the compiler would complain with the following message: error: ignoring return value of ‘char* realpath(const char*, char*)’, declared with attribute warn_unused_result
This commit is contained in:
parent
6c9d0cf6f1
commit
f768cbd1b4
|
@ -128,7 +128,8 @@ bool DMRaid::is_dmraid_device( const Glib::ustring & dev_path )
|
|||
//Path is a symbolic link so find real path
|
||||
char c_str[4096+1] ;
|
||||
//FIXME: it seems realpath is very unsafe to use (manpage)...
|
||||
realpath( dev_path .c_str(), c_str ) ;
|
||||
if ( realpath( dev_path .c_str(), c_str ) != NULL )
|
||||
{
|
||||
Glib::ustring tmp_path = c_str ;
|
||||
if ( tmp_path .length() > 0 )
|
||||
for ( unsigned int k=0; k < dmraid_devices .size(); k++ )
|
||||
|
@ -136,6 +137,7 @@ bool DMRaid::is_dmraid_device( const Glib::ustring & dev_path )
|
|||
device_found = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return device_found ;
|
||||
}
|
||||
|
@ -196,7 +198,8 @@ Glib::ustring DMRaid::get_dmraid_name( const Glib::ustring & dev_path )
|
|||
//Path is a symbolic link so find real path
|
||||
char c_str[4096+1] ;
|
||||
//FIXME: it seems realpath is very unsafe to use (manpage)...
|
||||
realpath( dev_path .c_str(), c_str ) ;
|
||||
if( realpath( dev_path .c_str(), c_str ) != NULL )
|
||||
{
|
||||
Glib::ustring tmp_path = c_str ;
|
||||
if ( tmp_path .length() > 0 )
|
||||
for ( unsigned int k=0; k < dmraid_devices .size(); k++ )
|
||||
|
@ -204,6 +207,7 @@ Glib::ustring DMRaid::get_dmraid_name( const Glib::ustring & dev_path )
|
|||
dmraid_name = dmraid_devices[k] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dmraid_name ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue