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

This commit is contained in:
Thomas Schmitt 2006-10-07 17:05:45 +00:00
parent 54fab5e41b
commit 11e788aec5
3 changed files with 51 additions and 21 deletions

View File

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

View File

@ -207,21 +207,25 @@ ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
15) libburn/init.c: assert(burn_running); ++ 15) libburn/init.c: assert(burn_running);
API burn_finish(): API burn_finish():
The library is not initialized The library is not initialized
: Severe Application Error : Severe Application Error
=> return (assume no msg system) => return (assume no msg system)
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
16) libburn/init.c: assert(burn_running); ++ 16) libburn/init.c: assert(burn_running);
API burn_preset_device_open(): API burn_preset_device_open():
The library is not initialized The library is not initialized
: Severe Application Error : Severe Application Error
=> return -1; (assume no msg system) => return (assume no msg system)
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -305,7 +309,7 @@ Called by toc_find_modes(), does the same assert. To be solved there.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
24) libburn/options.c: assert(0); ++ 24) libburn/options.c: assert(0);
API burn_write_opts_set_write_type(): API burn_write_opts_set_write_type():
Detects unsuitable enum burn_write_types write_type and int block_type. Detects unsuitable enum burn_write_types write_type and int block_type.
API promises return 0 on failure API promises return 0 on failure
@ -313,12 +317,16 @@ API promises return 0 on failure
: Severe Application Error : Severe Application Error
=> issue LIBDAX_MSGS_SEV_SORRY => issue LIBDAX_MSGS_SEV_SORRY
=> should also detect problem of 26) : wrong write_type,block_type combination => should also detect problem of 26) : wrong write_type,block_type combination
by calling sector_get_outmode() and checking for -1
=> should also detect problem of 41) : unknown block_type => should also detect problem of 41) : unknown block_type
by spc_block_type() and checking for -1
=> delete assert(0) => delete assert(0)
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
25) libburn/read.c: assert((o->version & 0xfffff000) == (OPTIONS_VERSION & 0xfffff000)); ++ 25) libburn/read.c: assert((o->version & 0xfffff000) == (OPTIONS_VERSION & 0xfffff000));
libburn/read.c: assert(!d->busy); libburn/read.c: assert(!d->busy);
libburn/read.c: assert(d->toc->valid); libburn/read.c: assert(d->toc->valid);
libburn/read.c: assert(o->datafd != -1); libburn/read.c: assert(o->datafd != -1);
@ -333,16 +341,21 @@ OPTIONS_VERSION does not occur outside this line
( 37) => catch ! d->mdata->valid ) ( 37) => catch ! d->mdata->valid )
=> :) => :)
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
26) libburn/sector.c: assert(0); /* return BURN_MODE_UNIMPLEMENTED :) */ ++ 26) libburn/sector.c: assert(0); /* return BURN_MODE_UNIMPLEMENTED :) */
static get_outmode(): static get_outmode():
burn_write_opts is wrongly programmed with .write_type and .block_type burn_write_opts is wrongly programmed with .write_type and .block_type
: Severe Application Error : Severe Application Error
=> This should be handled by burn_write_opts_set_write_type() => This gets handled by burn_write_opts_set_write_type()
ts A61007 by new semi-public sector_get_outmode()
=> delete assert() => delete assert()
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
27) libburn/sector.c: assert(outlen >= inlen); 27) libburn/sector.c: assert(outlen >= inlen);
@ -402,25 +415,28 @@ process_q()
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
32) libburn/sg.c: assert("drive busy" == "non fatal"); ++ 32) libburn/sg.c: assert("drive busy" == "non fatal");
sg_handle_busy_device(): sg_handle_busy_device():
Intentional abort preset by the app Intentional abort preset by the app
=> change to abort() => change to abort()
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
33) libburn/sg.c: assert(fd != -1337); ++ 33) libburn/sg.c: assert(fd != -1337);
sg_grab(): sg_grab():
The drive device file could not be opened The drive device file could not be opened
:Severe External Problem :Severe External Problem
=> issue LIBDAX_MSGS_SEV_FATAL => obsolete by normal drive open failure handling
=> return 0
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
34) libburn/sg.c: assert(!c->page); ++ 34) libburn/sg.c: assert(!c->page);
sg_issue_command(): sg_issue_command():
An SCSI command of direction NO_TRANSFER may not have a .page != NULL. An SCSI command of direction NO_TRANSFER may not have a .page != NULL.
@ -430,6 +446,8 @@ it is sufficient to just not use it.
: Libburn Error : Libburn Error
=> enhance internal logics of sg_issue_command() => enhance internal logics of sg_issue_command()
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
35) libburn/sg.c: assert(c->page->bytes > 0); 35) libburn/sg.c: assert(c->page->bytes > 0);
@ -508,7 +526,7 @@ Called by (see 39)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
41) libburn/spc.c: assert(0); ++ 41) libburn/spc.c: assert(0);
spc_block_type(): spc_block_type():
Unknown value with enum burn_block_types Unknown value with enum burn_block_types
@ -517,8 +535,11 @@ Called by spc_select_write_params, uses burn_write_opts.block_type,
: Severe Application Error : Severe Application Error
=> catch in API burn_write_opts_set_write_type => catch in API burn_write_opts_set_write_type
by calling spc_block_type()
=> delete assert => delete assert
ts A61007
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
42) libburn/structure.c: assert(!(pos > BURN_POS_END));\ 42) libburn/structure.c: assert(!(pos > BURN_POS_END));\

