Got rid of assert() in structure.c by soft means

This commit is contained in:
Thomas Schmitt 2006-10-08 10:04:09 +00:00
parent 988622c3b6
commit 2403532242
6 changed files with 97 additions and 31 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2006.10.07.175427"
#define Cdrskin_timestamP "2006.10.08.095016"

View File

@ -373,7 +373,7 @@ Called by sector_toc() sector_pregap() sector_postgap() sector_lout()
------------------------------------------------------------------------------
28) libburn/sector.c: assert(0);
++ 28) libburn/sector.c: assert(0);
static char_to_isrc():
Called by subcode_user() with data set by API burn_track_set_isrc()
Some character conversion fails on wrong input
@ -383,6 +383,8 @@ Some character conversion fails on wrong input
=> char_to_isrc() returns 0 as default
=> delete assert()
ts A61008
------------------------------------------------------------------------------
29) libburn/sector.c: assert(qmode == 1 || qmode == 2 || qmode == 3);
@ -472,7 +474,7 @@ The transfer of the command via ioctl() failed
------------------------------------------------------------------------------
37) libburn/spc.c: assert(d->mdata->valid);
++ 37) libburn/spc.c: assert(d->mdata->valid);
spc_select_error_params():
Drive was not properly programmed
@ -480,12 +482,13 @@ alias struct burn_drive.send_parameters()
Called by burn_disc_read, - defunct -
: Severe Application Error
(=> catch ! d->mdata->valid in burn_disc_read() )
=> :)
=> moved up as mangled assert to burn_disc_read()
ts A61007
------------------------------------------------------------------------------
38) libburn/spc.c: assert(d->mdata->cdr_write || d->mdata->cdrw_write ||
++ 38) libburn/spc.c: assert(d->mdata->cdr_write || d->mdata->cdrw_write ||
spc_sense_write_params():
Drive does not offer write of any known media type
@ -495,9 +498,11 @@ Called by API burn_drive_grab (assert test made there in soft)
: Severe Command Level Problem
=> remove assert()
ts A61007
------------------------------------------------------------------------------
39) libburn/spc.c: assert(o->drive == d);
++ 39) libburn/spc.c: assert(o->drive == d);
spc_select_write_params():
Drive does not match struct burn_write_opts
@ -509,9 +514,11 @@ Called by mmc_close_disc() (-defunct- ?), mmc_close_session() (-defunct- ?),
: Severe Libburn Error
=> remove assert()
ts A61007
------------------------------------------------------------------------------
40) libburn/spc.c: assert(d->mdata->valid);
++ 40) libburn/spc.c: assert(d->mdata->valid);
spc_select_write_params():
Drive was not properly programmed
@ -520,9 +527,9 @@ Called by (see 39)
burn_disc_write_sync() indirectly by API burn_disc_write()
: Severe Libburn Error
=> catch in burn_disc_write()
=> ? ignore command and issue LIBDAX_MSGS_SEV_SORRY ?
=> ? issue LIBDAX_MSGS_SEV_FATAL and shutdown libburn ?
=> caught in burn_disc_write() now
ts A61007
------------------------------------------------------------------------------
@ -542,7 +549,7 @@ ts A61007
------------------------------------------------------------------------------
42) libburn/structure.c: assert(!(pos > BURN_POS_END));\
++ 42) libburn/structure.c: assert(!(pos > BURN_POS_END));\
macro RESIZE
An illegal list index is given by the app.
@ -550,9 +557,9 @@ An illegal list index is given by the app.
Used by API burn_session_add_track() and API burn_disc_add_session()
: Severe Application Error
=> catch in API burn_session_add_track() , API burn_disc_add_session()
=> issue LIBDAX_MSGS_SEV_SORRY and return 0
=> delete assert
=> replace assert by if-and-return-0
ts A61008
------------------------------------------------------------------------------
@ -561,21 +568,26 @@ API burn_session_remove_track()
An application supplied pointer is NULL
: Severe Application Error
=> issue LIBDAX_MSGS_SEV_SORRY and return 0
=> delete assert
=> replace by if-and-return-0
ts A61008
------------------------------------------------------------------------------
44) libburn/structure.c: assert((country[i] >= '0' || country[i] < '9') &&
++ 44) libburn/structure.c: assert((country[i] >= '0' || country[i] < '9') &&
libburn/structure.c: assert((owner[i] >= '0' || owner[i] < '9') &&
libburn/structure.c: assert(year <= 99);
libburn/structure.c: assert(serial <= 99999);
API burn_track_set_isrc():
Illegal texts supplied by application
Illegal texts supplied by application.
The logical expression is always true !
: Severe Application Error
=> issue LIBDAX_MSGS_SEV_SORRY and return
=> delete assert
=> delete assert 28) in char_to_isrc()
ts A61008
------------------------------------------------------------------------------

View File

@ -319,6 +319,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
0x00020111 (FATAL,HIGH) = Could not allocate new auxiliary object
0x00020112 (SORRY,HIGH) = Bad combination of write_type and block_type
0x00020113 (FATAL,HIGH) = Drive capabilities not inquired yet
0x00020114 (SORRY,HIGH) = Attempt to set ISRC with bad data
------------------------------------------------------------------------------

View File

@ -378,7 +378,9 @@ static char char_to_isrc(char c)
return 0x11 + (c - 'A');
if (c >= 'a' && c <= 'z')
return 0x11 + (c - 'a');
assert(0);
/* ts A61008 : obsoleted by test in burn_track_set_isrc() */
/* a ssert(0); */
return 0;
}

