Initialize/null out drive capabilities before setting them.

This commit is contained in:
rocky
2004-07-19 01:29:04 +00:00
parent 8a99889f49
commit fa0d5bf3d9
2 changed files with 17 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: freebsd_cam.c,v 1.19 2004/07/19 01:13:32 rocky Exp $ $Id: freebsd_cam.c,v 1.20 2004/07/19 01:29:04 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.19 2004/07/19 01:13:32 rocky Exp $"; static const char _rcsid[] = "$Id: freebsd_cam.c,v 1.20 2004/07/19 01:29:04 rocky Exp $";
#ifdef HAVE_FREEBSD_CDROM #ifdef HAVE_FREEBSD_CDROM
@@ -171,9 +171,9 @@ get_drive_mcn_freebsd_cam (img_private_t *env)
*/ */
static cdio_drive_cap_t static cdio_drive_cap_t
get_drive_cap_freebsd_cam (img_private_t *env, get_drive_cap_freebsd_cam (img_private_t *env,
cdio_drive_read_cap_t *p_read_cap, /*out*/ cdio_drive_read_cap_t *p_read_cap,
cdio_drive_write_cap_t *p_write_cap, /*out*/ cdio_drive_write_cap_t *p_write_cap,
cdio_drive_misc_cap_t *p_misc_cap) /*out*/ cdio_drive_misc_cap_t *p_misc_cap)
{ {
int32_t i_drivetype = 0; int32_t i_drivetype = 0;
uint8_t buf[192] = { 0, }; uint8_t buf[192] = { 0, };
@@ -207,6 +207,9 @@ get_drive_cap_freebsd_cam (img_private_t *env,
if(rc == 0) { if(rc == 0) {
unsigned int n=buf[3]+4; unsigned int n=buf[3]+4;
*p_read_cap = 0;
*p_write_cap = 0;
*p_misc_cap = 0;
cdio_get_drive_cap_mmc(&(buf[n], p_read_cap, p_write_cap, p_misc_cap)); cdio_get_drive_cap_mmc(&(buf[n], p_read_cap, p_write_cap, p_misc_cap));
} else { } else {
*p_read_cap = CDIO_DRIVE_CAP_ERROR; *p_read_cap = CDIO_DRIVE_CAP_ERROR;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_sunos.c,v 1.55 2004/07/19 01:13:32 rocky Exp $ $Id: _cdio_sunos.c,v 1.56 2004/07/19 01:29:04 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -38,7 +38,7 @@
#ifdef HAVE_SOLARIS_CDROM #ifdef HAVE_SOLARIS_CDROM
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.55 2004/07/19 01:13:32 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.56 2004/07/19 01:29:04 rocky Exp $";
#ifdef HAVE_GLOB_H #ifdef HAVE_GLOB_H
#include <glob.h> #include <glob.h>
@@ -596,9 +596,9 @@ cdio_get_default_device_solaris(void)
*/ */
static void static void
_get_drive_cap_solaris (const void *user_data, _get_drive_cap_solaris (const void *user_data,
cdio_drive_read_cap_t *p_read_cap, /*out*/ cdio_drive_read_cap_t *p_read_cap,
cdio_drive_write_cap_t *p_write_cap, /*out*/ cdio_drive_write_cap_t *p_write_cap,
cdio_drive_misc_cap_t *p_misc_cap) /*out*/ cdio_drive_misc_cap_t *p_misc_cap)
{ {
const _img_private_t *env = user_data; const _img_private_t *env = user_data;
int status; int status;
@@ -631,6 +631,10 @@ _get_drive_cap_solaris (const void *user_data,
int lenData = ((unsigned int)buf[0] << 8) + buf[1]; int lenData = ((unsigned int)buf[0] << 8) + buf[1];
uint8_t *pMax = buf + 256; uint8_t *pMax = buf + 256;
*p_read_cap = 0;
*p_write_cap = 0;
*p_misc_cap = 0;
/* set to first sense mask, and then walk through the masks */ /* set to first sense mask, and then walk through the masks */
p = buf + 8; p = buf + 8;
while( (p < &(buf[2+lenData])) && (p < pMax) ) { while( (p < &(buf[2+lenData])) && (p < pMax) ) {