# HG changeset patch # User mroi # Date 1078332642 0 # Node ID e75c52894630c49b4ed9bfa356d629677ba664ab # Parent f794e1c17947e98aec941f7d1e87f60746d9217a * assert(0) does not always and the program (see NDEBUG) * use abort(), where we should really terminate * reversed return value of getbits_init (I prefer booleans) diff -r f794e1c17947 -r e75c52894630 dvdread/nav_read.c --- a/dvdread/nav_read.c Wed Mar 03 16:48:36 2004 +0000 +++ b/dvdread/nav_read.c Wed Mar 03 16:50:42 2004 +0000 @@ -19,9 +19,9 @@ #include "config.h" #include +#include #include #include -#include #include "bswap.h" #include "nav_types.h" @@ -35,13 +35,13 @@ uint8_t byte; } getbits_state_t; -static int32_t getbits_init(getbits_state_t *state, uint8_t *start) { - if ((state == NULL) || (start == NULL)) return -1; +static int getbits_init(getbits_state_t *state, uint8_t *start) { + if ((state == NULL) || (start == NULL)) return 0; state->start = start; state->bit_position = 0; state->byte_position = 0; state->byte = start[0]; - return 0; + return 1; } /* Non-optimized getbits. */ @@ -51,7 +51,7 @@ uint8_t byte=0; if (number_of_bits > 32) { printf("Number of bits > 32 in getbits\n"); - assert(0); + abort(); } if ((state->bit_position) > 0) { /* Last getbits left us in the middle of a byte. */ @@ -128,7 +128,7 @@ void navRead_PCI(pci_t *pci, unsigned char *buffer) { int32_t i, j; getbits_state_t state; - if (getbits_init(&state, buffer)) assert(0); /* Passed NULL pointers */ + if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */ /* pci pci_gi */ pci->pci_gi.nv_pck_lbn = getbits(&state, 32 ); @@ -296,7 +296,7 @@ void navRead_DSI(dsi_t *dsi, unsigned char *buffer) { int i; getbits_state_t state; - if (getbits_init(&state, buffer)) assert(0); /* Passed NULL pointers */ + if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */ /* dsi dsi gi */ dsi->dsi_gi.nv_pck_scr = getbits(&state, 32 ); diff -r f794e1c17947 -r e75c52894630 vm/decoder.c --- a/vm/decoder.c Wed Mar 03 16:48:36 2004 +0000 +++ b/vm/decoder.c Wed Mar 03 16:50:42 2004 +0000 @@ -1,5 +1,6 @@ /* * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort + * 2002-2004 the dvdnav project * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. @@ -31,7 +32,6 @@ #include #include /* For memset */ #include "ifo_types.h" /* vm_cmd_t */ -#include #include "dvdnav_internal.h" @@ -49,7 +49,7 @@ (count < 0) || (start < 0) ) { fprintf(MSG_OUT, "libdvdnav: Bad call to vm_getbits. Parameter out of range\n"); - assert(0); + abort(); } /* all ones, please */ bit_mask = ~bit_mask; @@ -512,7 +512,7 @@ res = eval_special_instruction(&command, cond); if(res == -1) { fprintf(MSG_OUT, "libdvdnav: Unknown Instruction!\n"); - assert(0); + abort(); } break; case 1: /* Link/jump instructions */ @@ -566,7 +566,7 @@ break; default: /* Unknown command */ fprintf(MSG_OUT, "libdvdnav: WARNING: Unknown Command=%x\n", vm_getbits(&command, 63, 3)); - assert(0); + abort(); } /* Check if there are bits not yet examined */ diff -r f794e1c17947 -r e75c52894630 vm/vm.c --- a/vm/vm.c Wed Mar 03 16:48:36 2004 +0000 +++ b/vm/vm.c Wed Mar 03 16:50:42 2004 +0000 @@ -1,6 +1,7 @@ /* * Copyright (C) 2000, 2001 Håkan Hjort * Copyright (C) 2001 Rich Wareham + * 2002-2004 the dvdnav project * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. @@ -866,8 +867,9 @@ case VMGM_DOMAIN: case FP_DOMAIN: return vm->vmgi->vmgi_mat->vmgm_video_attr; + default: + abort(); } - assert(0); } audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) { @@ -879,8 +881,9 @@ case VMGM_DOMAIN: case FP_DOMAIN: return vm->vmgi->vmgi_mat->vmgm_audio_attr; + default: + abort(); } - assert(0); } subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) { @@ -892,8 +895,9 @@ case VMGM_DOMAIN: case FP_DOMAIN: return vm->vmgi->vmgi_mat->vmgm_subp_attr; + default: + abort(); } - assert(0); } @@ -1055,6 +1059,7 @@ switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { case 0: /* Not part of a block */ assert(0); + break; case 1: /* Angle block */ /* Loop and check each cell instead? So we don't get outside the block? */ (vm->state).cellN += (vm->state).AGL_REG - 1; @@ -1159,6 +1164,7 @@ switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { case 0: /* Not part of a block */ assert(0); + break; case 1: /* Angle block */ /* Skip the 'other' angles */ (vm->state).cellN++; @@ -1808,11 +1814,7 @@ pgcit = get_MENU_PGCIT(vm, vm->vmgi, (vm->state).registers.SPRM[0]); break; default: - pgcit = NULL; /* Should never hapen */ - fprintf(MSG_OUT, "libdvdnav: get_PGCIT: Unknown domain:%d\n", - (vm->state).domain); - assert(0); - break; + abort(); } return pgcit; diff -r f794e1c17947 -r e75c52894630 vm/vmcmd.c --- a/vm/vmcmd.c Wed Mar 03 16:48:36 2004 +0000 +++ b/vm/vmcmd.c Wed Mar 03 16:50:42 2004 +0000 @@ -1,5 +1,6 @@ /* * Copyright (C) 2000, 2001 Martin Norbäck, Håkan Hjort + * 2002-2004 the dvdnav project * * This file is part of libdvdnav, a DVD navigation library. It is modified * from a file originally part of the Ogle DVD player. @@ -29,7 +30,6 @@ #include #include #include -#include #include "dvdnav_internal.h"