View File

@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <stdlib.h>
#include "transport.h" #include "transport.h"
#include "drive.h" #include "drive.h"
@ -99,7 +100,10 @@ int sg_handle_busy_device(char *fname, int os_errno)
fprintf(stderr, fprintf(stderr,
"\nlibburn: FATAL : Application triggered abort on busy device '%s'\n", "\nlibburn: FATAL : Application triggered abort on busy device '%s'\n",
fname); fname);
assert("drive busy" == "non fatal");
/* ts A61007 */
abort();
/* a ssert("drive busy" == "non fatal"); */
} }
/* ts A60924 : now reporting to libdax_msgs */ /* ts A60924 : now reporting to libdax_msgs */
@ -451,7 +455,7 @@ static void enumerate_common(char *fname, int bus_no, int host_no,
out.mdata = malloc(sizeof(struct scsi_mode_data)); out.mdata = malloc(sizeof(struct scsi_mode_data));
out.mdata->valid = 0; out.mdata->valid = 0;
/* ts A61007 : obsolete assert() in drive_getcaps() */ /* ts A61007 : obsolete Assert in drive_getcaps() */
if(out.idata == NULL || out.mdata == NULL) { if(out.idata == NULL || out.mdata == NULL) {
libdax_msgs_submit(libdax_messenger, -1, 0x00020108, libdax_msgs_submit(libdax_messenger, -1, 0x00020108,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
@ -544,8 +548,10 @@ int sg_grab(struct burn_drive *d)
} else } else
fd= d->fd; fd= d->fd;
assert(fd != -1337); /* ts A61007 : this is redundant */
if (-1 != fd) { /* a ssert(fd != -1337); */
if (fd >= 0) {
/* ts A60814: /* ts A60814:
according to my experiments this test would work now ! */ according to my experiments this test would work now ! */
@ -606,7 +612,7 @@ int sg_release(struct burn_drive *d)
int sg_issue_command(struct burn_drive *d, struct command *c) int sg_issue_command(struct burn_drive *d, struct command *c)
{ {
int done = 0; int done = 0, no_c_page = 0;
int err; int err;
sg_io_hdr_t s; sg_io_hdr_t s;
@ -639,7 +645,10 @@ this is valid during the mode probe in scan
s.dxfer_direction = SG_DXFER_FROM_DEV; s.dxfer_direction = SG_DXFER_FROM_DEV;
else if (c->dir == NO_TRANSFER) { else if (c->dir == NO_TRANSFER) {
s.dxfer_direction = SG_DXFER_NONE; s.dxfer_direction = SG_DXFER_NONE;
assert(!c->page);
/* ts A61007 */
/* a ssert(!c->page); */
no_c_page = 1;
} }
s.cmd_len = c->oplen; s.cmd_len = c->oplen;
s.cmdp = c->opcode; s.cmdp = c->opcode;
@ -647,7 +656,7 @@ this is valid during the mode probe in scan
s.sbp = c->sense; s.sbp = c->sense;
memset(c->sense, 0, sizeof(c->sense)); memset(c->sense, 0, sizeof(c->sense));
s.timeout = 200000; s.timeout = 200000;
if (c->page) { if (c->page && !no_c_page) {
s.dxferp = c->page->data; s.dxferp = c->page->data;
if (c->dir == FROM_DRIVE) { if (c->dir == FROM_DRIVE) {
s.dxfer_len = BUFFER_SIZE; s.dxfer_len = BUFFER_SIZE;