Changeset 1c674dd664a39c9369914763d636244ba1cfe966

Show
Ignore:
Timestamp:
04/03/10 11:41:26 (3 years ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
866d24baaf48377077b4d8bac26343c7e5e201fc
Parents:
d4bc1d70728baa026221a9c90fe17c2ed25df1fc
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-04-03T11:41:26Z+0300
Message:

daemon: fix&improve error handling in ladish_room_create()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • daemon/room.c

    r7c81ae3 r1c674dd  
    5656  { 
    5757    log_error("malloc() failed to allocate struct ladish_room"); 
    58     return false; 
     58    goto fail; 
    5959  } 
    6060 
     
    8888  { 
    8989    log_error("strdup() failed for room name"); 
    90     free(room_ptr); 
    91     return false; 
     90    goto free_room; 
    9291  } 
    9392 
    9493  if (!ladish_graph_create(&room_ptr->graph, object_path)) 
    9594  { 
    96     free(room_ptr); 
    97     return false; 
     95    goto free_name; 
    9896  } 
    9997 
     
    102100    if (!ladish_graph_copy(ladish_room_get_graph(template), room_ptr->graph)) 
    103101    { 
    104       ladish_graph_destroy(room_ptr->graph, true); 
    105       free(room_ptr); 
    106       return false; 
     102      goto destroy_graph; 
    107103    } 
    108104  } 
     
    120116    { 
    121117      log_error("dbus_object_path_new() failed"); 
    122       ladish_graph_destroy(room_ptr->graph, true); 
    123       free(room_ptr); 
    124       return false; 
     118      goto destroy_graph; 
    125119    } 
    126120 
     
    128122    { 
    129123      log_error("object_path_register() failed"); 
    130       dbus_object_path_destroy(g_dbus_connection, room_ptr->dbus_object); 
    131       ladish_graph_destroy(room_ptr->graph, true); 
    132       free(room_ptr); 
    133       return false; 
     124      goto destroy_dbus_object; 
    134125    } 
    135126 
     
    143134  *room_handle_ptr = (ladish_room_handle)room_ptr; 
    144135  return true; 
     136 
     137destroy_dbus_object: 
     138  dbus_object_path_destroy(g_dbus_connection, room_ptr->dbus_object); 
     139destroy_graph: 
     140  ladish_graph_destroy(room_ptr->graph, true); 
     141free_name: 
     142  free(room_ptr->name); 
     143free_room: 
     144  free(room_ptr); 
     145fail: 
     146  return false; 
    145147} 
    146148