View File

@ -9,7 +9,10 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include <assert.h>
/* ts A61008 */
/* #include <a ssert.h> */
#include <stdlib.h>
#include "transport.h"

View File

@ -1,4 +1,7 @@
#include <assert.h>
/* ts A61008 */
/* #include <a ssert.h> */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -7,10 +10,18 @@
#include "write.h"
#include "debug.h"
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
/* ts A61008 : replaced Assert by if and return 0 */
/* a ssert(!(pos > BURN_POS_END)); */
#define RESIZE(TO, NEW, pos) {\
void *tmp;\
\
assert(!(pos > BURN_POS_END));\
if (pos > BURN_POS_END)\
return 0;\
if (pos == BURN_POS_END)\
pos = TO->NEW##s;\
if (pos > TO->NEW##s)\
@ -138,7 +149,10 @@ int burn_session_remove_track(struct burn_session *s, struct burn_track *t)
struct burn_track **tmp;
int i, pos = -1;
assert(s->track != NULL);
/* ts A61008 */
/* a ssert(s->track != NULL); */
if (s->track == NULL)
return 0;
burn_track_free(t);
@ -203,23 +217,57 @@ void burn_track_set_isrc(struct burn_track *t, char *country, char *owner,
{
int i;
t->isrc.has_isrc = 1;
for (i = 0; i < 2; ++i) {
assert((country[i] >= '0' || country[i] < '9') &&
/* ts A61008 : This is always true */
/* a ssert((country[i] >= '0' || country[i] < '9') &&
(country[i] >= 'a' || country[i] < 'z') &&
(country[i] >= 'A' || country[i] < 'Z'));
(country[i] >= 'A' || country[i] < 'Z')); */
/* ts A61008 : now coordinated with sector.c: char_to_isrc() */
if (! ((country[i] >= '0' && country[i] <= '9') ||
(country[i] >= 'a' && country[i] <= 'z') ||
(country[i] >= 'A' && country[i] <= 'Z') ) )
goto is_not_allowed;
t->isrc.country[i] = country[i];
}
for (i = 0; i < 3; ++i) {
assert((owner[i] >= '0' || owner[i] < '9') &&
/* ts A61008 : This is always true */
/* a ssert((owner[i] >= '0' || owner[i] < '9') &&
(owner[i] >= 'a' || owner[i] < 'z') &&
(owner[i] >= 'A' || owner[i] < 'Z'));
(owner[i] >= 'A' || owner[i] < 'Z')); */
/* ts A61008 : now coordinated with sector.c: char_to_isrc() */
if (! ((owner[i] >= '0' && owner[i] <= '9') ||
(owner[i] >= 'a' && owner[i] <= 'z') ||
(owner[i] >= 'A' && owner[i] <= 'Z') ) )
goto is_not_allowed;
t->isrc.owner[i] = owner[i];
}
assert(year <= 99);
/* ts A61008 */
/* a ssert(year <= 99); */
if (year > 99)
goto is_not_allowed;
t->isrc.year = year;
assert(serial <= 99999);
/* ts A61008 */
/* a ssert(serial <= 99999); */
if (serial > 99999)
goto is_not_allowed;
t->isrc.serial = serial;
/* ts A61008 */
t->isrc.has_isrc = 1;
return;
is_not_allowed:;
libdax_msgs_submit(libdax_messenger, -1, 0x00020114,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"Attempt to set ISRC with bad data", 0, 0);
return;
}
void burn_track_clear_isrc(struct burn_track *t)