# HG changeset patch # User nicodvb # Date 1176322436 0 # Node ID bd734ab914d00e839d3d03265f999c9f2b2bb1c5 # Parent baec6f29fb76688fe0e80a773f96d82e1254e267 removed nonsensical checks on the sanity of dvdnav_t *this passed to nearly every function; checks like those don't belong to the library and are good only to hide bugs in applications (whose quality will likely decrease) diff -r baec6f29fb76 -r bd734ab914d0 dvdnav.c --- a/dvdnav.c Wed Apr 11 19:52:10 2007 +0000 +++ b/dvdnav.c Wed Apr 11 20:13:56 2007 +0000 @@ -122,11 +122,6 @@ fprintf(MSG_OUT, "libdvdnav: close:called\n"); #endif - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - if (this->file) { DVDCloseFile(this->file); #ifdef LOG_DEBUG @@ -159,11 +154,6 @@ fprintf(MSG_OUT, "libdvdnav: reset:called\n"); #endif - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); #ifdef LOG_DEBUG @@ -184,12 +174,6 @@ } dvdnav_status_t dvdnav_path(dvdnav_t *this, const char** path) { - - if(!this || !path) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - (*path) = this->path; return DVDNAV_STATUS_OK; @@ -412,11 +396,6 @@ dvd_state_t *state; int32_t result; - if(!this || !event || !len || !buf || !*buf) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if(!this->started) { @@ -829,23 +808,13 @@ } dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) { - - if(!this || !title_str) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - (*title_str) = this->vm->dvd_name; return DVDNAV_STATUS_OK; } uint8_t dvdnav_get_video_aspect(dvdnav_t *this) { uint8_t retval; - - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } + if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -861,10 +830,6 @@ uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) { uint8_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -880,10 +845,6 @@ uint16_t dvdnav_audio_stream_to_lang(dvdnav_t *this, uint8_t stream) { audio_attr_t attr; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -903,10 +864,6 @@ audio_attr_t attr; uint16_t format; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; /* 0xffff */ - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; /* 0xffff */ @@ -945,10 +902,6 @@ audio_attr_t attr; uint16_t format; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; /* 0xffff */ - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; /* 0xffff */ @@ -964,10 +917,6 @@ uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *this, uint8_t stream) { subp_attr_t attr; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -986,10 +935,6 @@ int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) { int8_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -1010,10 +955,6 @@ int8_t dvdnav_get_spu_logical_stream(dvdnav_t *this, uint8_t subp_num) { int8_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -1034,10 +975,6 @@ int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) { int8_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -1058,10 +995,6 @@ int8_t dvdnav_get_active_spu_stream(dvdnav_t *this) { int8_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -1082,10 +1015,6 @@ static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) { int8_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return -1; - } if(!this->started) { printerr("Virtual DVD machine not started."); return -1; @@ -1119,11 +1048,6 @@ dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) { int32_t num, current; - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); vm_get_angle_info(this->vm, ¤t, &num); /* Set angle SPRM if valid */ @@ -1141,11 +1065,6 @@ dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle, int32_t *number_of_angles) { - if(!this || !current_angle || !number_of_angles) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); vm_get_angle_info(this->vm, current_angle, number_of_angles); pthread_mutex_unlock(&this->vm_lock); @@ -1181,10 +1100,6 @@ ops.ops_int = 0; - if(!this) { - printerr("Passed a NULL pointer."); - return ops.ops_struct; - } if(!this->started) { printerr("Virtual DVD machine not started."); return ops.ops_struct; diff -r baec6f29fb76 -r bd734ab914d0 highlight.c --- a/highlight.c Wed Apr 11 19:52:10 2007 +0000 +++ b/highlight.c Wed Apr 11 20:13:56 2007 +0000 @@ -206,12 +206,6 @@ /* Highlighting API calls */ dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int32_t *button) { - - if(!this || !button) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - /* Simply return the appropriate value based on the SPRM */ if(((*button) = this->position_current.button) == -1) (*button) = this->vm->state.HL_BTNN_REG >> 10; @@ -222,10 +216,6 @@ static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) { int32_t button = 0; - if(!this || !pci) { - printerr("Passed a NULL pointer."); - return NULL; - } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); return NULL; @@ -331,10 +321,6 @@ int32_t button; btni_t *button_ptr = NULL; - if(!this || !pci) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); return DVDNAV_STATUS_ERR; @@ -391,11 +377,6 @@ dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd) { - if(!this || !cmd) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); /* make the VM execute the appropriate code and probably * schedule a jump */ @@ -417,11 +398,6 @@ } dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) { - - if(!this || !pci) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); return DVDNAV_STATUS_ERR; @@ -459,10 +435,6 @@ int32_t best,dist,d; int32_t mx,my,dx,dy; - if(!this || !pci) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } if(!pci->hli.hl_gi.hli_ss) { printerr("Not in a menu."); return DVDNAV_STATUS_ERR; diff -r baec6f29fb76 -r bd734ab914d0 navigation.c --- a/navigation.c Wed Apr 11 19:52:10 2007 +0000 +++ b/navigation.c Wed Apr 11 20:13:56 2007 +0000 @@ -30,11 +30,6 @@ /* Navigation API calls */ dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) { - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - this->position_current.still = 0; this->skip_still = 1; this->sync_wait = 0; @@ -44,11 +39,6 @@ } dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) { - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - this->sync_wait = 0; this->sync_wait_skip = 1; @@ -56,10 +46,6 @@ } dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) { - if(!this || !titles) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } if (!this->vm->vmgi) { printerr("Bad VM state."); return DVDNAV_STATUS_ERR; @@ -71,10 +57,6 @@ } dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) { - if(!this || !parts) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } if (!this->vm->vmgi) { printerr("Bad VM state."); return DVDNAV_STATUS_ERR; @@ -92,11 +74,6 @@ dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) { int32_t retval; - if(!this || !title || !part) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if (!this->vm->vtsi || !this->vm->vmgi) { printerr("Bad VM state."); @@ -134,21 +111,12 @@ } dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) { - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } return dvdnav_part_play(this, title, 1); } dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) { int32_t retval; - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if (!this->vm->vmgi) { printerr("Bad VM state."); @@ -194,22 +162,12 @@ dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title, uint64_t time) { - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - /* FIXME: Implement */ printerr("Not implemented yet."); return DVDNAV_STATUS_ERR; } dvdnav_status_t dvdnav_stop(dvdnav_t *this) { - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); this->vm->stopped = 1; pthread_mutex_unlock(&this->vm_lock); @@ -217,11 +175,6 @@ } dvdnav_status_t dvdnav_go_up(dvdnav_t *this) { - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - /* A nice easy function... delegate to the VM */ pthread_mutex_lock(&this->vm_lock); vm_jump_up(this->vm); diff -r baec6f29fb76 -r bd734ab914d0 searching.c --- a/searching.c Wed Apr 11 19:52:10 2007 +0000 +++ b/searching.c Wed Apr 11 20:13:56 2007 +0000 @@ -310,12 +310,6 @@ } dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) { - - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if(!this->vm->state.pgc) { printerr("No current PGC."); @@ -344,12 +338,6 @@ } dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) { - - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if(!this->vm->state.pgc) { printerr("No current PGC."); @@ -380,11 +368,6 @@ dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) { vm_t *try_vm; - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if(!this->vm->state.pgc) { printerr("No current PGC."); @@ -427,11 +410,6 @@ dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) { vm_t *try_vm; - if(!this) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - pthread_mutex_lock(&this->vm_lock); if(!this->vm->state.pgc) { printerr("No current PGC."); @@ -479,10 +457,6 @@ cell_playback_t *cell; dvd_state_t *state; - if(!this || !pos || !len) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } if(!this->started) { printerr("Virtual DVD machine not started."); return DVDNAV_STATUS_ERR; @@ -549,11 +523,6 @@ cell_playback_t *last_cell; dvd_state_t *state; - if(!this || !pos || !len) { - printerr("Passed a NULL pointer."); - return DVDNAV_STATUS_ERR; - } - state = &(this->vm->state); if(!state->pgc) { printerr("No current PGC.");