Skip to content

Commit

Permalink
stored: always initialize struct mtop
Browse files Browse the repository at this point in the history
When running in valgrind the ioctl() call that consumes struct mtop is
flagged as accessing uninitialized memory. This patch initializes every
struct mtop.

(cherry picked from commit 53e6700)
  • Loading branch information
arogge committed Oct 1, 2020
1 parent 0086b85 commit f8918d9
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions core/src/stored/backends/generic_tape_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void generic_tape_device::OpenDevice(DeviceControlRecord* dcr, int omode)
file_size = 0;
int timeout = max_open_wait;
#if !defined(HAVE_WIN32)
struct mtop mt_com;
struct mtop mt_com{};
utime_t start_time = time(NULL);
#endif

Expand Down Expand Up @@ -153,7 +153,7 @@ void generic_tape_device::OpenDevice(DeviceControlRecord* dcr, int omode)
*/
bool generic_tape_device::eod(DeviceControlRecord* dcr)
{
struct mtop mt_com;
struct mtop mt_com{};
bool ok = true;
int32_t os_file;

Expand Down Expand Up @@ -328,7 +328,7 @@ void generic_tape_device::SetAteot()
*/
bool generic_tape_device::offline()
{
struct mtop mt_com;
struct mtop mt_com{};

/*
* Remove EOF/EOT flags.
Expand Down Expand Up @@ -366,7 +366,7 @@ bool generic_tape_device::offline()
*/
bool generic_tape_device::weof(int num)
{
struct mtop mt_com;
struct mtop mt_com{};
int status;
Dmsg1(129, "=== weof_dev=%s\n", prt_name);

Expand Down Expand Up @@ -415,7 +415,7 @@ bool generic_tape_device::weof(int num)
bool generic_tape_device::fsf(int num)
{
int32_t os_file = 0;
struct mtop mt_com;
struct mtop mt_com{};
int status = 0;

if (!IsOpen()) {
Expand Down Expand Up @@ -598,7 +598,7 @@ bool generic_tape_device::fsf(int num)
*/
bool generic_tape_device::bsf(int num)
{
struct mtop mt_com;
struct mtop mt_com{};
int status;

if (!IsOpen()) {
Expand Down Expand Up @@ -645,7 +645,7 @@ static inline bool DevGetOsPos(Device* dev, struct mtget* mt_stat)
*/
bool generic_tape_device::fsr(int num)
{
struct mtop mt_com;
struct mtop mt_com{};
int status;

if (!IsOpen()) {
Expand Down Expand Up @@ -701,7 +701,7 @@ bool generic_tape_device::fsr(int num)
*/
bool generic_tape_device::bsr(int num)
{
struct mtop mt_com;
struct mtop mt_com{};
int status;

if (!IsOpen()) {
Expand Down Expand Up @@ -744,7 +744,7 @@ bool generic_tape_device::bsr(int num)
bool generic_tape_device::LoadDev()
{
#ifdef MTLOAD
struct mtop mt_com;
struct mtop mt_com{};
#endif

if (fd_ < 0) {
Expand Down Expand Up @@ -782,7 +782,7 @@ bool generic_tape_device::LoadDev()
void generic_tape_device::LockDoor()
{
#ifdef MTLOCK
struct mtop mt_com;
struct mtop mt_com{};

mt_com.mt_op = MTLOCK;
mt_com.mt_count = 1;
Expand All @@ -793,7 +793,7 @@ void generic_tape_device::LockDoor()
void generic_tape_device::UnlockDoor()
{
#ifdef MTUNLOCK
struct mtop mt_com;
struct mtop mt_com{};

mt_com.mt_op = MTUNLOCK;
mt_com.mt_count = 1;
Expand Down Expand Up @@ -834,7 +834,7 @@ static inline void OsClrerror(Device* dev)
*/
static inline void OsClrerror(Device* dev)
{
struct mtop mt_com;
struct mtop mt_com{};

/*
* Clear any error condition on the tape
Expand Down Expand Up @@ -991,7 +991,7 @@ void generic_tape_device::SetOsDeviceParameters(DeviceControlRecord* dcr)
}

#if defined(HAVE_LINUX_OS) || defined(HAVE_WIN32)
struct mtop mt_com;
struct mtop mt_com{};

Dmsg0(100, "In SetOsDeviceParameters\n");
#if defined(MTSETBLK)
Expand Down Expand Up @@ -1021,7 +1021,7 @@ void generic_tape_device::SetOsDeviceParameters(DeviceControlRecord* dcr)
#endif

#ifdef HAVE_NETBSD_OS
struct mtop mt_com;
struct mtop mt_com{};
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSETBSIZ;
Expand All @@ -1040,7 +1040,7 @@ void generic_tape_device::SetOsDeviceParameters(DeviceControlRecord* dcr)
#endif

#if HAVE_FREEBSD_OS || HAVE_OPENBSD_OS
struct mtop mt_com;
struct mtop mt_com{};
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSETBSIZ;
Expand Down Expand Up @@ -1068,7 +1068,7 @@ void generic_tape_device::SetOsDeviceParameters(DeviceControlRecord* dcr)
#endif

#ifdef HAVE_SUN_OS
struct mtop mt_com;
struct mtop mt_com{};
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSRSZ;
Expand Down Expand Up @@ -1103,7 +1103,7 @@ int32_t generic_tape_device::GetOsTapeFile()
*/
bool generic_tape_device::rewind(DeviceControlRecord* dcr)
{
struct mtop mt_com;
struct mtop mt_com{};
unsigned int i;
bool first = true;

Expand Down

0 comments on commit f8918d9

Please sign in to comment.