[gparted] Fix ignoring return value compiler warnings
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Fix ignoring return value compiler warnings
- Date: Mon, 18 Jul 2011 19:35:08 +0000 (UTC)
commit f768cbd1b4e186acab1ba9c434de0cac8392a69b
Author: Curtis Gedak <gedakc gmail com>
Date: Sat Jul 16 10:09:04 2011 -0600
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
src/DMRaid.cc | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/DMRaid.cc b/src/DMRaid.cc
index da82530..9b51af8 100644
--- a/src/DMRaid.cc
+++ b/src/DMRaid.cc
@@ -128,12 +128,14 @@ 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 ) ;
- Glib::ustring tmp_path = c_str ;
- if ( tmp_path .length() > 0 )
- for ( unsigned int k=0; k < dmraid_devices .size(); k++ )
- if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos )
- device_found = true ;
+ 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++ )
+ if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos )
+ device_found = true ;
+ }
}
}
@@ -196,12 +198,14 @@ 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 ) ;
- Glib::ustring tmp_path = c_str ;
- if ( tmp_path .length() > 0 )
- for ( unsigned int k=0; k < dmraid_devices .size(); k++ )
- if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos )
- dmraid_name = dmraid_devices[k] ;
+ 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++ )
+ if ( tmp_path .find( dmraid_devices[k] ) != Glib::ustring::npos )
+ dmraid_name = dmraid_devices[k] ;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]