Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix some Coverity issues.
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 6cb6418 commit baeea8b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 50 deletions.
72 changes: 34 additions & 38 deletions src/stored/label.c
Expand Up @@ -390,53 +390,49 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
goto bail_out;
}

for ( ;; ) {
empty_block(block);
if (!dev->rewind(dcr)) {
Dmsg2(130, "Bad status on %s from rewind: ERR=%s\n", dev->print_name(), dev->print_errmsg());
if (!forge_on) {
goto bail_out;
}
empty_block(block);
if (!dev->rewind(dcr)) {
Dmsg2(130, "Bad status on %s from rewind: ERR=%s\n", dev->print_name(), dev->print_errmsg());
if (!forge_on) {
goto bail_out;
}
}

/* Temporarily mark in append state to enable writing */
dev->set_append();

/* Temporarily mark in append state to enable writing */
dev->set_append();

/* Create PRE_LABEL */
create_volume_label(dev, VolName, PoolName);
/* Create PRE_LABEL */
create_volume_label(dev, VolName, PoolName);

/*
* If we have already detected an ANSI label, re-read it
* to skip past it. Otherwise, we write a new one if
* so requested.
*/
if (dev->label_type != B_BAREOS_LABEL) {
if (read_ansi_ibm_label(dcr) != VOL_OK) {
dev->rewind(dcr);
goto bail_out;
}
} else if (!write_ansi_ibm_labels(dcr, ANSI_VOL_LABEL, VolName)) {
/*
* If we have already detected an ANSI label, re-read it
* to skip past it. Otherwise, we write a new one if
* so requested.
*/
if (dev->label_type != B_BAREOS_LABEL) {
if (read_ansi_ibm_label(dcr) != VOL_OK) {
dev->rewind(dcr);
goto bail_out;
}
} else if (!write_ansi_ibm_labels(dcr, ANSI_VOL_LABEL, VolName)) {
goto bail_out;
}

create_volume_label_record(dcr, dev, dcr->rec);
dcr->rec->Stream = 0;
dcr->rec->maskedStream = 0;
create_volume_label_record(dcr, dev, dcr->rec);
dcr->rec->Stream = 0;
dcr->rec->maskedStream = 0;

if (!write_record_to_block(dcr, dcr->rec)) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
} else {
Dmsg2(130, "Wrote label of %d bytes to %s\n", dcr->rec->data_len, dev->print_name());
}
if (!write_record_to_block(dcr, dcr->rec)) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
} else {
Dmsg2(130, "Wrote label of %d bytes to %s\n", dcr->rec->data_len, dev->print_name());
}

Dmsg0(130, "Call write_block_to_dev()\n");
if (!dcr->write_block_to_dev()) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
}
break;
Dmsg0(130, "Call write_block_to_dev()\n");
if (!dcr->write_block_to_dev()) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
}
dev = dcr->dev;

Expand Down
12 changes: 2 additions & 10 deletions src/stored/reserve.c
Expand Up @@ -1119,8 +1119,7 @@ static int can_reserve_drive(DCR *dcr, RCTX &rctx)
}

/*
* Check if the device is in append mode with writers (i.e.
* available if pool is the same).
* Check if the device is in append mode with writers (i.e. available if pool is the same).
*/
if (dev->can_append() || dev->num_writers > 0) {
return is_pool_ok(dcr);
Expand All @@ -1130,18 +1129,11 @@ static int can_reserve_drive(DCR *dcr, RCTX &rctx)
jcr->JobId, dev->print_name());
queue_reserve_message(jcr);
Jmsg0(jcr, M_FATAL, 0, _("Logic error!!!! Should not get here.\n"));

return -1; /* error, should not get here */
}
Mmsg(jcr->errmsg, _("3911 JobId=%u failed reserve drive %s.\n"),
jcr->JobId, dev->print_name());
queue_reserve_message(jcr);
Dmsg1(dbglvl, "Failed: No reserve %s\n", dev->print_name());
return 0;
}




/*
* Queue a reservation error or failure message for this jcr
*/
Expand Down
3 changes: 1 addition & 2 deletions src/stored/stored_conf.c
Expand Up @@ -463,10 +463,9 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
sendit(sock, "NDMP DMA: name=%s\n", res->res_dir.hdr.name);
break;
case R_STORAGE:
sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d HB=%s\n",
sendit(sock, "Storage: name=%s SDaddr=%s HB=%s\n",
res->res_store.hdr.name,
NPRT(get_first_address(res->res_store.SDaddrs, buf, sizeof(buf))),
get_first_port_host_order(res->res_store.SDaddrs),
edit_utime(res->res_store.heartbeat_interval, buf, sizeof(buf)));
if (res->res_store.SDaddrs) {
foreach_dlist(addr, res->res_store.SDaddrs) {
Expand Down

0 comments on commit baeea8b

Please sign in to comment.