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

This commit is contained in:
Thomas Schmitt 2006-10-07 14:19:32 +00:00
parent a8921e4f59
commit d252d1fc9b
7 changed files with 72 additions and 19 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2006.10.07.132916"
#define Cdrskin_timestamP "2006.10.07.142454"

View File

@ -127,7 +127,7 @@ int burn_drive_scan(struct burn_drive_info *drives[], unsigned int *n_drives)
struct scan_opts o;
int ret = 0;
/* ts A61006 : moved up from burn_drive_scan_sync , former assert */
/* ts A61006 : moved up from burn_drive_scan_sync , former Assert */
if (!burn_running) {
libdax_msgs_submit(libdax_messenger, -1, 0x00020109,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,

View File

@ -502,7 +502,7 @@ void burn_drive_clear_whitelist(void);
/** Scan for drives. This function MUST be called until it returns nonzero.
No drives can be in use when this is called or it will assert.
No drives may be in use when this is called.
All drive pointers are invalidated by using this function. Do NOT store
drive pointers across calls to this function or death AND pain will ensue.
After this call all drives depicted by the returned array are subject
@ -643,7 +643,7 @@ enum burn_drive_status burn_drive_get_status(struct burn_drive *drive,
/** Creates a write_opts struct for burning to the specified drive
must be freed with burn_write_opts_free
@param drive The drive to write with
@return The write_opts
@return The write_opts, NULL on error
*/
struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive);

View File

@ -303,7 +303,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
0x00020006 (FATAL,HIGH) = Too many scsi siblings
0x00020007 (NOTE,HIGH) = Closed O_EXCL scsi siblings
From the hunt on assert:
From the hunt on Assert:
0x00020101 (WARNING,HIGH) = Cannot find given worker item
0x00020102 (SORRY,HIGH) = A drive operation is still going on
@ -316,6 +316,8 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
0x00020108 (FATAL,HIGH) = Could not allocate new drive object
0x00020109 (FATAL,HIGH) = Library not running
0x00020110 (FATAL,HIGH) = Persistent drive address too long
0x00020111 (FATAL,HIGH) = Could not allocate new auxiliary object
0x00020112 (SORRY,HIGH) = Bad combination of write_type and block_type
------------------------------------------------------------------------------

View File

@ -2,14 +2,27 @@
#include "options.h"
#include "transport.h"
#include <assert.h>
/* ts A61007 */
/* #include <a ssert.h> */
#include <stdlib.h>
#include <string.h>
#include "libdax_msgs.h"
extern struct libdax_msgs *libdax_messenger;
struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive)
{
struct burn_write_opts *opts;
opts = malloc(sizeof(struct burn_write_opts));
if (opts == NULL) {
libdax_msgs_submit(libdax_messenger, -1, 0x00020111,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
"Could not allocate new auxiliary object", 0, 0);
return NULL;
}
opts->drive = drive;
opts->refcount = 1;
opts->write_type = BURN_WRITE_TAO;
@ -61,14 +74,32 @@ int burn_write_opts_set_write_type(struct burn_write_opts *opts,
enum burn_write_types write_type,
int block_type)
{
if ((write_type == BURN_WRITE_SAO && block_type == BURN_BLOCK_SAO) ||
(opts->drive->block_types[write_type] & block_type)) {
opts->write_type = write_type;
opts->block_type = block_type;
return 1;
int sector_get_outmode(enum burn_write_types write_type,
enum burn_block_types block_type);
int spc_block_type(enum burn_block_types b);
/* ts A61007 */
if (! ( (write_type == BURN_WRITE_SAO && block_type == BURN_BLOCK_SAO)
|| (opts->drive->block_types[write_type] & block_type) ) ) {
bad_combination:;
libdax_msgs_submit(libdax_messenger, -1, 0x00020112,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"Bad combination of write_type and block_type", 0, 0);
return 0;
}
assert(0);
return 0;
/* ts A61007 : obsoleting Assert in sector.c:get_outmode() */
if (sector_get_outmode(write_type, (enum burn_block_types) block_type)
== -1)
goto bad_combination;
/* ts A61007 : obsoleting Assert in spc.c:spc_block_type() */
if (spc_block_type((enum burn_block_types) block_type) == -1)
goto bad_combination;
opts->write_type = write_type;
opts->block_type = block_type;
return 1;
/* a ssert(0); */
}
void burn_write_opts_set_toc_entries(struct burn_write_opts *opts, int count,

View File

@ -37,13 +37,14 @@ static void uncook_subs(unsigned char *dest, unsigned char *source)
}
}
/* 0 means "same as inmode" */
static int get_outmode(struct burn_write_opts *o)
/* @return >=0 : valid , <0 invalid */
int sector_get_outmode(enum burn_write_types write_type,
enum burn_block_types block_type)
{
if (o->write_type == BURN_WRITE_SAO)
if (write_type == BURN_WRITE_SAO)
return 0;
else
switch (o->block_type) {
switch (block_type) {
case BURN_BLOCK_RAW0:
return BURN_MODE_RAW;
case BURN_BLOCK_RAW16:
@ -54,10 +55,25 @@ static int get_outmode(struct burn_write_opts *o)
return BURN_MODE_RAW | BURN_SUBCODE_R96;
case BURN_BLOCK_MODE1:
return BURN_MODE1;
default:
return -1;
}
assert(0); /* return BURN_MODE_UNIMPLEMENTED :) */
/* ts A61007 : now handled in burn_write_opts_set_write_type() */
/* a ssert(0); */ /* return BURN_MODE_UNIMPLEMENTED :) */
}
/* 0 means "same as inmode" */
static int get_outmode(struct burn_write_opts *o)
{
/* ts A61007 */
return sector_get_outmode(o->write_type, o->block_type);
/* -1 is prevented by check in burn_write_opts_set_write_type() */
/* a ssert(0); */ /* return BURN_MODE_UNIMPLEMENTED :) */
}
static void get_bytes(struct burn_track *track, int count, unsigned char *data)
{
int valid, shortage, curr;

View File

@ -375,6 +375,7 @@ void spc_probe_write_modes(struct burn_drive *d)
}
}
/** @return -1 = error */
int spc_block_type(enum burn_block_types b)
{
switch (b) {
@ -400,6 +401,9 @@ int spc_block_type(enum burn_block_types b)
return 12;
case BURN_BLOCK_MODE2_OK:
return 13;
default:
return -1;
}
assert(0);
/* ts A61007 : already prevented in burn_write_opts_set_write_type() */
/* a ssert(0); */;
}