Skip to content

Commit

Permalink
Use explicitly uint32_t in btape for filling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 54379b3 commit 2a15a37
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/stored/btape.c
Expand Up @@ -1133,9 +1133,8 @@ static bool write_two_files()
{
DEV_BLOCK *block;
DEV_RECORD *rec;
int len, j;
unsigned int i;
int *p;
uint32_t len;
uint32_t *p;
bool rc = false; /* bad return code */
DEVICE *dev = dcr->dev;

Expand All @@ -1161,16 +1160,16 @@ static bool write_two_files()
rec = new_record();
rec->data = check_pool_memory_size(rec->data, block->buf_len);
rec->data_len = block->buf_len-100;
len = rec->data_len/sizeof(i);
len = rec->data_len / sizeof(uint32_t);

if (!dev->rewind(dcr)) {
Pmsg1(0, _("Bad status from rewind. ERR=%s\n"), dev->bstrerror());
goto bail_out;
}

for (i=1; i<=num_recs; i++) {
p = (int *)rec->data;
for (j=0; j<len; j++) {
for (uint32_t i = 1; i <= num_recs; i++) {
p = (uint32_t *)rec->data;
for (uint32_t j = 0; j < len; j++) {
*p++ = i;
}
if (!write_record_to_block(dcr, rec)) {
Expand All @@ -1184,9 +1183,9 @@ static bool write_two_files()
}
Pmsg2(0, _("Wrote %d blocks of %d bytes.\n"), num_recs, rec->data_len);
weofcmd();
for (i=num_recs+1; i<=2*num_recs; i++) {
p = (int *)rec->data;
for (j=0; j<len; j++) {
for (uint32_t i = num_recs + 1; i <= 2 * num_recs; i++) {
p = (uint32_t *)rec->data;
for (uint32_t j = 0; j < len; j++) {
*p++ = i;
}
if (!write_record_to_block(dcr, rec)) {
Expand All @@ -1210,22 +1209,22 @@ static bool write_two_files()
if (!rc) {
exit_code = 1;
}
return rc;

return rc;
}

/*
* This test writes Bareos blocks to the tape in
* several files. It then rewinds the tape and attepts
* to read these blocks back checking the data.
* several files. It then rewinds the tape and attepts
* to read these blocks back checking the data.
*/
static bool write_read_test()
{
DEV_BLOCK *block;
DEV_RECORD *rec;
bool rc = false;
int len, i, j;
int *p;
uint32_t len;
uint32_t *p;

rec = new_record();

Expand All @@ -1244,11 +1243,13 @@ static bool write_read_test()
}

rec->data = check_pool_memory_size(rec->data, block->buf_len);
rec->data_len = block->buf_len-100;
len = rec->data_len/sizeof(i);
rec->data_len = block->buf_len - 100;
len = rec->data_len / sizeof(uint32_t);

/* Now read it back */
for (i=1; i<=2*num_recs; i++) {
/*
* Now read it back
*/
for (uint32_t i = 1; i <= 2 * num_recs; i++) {
read_again:
if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
berrno be;
Expand All @@ -1267,16 +1268,15 @@ static bool write_read_test()
Pmsg2(0, _("Read record failed. Block %d! ERR=%s\n"), i, be.bstrerror(dev->dev_errno));
goto bail_out;
}
p = (int *)rec->data;
for (j=0; j<len; j++) {
p = (uint32_t *)rec->data;
for (uint32_t j = 0; j < len; j++) {
if (*p != i) {
Pmsg3(0, _("Bad data in record. Expected %d, got %d at byte %d. Test failed!\n"),
i, *p, j);
Pmsg3(0, _("Bad data in record. Expected %d, got %d at byte %d. Test failed!\n"), i, *p, j);
goto bail_out;
}
p++;
}
if (i == num_recs || i == 2*num_recs) {
if (i == num_recs || i == 2 * num_recs) {
Pmsg1(-1, _("%d blocks re-read correctly.\n"), num_recs);
}
}
Expand All @@ -1293,8 +1293,8 @@ static bool write_read_test()

/*
* This test writes Bareos blocks to the tape in
* several files. It then rewinds the tape and attepts
* to read these blocks back checking the data.
* several files. It then rewinds the tape and attepts
* to read these blocks back checking the data.
*/
static bool position_test()
{
Expand Down

0 comments on commit 2a15a37

Please sign in to comment.