Changeset 5145:c1a3ca765154 in roaraudio for libroar
- Timestamp:
- 10/11/11 13:47:59 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libroar
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/beep.c
r4708 r5145 40 40 int16_t * data = (int16_t*)m.data; 41 41 42 if ( con == NULL ) 42 if ( con == NULL ) { 43 roar_err_set(ROAR_ERROR_FAULT); 43 44 return -1; 45 } 44 46 45 47 memset(&m, 0, sizeof(m)); -
libroar/client.c
r4948 r5145 39 39 int i; 40 40 41 if ( client == NULL ) 41 if ( client == NULL ) { 42 roar_err_set(ROAR_ERROR_FAULT); 42 43 return -1; 44 } 43 45 44 46 memset(client, 0, sizeof(struct roar_client)); … … 58 60 59 61 int roar_client_set_fh (struct roar_client * client, int fh) { 60 if ( client == NULL ) 62 if ( client == NULL ) { 63 roar_err_set(ROAR_ERROR_FAULT); 61 64 return -1; 65 } 62 66 63 67 client->fh = fh; … … 67 71 68 72 int roar_client_set_proto(struct roar_client * client, int proto, int byteorder) { 69 if ( client == NULL ) 73 if ( client == NULL ) { 74 roar_err_set(ROAR_ERROR_FAULT); 70 75 return -1; 76 } 71 77 72 78 client->proto = proto; … … 80 86 break; 81 87 default: 88 roar_err_set(ROAR_ERROR_INVAL); 82 89 return -1; 83 90 break; … … 93 100 int confh; 94 101 int i; 102 103 if ( con == NULL || client == NULL ) { 104 roar_err_set(ROAR_ERROR_FAULT); 105 return -1; 106 } 95 107 96 108 memset(&m, 0, sizeof(m)); … … 133 145 int i; 134 146 147 if ( con == NULL || client == NULL ) { 148 roar_err_set(ROAR_ERROR_FAULT); 149 return -1; 150 } 151 135 152 memset(&m, 0, sizeof(m)); 136 153 -
libroar/ctl.c
r5144 r5145 311 311 m->data[1] = filter; 312 312 m->data[2] = cmp; 313 *((uint32_t*)&(m->data[3])) = ROAR_HOST2NET32(id); 313 m->data[3] = (id & 0xFF000000LU) >> 24; 314 m->data[4] = (id & 0x00FF0000LU) >> 16; 315 m->data[5] = (id & 0x0000FF00LU) >> 8; 316 m->data[6] = (id & 0x000000FFLU) >> 0; 314 317 315 318 return 0; 316 319 } 317 320 int roar_ctl_m2f (struct roar_message * m, unsigned char * filter, unsigned char * cmp, uint32_t * id) { 321 register uint32_t idreg; 318 322 319 323 if ( m->datalen != 7 ) … … 328 332 *cmp = m->data[2]; 329 333 330 *id = ROAR_NET2HOST32(*((uint32_t*)&(m->data[3]))); 334 idreg = ((uint32_t)(unsigned char)m->data[3]) << 24; 335 idreg |= ((uint32_t)(unsigned char)m->data[4]) << 16; 336 idreg |= ((uint32_t)(unsigned char)m->data[5]) << 8; 337 idreg |= ((uint32_t)(unsigned char)m->data[6]) << 0; 338 *id = idreg; 331 339 332 340 return 0; … … 345 353 break; 346 354 default: 355 roar_err_set(ROAR_ERROR_NOTSUP); 347 356 return -1; 348 357 } … … 352 361 int i; 353 362 354 if ( len > LIBROAR_BUFFER_MSGDATA ) 355 return -1; 363 if ( len > LIBROAR_BUFFER_MSGDATA ) { 364 roar_err_set(ROAR_ERROR_MSGSIZE); 365 return -1; 366 } 356 367 357 368 m->datalen = len; … … 365 376 int i; 366 377 367 if ( m->datalen > len ) 368 return -1; 378 if ( m->datalen > len ) { 379 roar_err_set(ROAR_ERROR_MSGSIZE); 380 return -1; 381 } 369 382 370 383 for (i = 0; i < m->datalen; i++) … … 380 393 int max_len; 381 394 uint32_t pid; 382 size_t len_rest; 395 signed long int len_rest; 396 size_t nnode_len; 383 397 384 398 if ( c == NULL ) … … 429 443 cur += 4; 430 444 431 len_rest = sizeof(m->data) - cur; 432 if ( roar_nnode_to_blob(&(c->nnode), &(m->data[cur]), &len_rest) == 0 ) { 433 cur += len_rest; 445 len_rest = (long int)sizeof(m->data) - (long int)cur; 446 if ( len_rest < 0 ) { 447 roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION, NULL); 448 } 449 450 nnode_len = len_rest; 451 if ( roar_nnode_to_blob(&(c->nnode), &(m->data[cur]), &nnode_len) == 0 ) { 452 cur += nnode_len; 434 453 } 435 454 … … 445 464 size_t len; 446 465 447 if ( m == NULL || c == NULL ) 448 return -1; 449 450 if ( m->datalen == 0 ) 451 return -1; 466 if ( m == NULL || c == NULL ) { 467 roar_err_set(ROAR_ERROR_FAULT); 468 return -1; 469 } 470 471 if ( m->datalen == 0 ) { 472 roar_err_set(ROAR_ERROR_MSGSIZE); 473 return -1; 474 } 452 475 453 476 ROAR_DBG("roar_ctl_m2c(*): got data!, len = %i", m->datalen); … … 455 478 if ( m->data[0] != 0 ) { 456 479 ROAR_DBG("roar_ctl_m2c(*): wrong version!"); 457 return -1; 458 } 459 460 if ( m->datalen < 3 ) 461 return -1; 480 roar_err_set(ROAR_ERROR_NSVERSION); 481 return -1; 482 } 483 484 if ( m->datalen < 3 ) { 485 roar_err_set(ROAR_ERROR_MSGSIZE); 486 return -1; 487 } 462 488 463 489 ROAR_DBG("roar_ctl_m2c(*): have usable data!"); … … 467 493 for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) 468 494 c->streams[i] = -1; 495 496 if ( m->data[2] < 0 || m->data[2] > ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT ) { 497 roar_err_set(ROAR_ERROR_TOOMANYARGS); 498 return -1; 499 } 469 500 470 501 for (i = 0; i < m->data[2]; i++) … … 555 586 } 556 587 588 roar_err_set(ROAR_ERROR_NOENT); 557 589 return -1; 558 590 } … … 592 624 } 593 625 626 roar_err_set(ROAR_ERROR_NOENT); 594 627 return -1; 595 628 } … … 632 665 return _libroar_ot[i].ot; 633 666 667 roar_err_set(ROAR_ERROR_NOENT); 634 668 return -1; 635 669 } … … 642 676 return _libroar_ot[i].name; 643 677 678 roar_err_set(ROAR_ERROR_NOENT); 644 679 return NULL; 645 680 } … … 650 685 uint_least32_t s; 651 686 652 if ( dst == NULL || src == NULL || dstchans < 0 || srcchans < 0 ) 653 return -1; 687 if ( dst == NULL || src == NULL ) { 688 roar_err_set(ROAR_ERROR_FAULT); 689 return -1; 690 } 691 692 if ( dstchans < 0 || srcchans < 0 ) { 693 roar_err_set(ROAR_ERROR_INVAL); 694 return -1; 695 } 654 696 655 697 if ( dstchans == srcchans ) { … … 709 751 break; 710 752 default: 753 roar_err_set(ROAR_ERROR_NOTSUP); 711 754 return -1; 712 755 break; … … 741 784 break; 742 785 default: 786 roar_err_set(ROAR_ERROR_NOTSUP); 743 787 return -1; 744 788 break; … … 772 816 break; 773 817 default: 818 roar_err_set(ROAR_ERROR_NOTSUP); 774 819 return -1; 775 820 break; … … 802 847 break; 803 848 default: 849 roar_err_set(ROAR_ERROR_NOTSUP); 804 850 return -1; 805 851 break; … … 831 877 break; 832 878 default: 879 roar_err_set(ROAR_ERROR_NOTSUP); 833 880 return -1; 834 881 break; … … 836 883 break; 837 884 default: 885 roar_err_set(ROAR_ERROR_NOTSUP); 838 886 return -1; 839 887 break; -
libroar/enumdev.c
r5138 r5145 337 337 int i; 338 338 339 if ( servs == NULL ) 340 return -1; 339 if ( servs == NULL ) { 340 roar_err_set(ROAR_ERROR_FAULT); 341 return -1; 342 } 341 343 342 344 for (i = 0; (c = &(servs[i]))->server != NULL; i++) { … … 361 363 size_t ret; 362 364 363 if ( servs == NULL ) 364 return -1; 365 if ( servs == NULL ) { 366 roar_err_set(ROAR_ERROR_FAULT); 367 return -1; 368 } 365 369 366 370 for (ret = 0; servs[ret].server != NULL; ret++); -
libroar/keyval.c
r4708 r5145 40 40 ssize_t i; 41 41 42 if ( kv == NULL || key == NULL ) { 43 roar_err_set(ROAR_ERROR_FAULT); 44 return NULL; 45 } 46 42 47 if ( casesens ) 43 48 sc = strcmp; … … 48 53 } 49 54 55 roar_err_set(ROAR_ERROR_NOENT); 50 56 return NULL; 51 57 } … … 67 73 int last_was_seg = 0; 68 74 69 if ( kv == NULL || str == NULL ) 75 if ( kv == NULL || str == NULL ) { 76 roar_err_set(ROAR_ERROR_FAULT); 70 77 return -1; 78 } 71 79 72 80 // we currently do not support quotes 73 if ( quotes ) 81 if ( quotes ) { 82 roar_err_set(ROAR_ERROR_NOTSUP); 74 83 return -1; 84 } 75 85 76 86 if ( fdel == NULL ) -
libroar/ltm.c
r4873 r5145 65 65 size_t i; 66 66 67 if ( mt == 0 || streams == NULL || slen == 0 || mes == NULL || buf == NULL) {67 if ( mt == 0 ) { 68 68 roar_err_set(ROAR_ERROR_INVAL); 69 return -1; 70 } 71 72 if ( streams == NULL || slen == 0 || mes == NULL || buf == NULL ) { 73 roar_err_set(ROAR_ERROR_FAULT); 69 74 return -1; 70 75 } … … 172 177 int i; 173 178 174 if ( con == NULL ) 175 return NULL; 176 177 if ( streams == NULL || slen == 0 ) 178 return NULL; 179 if ( con == NULL ) { 180 roar_err_set(ROAR_ERROR_FAULT); 181 return NULL; 182 } 183 184 if ( streams == NULL || slen == 0 ) { 185 roar_err_set(ROAR_ERROR_FAULT); 186 return NULL; 187 } 179 188 180 189 if ( roar_ltm_pack_req(mt, window, streams, slen, &mes, &buf, ROAR_LTM_SST_GET_RAW) == -1 ) … … 238 247 } 239 248 240 #define _CKNULL(x) if ( (x) == NULL ) return -1241 #define _RETMEMBERCKED(x,m) _CKNULL(x) ;return (x)->m249 #define _CKNULL(x) if ( (x) == NULL ) { roar_err_set(ROAR_ERROR_FAULT); return -1; } 250 #define _RETMEMBERCKED(x,m) _CKNULL(x) return (x)->m 242 251 243 252 int roar_ltm_get_numstreams(struct roar_ltm_result * res) { … … 258 267 ROAR_DBG("roar_ltm_get_streamptr(res=%p, streamidx=%i) = ?", res, streamidx); 259 268 260 if ( res == NULL || streamidx < 0 || streamidx >= res->streams ) 261 return NULL; 269 if ( res == NULL || streamidx < 0 || streamidx >= res->streams ) { 270 roar_err_set(ROAR_ERROR_FAULT); 271 return NULL; 272 } 262 273 263 274 ptr = res->data; … … 294 305 ROAR_DBG("roar_ltm_extract(res=%p, mt=0x%.4x, streamidx=%i, channel=%i) = ?", res, mt, streamidx, channel); 295 306 296 if ( roar_ltm_numbits(mt) != 1 ) 297 return -1; 307 if ( roar_ltm_numbits(mt) != 1 ) { 308 roar_err_set(ROAR_ERROR_INVAL); 309 return -1; 310 } 298 311 299 312 ROAR_DBG("roar_ltm_extract(res=%p, mt=0x%.4x, streamidx=%i, channel=%i) = ?", res, mt, streamidx, channel); … … 306 319 ROAR_DBG("roar_ltm_extract(res=%p, mt=0x%.4x, streamidx=%i, channel=%i): numchans=%i", res, mt, streamidx, channel, numchans); 307 320 308 if ( channel >= numchans ) 309 return -1; 321 if ( channel >= numchans ) { 322 roar_err_set(ROAR_ERROR_RANGE); 323 return -1; 324 } 310 325 311 326 ptr++; -
libroar/stream.c
r5072 r5145 85 85 unsigned int channels, unsigned int bits, unsigned int codec) { 86 86 87 if ( s == NULL ) 88 return -1; 87 if ( s == NULL ) { 88 roar_err_set(ROAR_ERROR_FAULT); 89 return -1; 90 } 89 91 90 92 s->fh = -1; … … 115 117 116 118 int roar_stream_set_rel_id(struct roar_stream * s, int id) { 117 if ( s == NULL ) 118 return -1; 119 if ( s == NULL ) { 120 roar_err_set(ROAR_ERROR_FAULT); 121 return -1; 122 } 119 123 120 124 s->pos_rel_id = id; … … 124 128 125 129 int roar_stream_get_rel_id(struct roar_stream * s) { 126 if ( s == NULL ) 127 return -1; 130 if ( s == NULL ) { 131 roar_err_set(ROAR_ERROR_FAULT); 132 return -1; 133 } 128 134 129 135 return s->pos_rel_id; … … 131 137 132 138 int roar_stream_new_by_id(struct roar_stream * s, int id) { 133 if ( s == NULL ) 134 return -1; 139 if ( s == NULL ) { 140 roar_err_set(ROAR_ERROR_FAULT); 141 return -1; 142 } 135 143 136 144 if ( roar_stream_new_empty(s) == -1 ) … … 141 149 142 150 int roar_stream_new_empty(struct roar_stream * s) { 143 if ( s == NULL ) 144 return -1; 151 if ( s == NULL ) { 152 roar_err_set(ROAR_ERROR_FAULT); 153 return -1; 154 } 145 155 146 156 return roar_stream_new(s, 0, 0, 0, 0); … … 148 158 149 159 int roar_stream_set_id (struct roar_stream * s, int id) { 150 if ( s == NULL ) 151 return -1; 160 if ( s == NULL ) { 161 roar_err_set(ROAR_ERROR_FAULT); 162 return -1; 163 } 152 164 153 165 s->id = id; … … 157 169 158 170 int roar_stream_get_id (struct roar_stream * s) { 159 if ( s == NULL ) 160 return -1; 171 if ( s == NULL ) { 172 roar_err_set(ROAR_ERROR_FAULT); 173 return -1; 174 } 161 175 162 176 return s->id; … … 164 178 165 179 int roar_stream_set_fh (struct roar_stream * s, int fh) { 166 if ( s == NULL ) 167 return -1; 180 if ( s == NULL ) { 181 roar_err_set(ROAR_ERROR_FAULT); 182 return -1; 183 } 168 184 169 185 s->fh = fh; … … 173 189 174 190 int roar_stream_get_fh (struct roar_stream * s) { 175 if ( s == NULL ) 176 return -1; 191 if ( s == NULL ) { 192 roar_err_set(ROAR_ERROR_FAULT); 193 return -1; 194 } 177 195 178 196 return s->fh; … … 180 198 181 199 int roar_stream_set_dir (struct roar_stream * s, int dir) { 182 if ( s == NULL ) 183 return -1; 200 if ( s == NULL ) { 201 roar_err_set(ROAR_ERROR_FAULT); 202 return -1; 203 } 184 204 185 205 s->dir = dir; … … 189 209 190 210 int roar_stream_get_dir (struct roar_stream * s) { 191 if ( s == NULL ) 192 return -1; 211 if ( s == NULL ) { 212 roar_err_set(ROAR_ERROR_FAULT); 213 return -1; 214 } 193 215 194 216 return s->dir; … … 232 254 int len = 0; 233 255 234 if ( host == NULL ) 235 return -1; 256 if ( host == NULL ) { 257 roar_err_set(ROAR_ERROR_FAULT); 258 return -1; 259 } 236 260 237 261 ROAR_DBG("roar_stream_connect_to_ask(*): Ask the server to connect to: %s:%i", host, port); … … 249 273 len = strlen(host); 250 274 251 if ( len > 76 ) 252 return -1; 275 if ( len > 76 ) { 276 roar_err_set(ROAR_ERROR_NAMETOOLONG); 277 return -1; 278 } 253 279 254 280 strncpy(&(m.data[4]), host, len); … … 265 291 struct roar_message m; 266 292 int confh; 293 294 if ( con == NULL || s == NULL ) { 295 roar_err_set(ROAR_ERROR_FAULT); 296 return -1; 297 } 298 299 if ( fh < 0 ) { 300 roar_err_set(ROAR_ERROR_INVAL); 301 return -1; 302 } 267 303 268 304 memset(&m, 0, sizeof(m)); … … 310 346 int i; 311 347 348 if ( con == NULL || s == NULL ) { 349 roar_err_set(ROAR_ERROR_FAULT); 350 return -1; 351 } 352 353 if ( client < 0 ) { 354 roar_err_set(ROAR_ERROR_INVAL); 355 return -1; 356 } 357 312 358 memset(&m, 0, sizeof(m)); 313 359 … … 337 383 struct roar_message m; 338 384 385 if ( con == NULL || s == NULL || data == NULL ) { 386 roar_err_set(ROAR_ERROR_FAULT); 387 return -1; 388 } 389 339 390 memset(&m, 0, sizeof(m)); 340 391 … … 361 412 roar_debug_warn_obsolete("roar_stream_send_data", "roar_vio_write", NULL); 362 413 363 if ( s == NULL ) 364 return -1; 414 if ( s == NULL ) { 415 roar_err_set(ROAR_ERROR_FAULT); 416 return -1; 417 } 365 418 366 419 if ( s->fh == -1 ) { 367 if ( con == NULL ) 420 if ( con == NULL ) { 421 roar_err_set(ROAR_ERROR_NOTSUP); 368 422 return -1; 423 } 369 424 370 425 if ( roar_stream_add_data(con, s, data, len) == -1 ) … … 375 430 376 431 #ifdef ROAR_HAVE_IO_POSIX 377 return write(s->fh, data, len);432 return ROAR_NETWORK_WRITE(s->fh, data, len); 378 433 #endif 379 434 435 roar_err_set(ROAR_ERROR_NOTSUP); 380 436 return -1; 381 437 } … … 385 441 uint16_t * data = (uint16_t *) m.data; 386 442 int i; 443 444 if ( con == NULL || s == NULL || info == NULL ) { 445 roar_err_set(ROAR_ERROR_FAULT); 446 return -1; 447 } 387 448 388 449 memset(&m, 0, sizeof(m)); … … 410 471 } 411 472 412 if ( m.datalen < 7*2 ) 413 return -1; 414 415 if ( data[0] != 0 || data[1] != 1 ) 416 return -1; 473 if ( m.datalen < 7*2 ) { 474 roar_err_set(ROAR_ERROR_MSGSIZE); 475 return -1; 476 } 477 478 if ( data[0] != 0 || data[1] != 1 ) { 479 roar_err_set(ROAR_ERROR_NSVERSION); 480 return -1; 481 } 417 482 418 483 memset(info, 0, sizeof(struct roar_stream_info)); … … 459 524 uint16_t * data = (uint16_t *) m.data; 460 525 461 if ( con == NULL || s == NULL || name == NULL || len == 0 ) 462 return -1; 526 if ( con == NULL || s == NULL || name == NULL || len == 0 ) { 527 roar_err_set(ROAR_ERROR_FAULT); 528 return -1; 529 } 463 530 464 531 name[0] = 0; // just in case... … … 489 556 ROAR_DBG("roar_stream_get_name(*) = ?"); 490 557 491 if ( m.datalen < 4 ) 492 return -1; 558 if ( m.datalen < 4 ) { 559 roar_err_set(ROAR_ERROR_MSGSIZE); 560 return -1; 561 } 493 562 494 563 data[0] = ROAR_NET2HOST16(data[0]); … … 497 566 ROAR_DBG("roar_stream_get_name(*) = ?"); 498 567 499 if ( data[0] != 0 || data[1] != ROAR_STREAM_PARA_NAME ) 500 return -1; 568 if ( data[0] != 0 ) { 569 roar_err_set(ROAR_ERROR_NSVERSION); 570 return -1; 571 } 572 573 if ( data[1] != ROAR_STREAM_PARA_NAME ) { 574 roar_err_set(ROAR_ERROR_TYPEMM); 575 return -1; 576 } 501 577 502 578 m.datalen -= 4; … … 521 597 ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p, map=%p, len=%p) = ?", con, s, map, len); 522 598 523 if ( con == NULL || s == NULL || map == NULL || len == NULL ) 524 return -1; 525 526 if ( *len == 0 ) 527 return -1; 599 if ( con == NULL || s == NULL || map == NULL || len == NULL ) { 600 roar_err_set(ROAR_ERROR_FAULT); 601 return -1; 602 } 603 604 if ( *len == 0 ) { 605 roar_err_set(ROAR_ERROR_INVAL); 606 return -1; 607 } 528 608 529 609 memset(&m, 0, sizeof(m)); … … 549 629 ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len); 550 630 551 if ( m.datalen < 4 ) 552 return -1; 631 if ( m.datalen < 4 ) { 632 roar_err_set(ROAR_ERROR_MSGSIZE); 633 return -1; 634 } 553 635 554 636 data[0] = ROAR_NET2HOST16(data[0]); … … 557 639 ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len); 558 640 559 if ( data[0] != 0 || data[1] != ROAR_STREAM_PARA_CHANMAP ) 560 return -1; 641 if ( data[0] != 0 ) { 642 roar_err_set(ROAR_ERROR_NSVERSION); 643 return -1; 644 } 645 646 if ( data[1] != ROAR_STREAM_PARA_CHANMAP ) { 647 roar_err_set(ROAR_ERROR_TYPEMM); 648 return -1; 649 } 561 650 562 651 ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len); … … 564 653 m.datalen -= 4; 565 654 566 if ( m.datalen > *len ) 567 return -1; 655 if ( m.datalen > *len ) { 656 roar_err_set(ROAR_ERROR_NOMEM); 657 return -1; 658 } 568 659 569 660 ROAR_DBG("roar_stream_get_chanmap(con=%p, s=%p{.id=%i}, map=%p, len=%p) = ?", con, s, s->id, map, len); … … 581 672 uint16_t * data = (uint16_t *) m.data; 582 673 583 if ( con == NULL || s == NULL || map == NULL ) 584 return -1; 585 586 if ( len == 0 ) 674 if ( con == NULL || s == NULL || map == NULL ) { 675 roar_err_set(ROAR_ERROR_FAULT); 676 return -1; 677 } 678 679 if ( len == 0 ) { 680 roar_err_set(ROAR_ERROR_INVAL); 587 681 return 0; 682 } 588 683 589 684 memset(&m, 0, sizeof(m)); … … 622 717 uint16_t * data = (uint16_t *) m.data; 623 718 int i; 719 720 if ( con == NULL || s == NULL ) { 721 roar_err_set(ROAR_ERROR_FAULT); 722 return -1; 723 } 624 724 625 725 memset(&m, 0, sizeof(m)); … … 662 762 int i; 663 763 764 if ( con == NULL || s == NULL ) { 765 roar_err_set(ROAR_ERROR_FAULT); 766 return -1; 767 } 768 664 769 memset(&m, 0, sizeof(m)); 665 770 … … 692 797 int i; 693 798 694 if ( !(s && m) ) 695 return -1; 799 if ( s == NULL || m == NULL ) { 800 roar_err_set(ROAR_ERROR_FAULT); 801 return -1; 802 } 696 803 697 804 m->datalen = _ROAR_STREAM_MESSAGE_LEN; … … 719 826 int i; 720 827 721 if ( !(s && m) ) 722 return -1; 723 724 if ( m->datalen != _ROAR_STREAM_MESSAGE_LEN ) 725 return -1; 828 if ( s == NULL || m == NULL ) { 829 roar_err_set(ROAR_ERROR_FAULT); 830 return -1; 831 } 832 833 if ( m->datalen != _ROAR_STREAM_MESSAGE_LEN ) { 834 roar_err_set(ROAR_ERROR_MSGSIZE); 835 return -1; 836 } 726 837 727 838 s->pos = m->pos; … … 925 1036 return guess; 926 1037 927 if ( codec == NULL || *codec == 0 )928 return ROAR_CODEC_DEFAULT;929 930 1038 for (i = 0; _libroar_codec[i].codec != -1; i++) 931 1039 if ( strcasecmp(_libroar_codec[i].name, codec) == 0 ) 932 1040 return _libroar_codec[i].codec; 933 1041 1042 roar_err_set(ROAR_ERROR_NOENT); 934 1043 return -1; 935 1044 } … … 949 1058 int i; 950 1059 951 if ( mime == NULL || *mime == 0 ) 952 return -1; 1060 if ( mime == NULL ) { 1061 roar_err_set(ROAR_ERROR_FAULT); 1062 return -1; 1063 } 1064 1065 if ( *mime == 0 ) { 1066 roar_err_set(ROAR_ERROR_INVAL); 1067 return -1; 1068 } 953 1069 954 1070 for (i = 0; _libroar_codec[i].codec != -1; i++) … … 957 1073 return _libroar_codec[i].codec; 958 1074 1075 roar_err_set(ROAR_ERROR_NOENT); 959 1076 return -1; 960 1077 } … … 967 1084 return _libroar_codec[i].mime; 968 1085 1086 roar_err_set(ROAR_ERROR_NOENT); 969 1087 return NULL; 970 1088 } … … 981 1099 982 1100 if ( ret == 0 && rate[0] != '0' ) { 1101 roar_err_set(ROAR_ERROR_NOENT); 983 1102 return -1; 984 1103 } … … 998 1117 999 1118 if ( ret == 0 && bits[0] != '0' ) { 1119 roar_err_set(ROAR_ERROR_NOENT); 1000 1120 return -1; 1001 1121 } … … 1021 1141 1022 1142 if ( ret == 0 && channels[0] != '0' ) { 1143 roar_err_set(ROAR_ERROR_NOENT); 1023 1144 return -1; 1024 1145 } … … 1065 1186 int i; 1066 1187 1188 roar_err_clear(); 1189 1067 1190 for (i = 0; _libroar_role[i].name != NULL; i++) 1068 1191 if ( !strcasecmp(_libroar_role[i].name, role) ) 1069 1192 return _libroar_role[i].role; 1070 1193 1194 roar_err_set(ROAR_ERROR_NOENT); 1071 1195 return ROAR_ROLE_UNKNOWN; 1072 1196 }
Note: See TracChangeset
for help on using the changeset viewer.