Changes in / [3090715:9ce7eb5] in mainline
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/measured_strings.c
r3090715 r9ce7eb5 41 41 #include <unistd.h> 42 42 #include <errno.h> 43 #include <err.h> 43 44 #include <async.h> 44 45 … … 134 135 size_t count) 135 136 { 137 ERROR_DECLARE; 138 136 139 size_t *lengths; 137 140 size_t index; … … 139 142 char *next; 140 143 ipc_callid_t callid; 141 int rc;142 144 143 145 if ((!strings) || (!data) || (count <= 0)) … … 153 155 return EINVAL; 154 156 } 155 rc = async_data_write_finalize(callid, lengths, length);156 if (rc != EOK) {157 free(lengths); 158 return rc;157 if (ERROR_OCCURRED(async_data_write_finalize(callid, lengths, 158 length))) { 159 free(lengths); 160 return ERROR_CODE; 159 161 } 160 162 … … 185 187 return EINVAL; 186 188 } 187 rc = async_data_write_finalize(callid, next, 188 lengths[index]); 189 if (rc != EOK) { 189 if (ERROR_OCCURRED(async_data_write_finalize(callid, 190 next, lengths[index]))) { 190 191 free(*data); 191 192 free(*strings); 192 193 free(lengths); 193 return rc;194 return ERROR_CODE; 194 195 } 195 196 (*strings)[index].value = next; … … 250 251 int measured_strings_reply(const measured_string_ref strings, size_t count) 251 252 { 253 ERROR_DECLARE; 254 252 255 size_t *lengths; 253 256 size_t index; 254 257 size_t length; 255 258 ipc_callid_t callid; 256 int rc;257 259 258 260 if ((!strings) || (count <= 0)) … … 268 270 return EINVAL; 269 271 } 270 rc = async_data_read_finalize(callid, lengths, length); 271 if (rc != EOK) { 272 free(lengths); 273 return rc; 272 if (ERROR_OCCURRED(async_data_read_finalize(callid, lengths, length))) { 273 free(lengths); 274 return ERROR_CODE; 274 275 } 275 276 free(lengths); … … 281 282 return EINVAL; 282 283 } 283 rc = async_data_read_finalize(callid, 284 strings[index].value, strings[index].length); 285 if (rc != EOK) 286 return rc; 284 ERROR_PROPAGATE(async_data_read_finalize(callid, 285 strings[index].value, strings[index].length)); 287 286 } 288 287 } … … 314 313 size_t count) 315 314 { 315 ERROR_DECLARE; 316 316 317 size_t *lengths; 317 318 size_t index; 318 319 char *next; 319 int rc;320 320 321 321 if ((phone < 0) || (!strings) || (!data) || (count <= 0)) … … 326 326 return ENOMEM; 327 327 328 rc = async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)); 330 if (rc != EOK) { 331 free(lengths); 332 return rc; 328 if (ERROR_OCCURRED(async_data_read_start(phone, lengths, 329 sizeof(size_t) * (count + 1)))) { 330 free(lengths); 331 return ERROR_CODE; 333 332 } 334 333 … … 351 350 (*strings)[index].length = lengths[index]; 352 351 if (lengths[index] > 0) { 353 rc = async_data_read_start(phone, next, lengths[index]);354 if (rc != EOK) {352 if (ERROR_OCCURRED(async_data_read_start(phone, next, 353 lengths[index]))) { 355 354 free(lengths); 356 355 free(data); 357 356 free(strings); 358 return rc;357 return ERROR_CODE; 359 358 } 360 359 (*strings)[index].value = next; … … 388 387 size_t count) 389 388 { 389 ERROR_DECLARE; 390 390 391 size_t *lengths; 391 392 size_t index; 392 int rc;393 393 394 394 if ((phone < 0) || (!strings) || (count <= 0)) … … 399 399 return ENOMEM; 400 400 401 rc = async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)); 403 if (rc != EOK) { 404 free(lengths); 405 return rc; 401 if (ERROR_OCCURRED(async_data_write_start(phone, lengths, 402 sizeof(size_t) * (count + 1)))) { 403 free(lengths); 404 return ERROR_CODE; 406 405 } 407 406 … … 410 409 for (index = 0; index < count; index++) { 411 410 if (strings[index].length > 0) { 412 rc = async_data_write_start(phone, strings[index].value, 413 strings[index].length); 414 if (rc != EOK) 415 return rc; 411 ERROR_PROPAGATE(async_data_write_start(phone, 412 strings[index].value, strings[index].length)); 416 413 } 417 414 } -
uspace/lib/c/include/adt/generic_char_map.h
r3090715 r9ce7eb5 40 40 #include <unistd.h> 41 41 #include <errno.h> 42 #include <err.h> 42 43 43 44 #include <adt/char_map.h> … … 84 85 type *value) \ 85 86 { \ 86 int rc; \87 ERROR_DECLARE; \ 87 88 int index; \ 88 89 if (!name##_is_valid(map)) \ … … 91 92 if (index < 0) \ 92 93 return index; \ 93 rc = char_map_add(&map->names, name, length, index);\94 if (rc != EOK) { \94 if (ERROR_OCCURRED(char_map_add(&map->names, name, length, \ 95 index))) { \ 95 96 name##_items_exclude_index(&map->values, index); \ 96 return rc; \97 return ERROR_CODE; \ 97 98 } \ 98 99 return EOK; \ … … 140 141 int name##_initialize(name##_ref map) \ 141 142 { \ 142 int rc; \143 ERROR_DECLARE; \ 143 144 if (!map) \ 144 145 return EINVAL; \ 145 rc = char_map_initialize(&map->names); \ 146 if (rc != EOK) \ 147 return rc; \ 148 rc = name##_items_initialize(&map->values); \ 149 if (rc != EOK) { \ 146 ERROR_PROPAGATE(char_map_initialize(&map->names)); \ 147 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \ 150 148 char_map_destroy(&map->names); \ 151 return rc; \149 return ERROR_CODE; \ 152 150 } \ 153 151 map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \ -
uspace/lib/c/include/err.h
r3090715 r9ce7eb5 37 37 38 38 #include <stdio.h> 39 #include <errno.h> 40 41 #ifdef CONFIG_DEBUG 42 #include <str_error.h> 43 #endif 39 44 40 45 #define errx(status, fmt, ...) { \ … … 43 48 } 44 49 50 51 /** An actual stored error code. */ 52 #define ERROR_CODE error_check_return_value 53 54 /** An error processing routines declaration. 55 * 56 * This has to be declared in the block where the error processing 57 * is desired. 58 */ 59 #define ERROR_DECLARE int ERROR_CODE 60 61 /** Store the value as an error code and checks if an error occurred. 62 * 63 * @param[in] value The value to be checked. May be a function call. 64 * @return False if the value indicates success (EOK). 65 * @return True otherwise. 66 */ 67 #ifdef CONFIG_DEBUG 68 69 #define ERROR_OCCURRED(value) \ 70 (((ERROR_CODE = (value)) != EOK) && \ 71 ({ \ 72 fprintf(stderr, "libsocket error at %s:%d (%s)\n", \ 73 __FILE__, __LINE__, str_error(ERROR_CODE)); \ 74 1; \ 75 })) 76 77 #else 78 79 #define ERROR_OCCURRED(value) ((ERROR_CODE = (value)) != EOK) 80 81 #endif 82 83 #define ERROR_NONE(value) !ERROR_OCCURRED((value)) 84 85 /** Error propagation 86 * 87 * Check if an error occurred and immediately exit the actual 88 * function returning the error code. 89 * 90 * @param[in] value The value to be checked. May be a function call. 91 * 92 */ 93 94 #define ERROR_PROPAGATE(value) \ 95 if (ERROR_OCCURRED(value)) \ 96 return ERROR_CODE 97 45 98 #endif 46 99 47 100 /** @} 48 101 */ 49 -
uspace/lib/net/adt/module_map.c
r3090715 r9ce7eb5 38 38 #include <task.h> 39 39 #include <unistd.h> 40 #include <err no.h>40 #include <err.h> 41 41 42 42 #include <ipc/services.h> … … 67 67 connect_module_t connect_module) 68 68 { 69 ERROR_DECLARE; 70 69 71 module_ref tmp_module; 70 int rc;71 72 72 73 tmp_module = (module_ref) malloc(sizeof(module_t)); … … 82 83 tmp_module->connect_module = connect_module; 83 84 84 rc = modules_add(modules, tmp_module->name, 0, tmp_module);85 if (rc != EOK) {85 if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, 86 tmp_module))) { 86 87 free(tmp_module); 87 return rc;88 return ERROR_CODE; 88 89 } 89 90 if (module) -
uspace/lib/net/generic/packet_remote.c
r3090715 r9ce7eb5 38 38 #include <async.h> 39 39 #include <errno.h> 40 #include <err.h> 40 41 #include <ipc/ipc.h> 41 42 #include <ipc/packet.h> … … 66 67 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size) 67 68 { 69 ERROR_DECLARE; 70 68 71 ipc_call_t answer; 69 aid_t message; 70 int rc; 71 72 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 72 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 73 74 74 *packet = (packet_t) as_get_mappable_page(size); 75 rc = async_share_in_start_0_0(phone, *packet, size);76 if (rc != EOK) {75 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) || 76 ERROR_OCCURRED(pm_add(*packet))) { 77 77 munmap(*packet, size); 78 78 async_wait_for(message, NULL); 79 return rc; 80 } 81 rc = pm_add(*packet); 82 if (rc != EOK) { 83 munmap(*packet, size); 84 async_wait_for(message, NULL); 85 return rc; 79 return ERROR_CODE; 86 80 } 87 81 … … 109 103 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 110 104 { 111 int rc;105 ERROR_DECLARE; 112 106 113 107 if (!packet) … … 118 112 ipcarg_t size; 119 113 120 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 if (rc != EOK) 123 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 125 if (rc != EOK) 126 return rc; 114 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, 115 packet_id, &size)); 116 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 127 117 } 128 118 if ((*packet)->next) { … … 151 141 size_t max_prefix, size_t max_suffix) 152 142 { 143 ERROR_DECLARE; 144 153 145 ipcarg_t packet_id; 154 146 ipcarg_t size; 155 int rc; 156 157 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 158 max_prefix, max_suffix, &packet_id, &size); 159 if (rc != EOK) 147 148 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, 149 max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))) 160 150 return NULL; 161 151 … … 163 153 packet_t packet = pm_find(packet_id); 164 154 if (!packet) { 165 rc = packet_return(phone, &packet, packet_id, size);166 if (rc != EOK)155 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, 156 size))) 167 157 return NULL; 168 158 } … … 182 172 packet_t packet_get_1_remote(int phone, size_t content) 183 173 { 174 ERROR_DECLARE; 175 184 176 ipcarg_t packet_id; 185 177 ipcarg_t size; 186 int rc; 187 188 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 189 &size); 190 if (rc != EOK) 178 179 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 180 &packet_id, &size))) 191 181 return NULL; 192 182 193 183 packet_t packet = pm_find(packet_id); 194 184 if (!packet) { 195 rc = packet_return(phone, &packet, packet_id, size);196 if (rc != EOK)185 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, 186 size))) 197 187 return NULL; 198 188 } -
uspace/lib/net/netif/netif_local.c
r3090715 r9ce7eb5 43 43 #include <ipc/services.h> 44 44 #include <ipc/netif.h> 45 #include <err no.h>45 #include <err.h> 46 46 47 47 #include <generic.h> … … 113 113 int netif_start_req_local(int netif_phone, device_id_t device_id) 114 114 { 115 int rc;115 ERROR_DECLARE; 116 116 117 117 fibril_rwlock_write_lock(&netif_globals.lock); 118 118 119 119 netif_device_t *device; 120 rc = find_device(device_id, &device); 121 if (rc != EOK) { 120 if (ERROR_OCCURRED(find_device(device_id, &device))) { 122 121 fibril_rwlock_write_unlock(&netif_globals.lock); 123 return rc;122 return ERROR_CODE; 124 123 } 125 124 … … 149 148 int netif_stop_req_local(int netif_phone, device_id_t device_id) 150 149 { 151 int rc;150 ERROR_DECLARE; 152 151 153 152 fibril_rwlock_write_lock(&netif_globals.lock); 154 153 155 154 netif_device_t *device; 156 rc = find_device(device_id, &device); 157 if (rc != EOK) { 155 if (ERROR_OCCURRED(find_device(device_id, &device))) { 158 156 fibril_rwlock_write_unlock(&netif_globals.lock); 159 return rc;157 return ERROR_CODE; 160 158 } 161 159 … … 205 203 measured_string_ref *address, char **data) 206 204 { 207 int rc;205 ERROR_DECLARE; 208 206 209 207 if (!address || !data) … … 213 211 214 212 measured_string_t translation; 215 rc = netif_get_addr_message(device_id, &translation); 216 if (rc == EOK) { 213 if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) { 217 214 *address = measured_string_copy(&translation); 218 rc= (*address) ? EOK : ENOMEM;215 ERROR_CODE = (*address) ? EOK : ENOMEM; 219 216 } 220 217 … … 223 220 *data = (**address).value; 224 221 225 return rc;222 return ERROR_CODE; 226 223 } 227 224 … … 267 264 int netif_init_module(async_client_conn_t client_connection) 268 265 { 269 int rc;266 ERROR_DECLARE; 270 267 271 268 async_set_client_connection(client_connection); … … 274 271 netif_device_map_initialize(&netif_globals.device_map); 275 272 276 rc = pm_init(); 277 if (rc != EOK) 278 return rc; 273 ERROR_PROPAGATE(pm_init()); 279 274 280 275 fibril_rwlock_initialize(&netif_globals.lock); 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 276 if (ERROR_OCCURRED(netif_initialize())) { 284 277 pm_destroy(); 285 return rc;278 return ERROR_CODE; 286 279 } 287 280 … … 324 317 static int register_message(const char *name, device_id_t device_id, int phone) 325 318 { 319 ERROR_DECLARE; 320 326 321 netif_device_t *device; 327 int rc; 328 329 rc = find_device(device_id, &device); 330 if (rc != EOK) 331 return rc; 332 333 if (device->nil_phone > 0) 322 ERROR_PROPAGATE(find_device(device_id, &device)); 323 if(device->nil_phone > 0) 334 324 return ELIMIT; 335 325 … … 359 349 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 360 350 { 351 ERROR_DECLARE; 352 361 353 size_t length; 362 354 device_stats_t stats; 363 355 packet_t packet; 364 356 measured_string_t address; 365 int rc;366 357 367 358 *answer_count = 0; … … 376 367 case IPC_M_CONNECT_TO_ME: 377 368 fibril_rwlock_write_lock(&netif_globals.lock); 378 rc= register_message(name, IPC_GET_DEVICE(call),369 ERROR_CODE = register_message(name, IPC_GET_DEVICE(call), 379 370 IPC_GET_PHONE(call)); 380 371 fibril_rwlock_write_unlock(&netif_globals.lock); 381 return rc;372 return ERROR_CODE; 382 373 383 374 case NET_NETIF_SEND: 384 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET(call)); 386 if (rc != EOK) 387 return rc; 375 ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone, 376 &packet, IPC_GET_PACKET(call))); 388 377 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 389 378 IPC_GET_SENDER(call)); 390 379 391 380 case NET_NETIF_START: 392 381 return netif_start_req_local(0, IPC_GET_DEVICE(call)); … … 395 384 fibril_rwlock_read_lock(&netif_globals.lock); 396 385 397 rc = async_data_read_receive(&callid, &length); 398 if (rc != EOK) { 386 if (ERROR_OCCURRED(async_data_read_receive(&callid, &length))) { 399 387 fibril_rwlock_read_unlock(&netif_globals.lock); 400 return rc;388 return ERROR_CODE; 401 389 } 402 390 if (length < sizeof(device_stats_t)) { … … 405 393 } 406 394 407 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats);408 if (rc == EOK) {409 rc= async_data_read_finalize(callid, &stats,395 if (ERROR_NONE(netif_get_device_stats(IPC_GET_DEVICE(call), 396 &stats))) { 397 ERROR_CODE = async_data_read_finalize(callid, &stats, 410 398 sizeof(device_stats_t)); 411 399 } 412 400 413 401 fibril_rwlock_read_unlock(&netif_globals.lock); 414 return rc;402 return ERROR_CODE; 415 403 416 404 case NET_NETIF_STOP: … … 419 407 case NET_NETIF_GET_ADDR: 420 408 fibril_rwlock_read_lock(&netif_globals.lock); 421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address);422 if (rc == EOK)423 rc= measured_strings_reply(&address, 1);409 if (ERROR_NONE(netif_get_addr_message(IPC_GET_DEVICE(call), 410 &address))) 411 ERROR_CODE = measured_strings_reply(&address, 1); 424 412 fibril_rwlock_read_unlock(&netif_globals.lock); 425 return rc;413 return ERROR_CODE; 426 414 } 427 415 … … 443 431 int netif_module_start_standalone(async_client_conn_t client_connection) 444 432 { 445 int rc; 446 447 rc = netif_init_module(client_connection); 448 if (rc != EOK) 449 return rc; 433 ERROR_DECLARE; 434 435 ERROR_PROPAGATE(netif_init_module(client_connection)); 450 436 451 437 async_manager(); -
uspace/lib/net/tl/socket_core.c
r3090715 r9ce7eb5 48 48 #include <stdlib.h> 49 49 #include <errno.h> 50 #include <err.h> 50 51 51 52 #include <adt/dynamic_fifo.h> … … 163 164 const char *key, size_t key_length) 164 165 { 166 ERROR_DECLARE; 167 165 168 socket_core_ref *socket_ref; 166 int rc;167 169 168 170 // create a wrapper … … 173 175 *socket_ref = socket; 174 176 // add the wrapper 175 rc = socket_port_map_add(&socket_port->map, key, key_length, 176 socket_ref); 177 if (rc != EOK) { 177 if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key, 178 key_length, socket_ref))) { 178 179 free(socket_ref); 179 return rc;180 return ERROR_CODE; 180 181 } 181 182 … … 203 204 int port) 204 205 { 206 ERROR_DECLARE; 207 205 208 socket_port_ref socket_port; 206 int rc;207 209 208 210 // create a wrapper … … 212 214 213 215 socket_port->count = 0; 214 rc = socket_port_map_initialize(&socket_port->map); 215 if (rc != EOK) 216 goto fail; 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING, 219 0); 220 if (rc != EOK) 221 goto fail; 216 if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) || 217 ERROR_OCCURRED(socket_port_add_core(socket_port, socket, 218 SOCKET_MAP_KEY_LISTENING, 0))) { 219 socket_port_map_destroy(&socket_port->map); 220 free(socket_port); 221 return ERROR_CODE; 222 } 222 223 223 224 // register the incomming port 224 rc = socket_ports_add(global_sockets, port, socket_port); 225 if (rc < 0) 226 goto fail; 225 ERROR_CODE = socket_ports_add(global_sockets, port, socket_port); 226 if (ERROR_CODE < 0) { 227 socket_port_map_destroy(&socket_port->map); 228 free(socket_port); 229 return ERROR_CODE; 230 } 227 231 228 232 socket->port = port; 229 233 return EOK; 230 231 fail:232 socket_port_map_destroy(&socket_port->map);233 free(socket_port);234 return rc;235 236 234 } 237 235 … … 418 416 void *specific_data, int *socket_id) 419 417 { 418 ERROR_DECLARE; 419 420 420 socket_core_ref socket; 421 int res; 421 422 int positive; 422 int rc;423 423 424 424 if (!socket_id) … … 447 447 socket->key_length = 0; 448 448 socket->specific_data = specific_data; 449 rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);450 if (rc != EOK) {449 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received, 450 SOCKET_INITIAL_RECEIVED_SIZE))) { 451 451 free(socket); 452 return rc; 453 } 454 455 rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE); 456 if (rc != EOK) { 452 return ERROR_CODE; 453 } 454 if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted, 455 SOCKET_INITIAL_ACCEPTED_SIZE))) { 457 456 dyn_fifo_destroy(&socket->received); 458 457 free(socket); 459 return rc;458 return ERROR_CODE; 460 459 } 461 460 socket->socket_id = *socket_id; 462 r c= socket_cores_add(local_sockets, socket->socket_id, socket);463 if (r c< 0) {461 res = socket_cores_add(local_sockets, socket->socket_id, socket); 462 if (res < 0) { 464 463 dyn_fifo_destroy(&socket->received); 465 464 dyn_fifo_destroy(&socket->accepted); 466 465 free(socket); 467 return r c;466 return res; 468 467 } 469 468 … … 524 523 int socket_reply_packets(packet_t packet, size_t *length) 525 524 { 525 ERROR_DECLARE; 526 526 527 packet_t next_packet; 527 528 size_t fragments; 528 529 size_t *lengths; 529 530 size_t index; 530 int rc;531 531 532 532 if (!length) … … 536 536 if (!next_packet) { 537 537 // write all if only one fragment 538 rc = data_reply(packet_get_data(packet), 539 packet_get_data_length(packet)); 540 if (rc != EOK) 541 return rc; 538 ERROR_PROPAGATE(data_reply(packet_get_data(packet), 539 packet_get_data_length(packet))); 542 540 // store the total length 543 541 *length = packet_get_data_length(packet); … … 566 564 567 565 // write the fragment lengths 568 rc = data_reply(lengths, sizeof(int) * (fragments + 1));569 if (rc != EOK) {566 if (ERROR_OCCURRED(data_reply(lengths, 567 sizeof(int) * (fragments + 1)))) { 570 568 free(lengths); 571 return rc;569 return ERROR_CODE; 572 570 } 573 571 next_packet = packet; … … 575 573 // write the fragments 576 574 for (index = 0; index < fragments; ++index) { 577 rc= data_reply(packet_get_data(next_packet),575 ERROR_CODE = data_reply(packet_get_data(next_packet), 578 576 lengths[index]); 579 if ( rc != EOK) {577 if (ERROR_OCCURRED(ERROR_CODE)) { 580 578 free(lengths); 581 return rc;579 return ERROR_CODE; 582 580 } 583 581 next_packet = pq_next(next_packet); … … 682 680 socket_core_ref socket, const char *key, size_t key_length) 683 681 { 682 ERROR_DECLARE; 683 684 684 socket_port_ref socket_port; 685 int rc;686 685 687 686 // find ports … … 691 690 692 691 // add the socket 693 rc = socket_port_add_core(socket_port, socket, key, key_length); 694 if (rc != EOK) 695 return rc; 692 ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key, 693 key_length)); 696 694 697 695 socket->port = port; -
uspace/lib/net/tl/tl_common.c
r3090715 r9ce7eb5 54 54 #include <ipc/services.h> 55 55 #include <errno.h> 56 #include <err.h> 56 57 57 58 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); … … 123 124 packet_dimension_ref *packet_dimension) 124 125 { 125 int rc;126 ERROR_DECLARE; 126 127 127 128 if (!packet_dimension) … … 136 137 return ENOMEM; 137 138 138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);139 if (rc != EOK) {139 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, 140 *packet_dimension))) { 140 141 free(*packet_dimension); 141 return rc;142 return ERROR_CODE; 142 143 } 143 144 144 rc= packet_dimensions_add(packet_dimensions, device_id,145 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, 145 146 *packet_dimension); 146 if ( rc< 0) {147 if (ERROR_CODE < 0) { 147 148 free(*packet_dimension); 148 return rc;149 return ERROR_CODE; 149 150 } 150 151 } … … 291 292 socklen_t addrlen) 292 293 { 294 ERROR_DECLARE; 295 293 296 ipc_callid_t callid; 294 297 size_t length; 295 void *data; 296 int rc; 298 void * data; 297 299 298 300 if (!dimension) … … 317 319 318 320 // read the data into the packet 319 rc = async_data_write_finalize(callid, data, length); 320 if (rc != EOK) { 321 if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) || 322 // set the packet destination address 323 ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, 324 addrlen))) { 321 325 pq_release_remote(packet_phone, packet_get_id(*packet)); 322 return rc; 323 } 324 325 // set the packet destination address 326 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 if (rc != EOK) { 328 pq_release_remote(packet_phone, packet_get_id(*packet)); 329 return rc; 326 return ERROR_CODE; 330 327 } 331 328 -
uspace/lib/packet/generic/packet_server.c
r3090715 r9ce7eb5 42 42 #include <async.h> 43 43 #include <errno.h> 44 #include <err.h> 44 45 #include <fibril_synch.h> 45 46 #include <unistd.h> … … 161 162 size_t max_content, size_t max_suffix) 162 163 { 164 ERROR_DECLARE; 165 163 166 packet_t packet; 164 int rc;165 167 166 168 // already locked … … 175 177 packet_init(packet, addr_len, max_prefix, max_content, max_suffix); 176 178 packet->magic_value = PACKET_MAGIC_VALUE; 177 rc = pm_add(packet); 178 if (rc != EOK) { 179 if (ERROR_OCCURRED(pm_add(packet))) { 179 180 munmap(packet, packet->length); 180 181 return NULL; -
uspace/srv/hw/netif/dp8390/dp8390_module.c
r3090715 r9ce7eb5 158 158 159 159 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats){ 160 ERROR_DECLARE; 161 160 162 netif_device_t * device; 161 163 eth_stat_t * de_stat; 162 int rc;163 164 164 165 if(! stats){ 165 166 return EBADMEM; 166 167 } 167 rc = find_device(device_id, &device); 168 if (rc != EOK) 169 return rc; 168 ERROR_PROPAGATE(find_device(device_id, &device)); 170 169 de_stat = &((dpeth_t *) device->specific)->de_stat; 171 170 null_device_stats(stats); … … 186 185 187 186 int netif_get_addr_message(device_id_t device_id, measured_string_ref address){ 188 netif_device_t * device; 189 int rc; 187 ERROR_DECLARE; 188 189 netif_device_t * device; 190 190 191 191 if(! address){ 192 192 return EBADMEM; 193 193 } 194 rc = find_device(device_id, &device); 195 if (rc != EOK) 196 return rc; 194 ERROR_PROPAGATE(find_device(device_id, &device)); 197 195 address->value = (char *) (&((dpeth_t *) device->specific)->de_address); 198 196 address->length = CONVERT_SIZE(ether_addr_t, char, 1); … … 203 201 204 202 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io){ 205 netif_device_t * device; 206 dpeth_t * dep; 207 int rc; 203 ERROR_DECLARE; 204 205 netif_device_t * device; 206 dpeth_t * dep; 208 207 209 208 device = (netif_device_t *) malloc(sizeof(netif_device_t)); … … 225 224 dep->de_mode = DEM_DISABLED; 226 225 //TODO address? 227 rc = pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port);228 if (rc != EOK){226 if(ERROR_OCCURRED(pio_enable((void *) io, DP8390_IO_SIZE, (void **) &dep->de_base_port)) 227 || ERROR_OCCURRED(do_probe(dep))){ 229 228 free(dep); 230 229 free(device); 231 return rc; 232 } 233 rc = do_probe(dep); 234 if (rc != EOK) { 230 return ERROR_CODE; 231 } 232 if(ERROR_OCCURRED(netif_device_map_add(&netif_globals.device_map, device->device_id, device))){ 235 233 free(dep); 236 234 free(device); 237 return rc; 238 } 239 rc = netif_device_map_add(&netif_globals.device_map, device->device_id, device); 240 if (rc != EOK){ 241 free(dep); 242 free(device); 243 return rc; 235 return ERROR_CODE; 244 236 } 245 237 return EOK; … … 247 239 248 240 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender){ 241 ERROR_DECLARE; 242 249 243 netif_device_t * device; 250 244 dpeth_t * dep; 251 245 packet_t next; 252 int rc; 253 254 rc = find_device(device_id, &device); 255 if (rc != EOK) 256 return rc; 246 247 ERROR_PROPAGATE(find_device(device_id, &device)); 257 248 if(device->state != NETIF_ACTIVE){ 258 249 netif_pq_release(packet_get_id(packet)); … … 272 263 273 264 int netif_start_message(netif_device_t * device){ 274 dpeth_t * dep; 275 int rc; 265 ERROR_DECLARE; 266 267 dpeth_t * dep; 276 268 277 269 if(device->state != NETIF_ACTIVE){ … … 279 271 dp8390_cmds[0].addr = (void *) (uintptr_t) (dep->de_dp8390_port + DP_ISR); 280 272 dp8390_cmds[2].addr = dp8390_cmds[0].addr; 281 rc = ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code); 282 if (rc != EOK) 283 return rc; 284 rc = do_init(dep, DL_BROAD_REQ); 285 if (rc != EOK) { 273 ERROR_PROPAGATE(ipc_register_irq(dep->de_irq, device->device_id, device->device_id, &dp8390_code)); 274 if(ERROR_OCCURRED(do_init(dep, DL_BROAD_REQ))){ 286 275 ipc_unregister_irq(dep->de_irq, device->device_id); 287 return rc;276 return ERROR_CODE; 288 277 } 289 278 return change_state(device, NETIF_ACTIVE); … … 361 350 int main(int argc, char *argv[]) 362 351 { 363 int rc;352 ERROR_DECLARE; 364 353 365 354 /* Start the module */ 366 rc = netif_module_start(netif_client_connection); 367 return rc; 355 if (ERROR_OCCURRED(netif_module_start(netif_client_connection))) 356 return ERROR_CODE; 357 358 return EOK; 368 359 } 369 360
Note:
See TracChangeset
for help on using the changeset viewer.