@@ -1476,28 +1476,30 @@ gboolean bd_md_set_bitmap_location (const gchar *raid_spec, const gchar *locatio
14761476 * Tech category: %BD_MD_TECH_MDRAID-%BD_MD_TECH_MODE_QUERY
14771477 */
14781478gchar * bd_md_get_bitmap_location (const gchar * raid_spec , GError * * error ) {
1479- gchar * raid_node = NULL ;
1480- gchar * sys_path = NULL ;
1479+ g_autofree gchar * raid_node = NULL ;
1480+ g_autofree gchar * sys_path = NULL ;
14811481 gchar * ret = NULL ;
14821482 gboolean success = FALSE;
1483+ GError * l_error = NULL ;
14831484
14841485 raid_node = get_sysfs_name_from_input (raid_spec , error );
14851486 if (!raid_node )
14861487 /* error is already populated */
14871488 return NULL ;
14881489
14891490 sys_path = g_strdup_printf ("/sys/class/block/%s/md/bitmap/location" , raid_node );
1490- g_free (raid_node );
14911491
1492- success = g_file_get_contents (sys_path , & ret , NULL , error );
1492+ success = g_file_get_contents (sys_path , & ret , NULL , & l_error );
14931493 if (!success ) {
1494- /* error is already populated */
1495- g_free (sys_path );
1496- return NULL ;
1494+ if (g_error_matches (l_error , G_FILE_ERROR , G_FILE_ERROR_NOENT )) {
1495+ g_clear_error (& l_error );
1496+ return g_strdup ("none" );
1497+ } else {
1498+ g_propagate_prefixed_error (error , l_error , "Failed to get bitmap location: " );
1499+ return NULL ;
1500+ }
14971501 }
14981502
1499- g_free (sys_path );
1500-
15011503 return g_strstrip (ret );
15021504}
15031505
0 commit comments