Replace bzero() with memset()
This commit is contained in:
@@ -412,7 +412,7 @@ int main(int argc _U_, char *argv[] _U_)
|
||||
|
||||
printf("iscsi client\n");
|
||||
|
||||
bzero(&clnt, sizeof(clnt));
|
||||
memset(&clnt, 0, sizeof(clnt));
|
||||
|
||||
iscsi = iscsi_create_context("iqn.2002-10.com.ronnie:client");
|
||||
if (iscsi == NULL) {
|
||||
|
||||
@@ -141,7 +141,7 @@ iscsi_process_text_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
||||
iscsi_free_discovery_addresses(targets);
|
||||
return -1;
|
||||
}
|
||||
bzero(target, sizeof(struct iscsi_discovery_address));
|
||||
memset(target, 0, sizeof(struct iscsi_discovery_address));
|
||||
target->target_name = strdup((char *)ptr+11);
|
||||
if (target->target_name == NULL) {
|
||||
iscsi_set_error(iscsi, "Failed to allocate "
|
||||
|
||||
@@ -44,7 +44,7 @@ iscsi_create_context(const char *initiator_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(iscsi, sizeof(struct iscsi_context));
|
||||
memset(iscsi, 0, sizeof(struct iscsi_context));
|
||||
|
||||
iscsi->initiator_name = strdup(initiator_name);
|
||||
if (iscsi->initiator_name == NULL) {
|
||||
|
||||
@@ -36,7 +36,7 @@ iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opcode
|
||||
iscsi_set_error(iscsi, "failed to allocate pdu");
|
||||
return NULL;
|
||||
}
|
||||
bzero(pdu, sizeof(struct iscsi_pdu));
|
||||
memset(pdu, 0, sizeof(struct iscsi_pdu));
|
||||
|
||||
pdu->outdata.size = ISCSI_HEADER_SIZE;
|
||||
pdu->outdata.data = malloc(pdu->outdata.size);
|
||||
@@ -46,7 +46,7 @@ iscsi_allocate_pdu_with_itt_flags(struct iscsi_context *iscsi, enum iscsi_opcode
|
||||
free(pdu);
|
||||
return NULL;
|
||||
}
|
||||
bzero(pdu->outdata.data, pdu->outdata.size);
|
||||
memset(pdu->outdata.data, 0, pdu->outdata.size);
|
||||
|
||||
/* opcode */
|
||||
pdu->outdata.data[0] = opcode;
|
||||
@@ -130,7 +130,7 @@ iscsi_add_data(struct iscsi_context *iscsi, struct iscsi_data *data,
|
||||
memcpy(buf + data->size, dptr, dsize);
|
||||
if (len != aligned) {
|
||||
/* zero out any padding at the end */
|
||||
bzero(buf+len, aligned-len);
|
||||
memset(buf+len, 0, aligned-len);
|
||||
}
|
||||
|
||||
free(data->data);
|
||||
@@ -359,7 +359,7 @@ iscsi_pdu_set_bufferoffset(struct iscsi_pdu *pdu, uint32_t bufferoffset)
|
||||
void
|
||||
iscsi_pdu_set_cdb(struct iscsi_pdu *pdu, struct scsi_task *task)
|
||||
{
|
||||
bzero(&pdu->outdata.data[32], 16);
|
||||
memset(&pdu->outdata.data[32], 0, 16);
|
||||
memcpy(&pdu->outdata.data[32], task->cdb, task->cdb_size);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
|
||||
scsi_free_scsi_task(task);
|
||||
return -1;
|
||||
}
|
||||
bzero(scsi_cbdata, sizeof(struct iscsi_scsi_cbdata));
|
||||
memset(scsi_cbdata, 0, sizeof(struct iscsi_scsi_cbdata));
|
||||
scsi_cbdata->task = task;
|
||||
scsi_cbdata->callback = cb;
|
||||
scsi_cbdata->private_data = private_data;
|
||||
|
||||
@@ -57,13 +57,13 @@ scsi_malloc(struct scsi_task *task, size_t size)
|
||||
if (mem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
bzero(mem, sizeof(struct scsi_allocated_memory));
|
||||
memset(mem, 0, sizeof(struct scsi_allocated_memory));
|
||||
mem->ptr = malloc(size);
|
||||
if (mem->ptr == NULL) {
|
||||
free(mem);
|
||||
return NULL;
|
||||
}
|
||||
bzero(mem->ptr, size);
|
||||
memset(mem->ptr, 0, size);
|
||||
SLIST_ADD(&task->mem, mem);
|
||||
return mem->ptr;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ scsi_cdb_testunitready(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_TESTUNITREADY;
|
||||
|
||||
task->cdb_size = 6;
|
||||
@@ -151,7 +151,7 @@ scsi_reportluns_cdb(int report_type, int alloc_len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_REPORTLUNS;
|
||||
task->cdb[2] = report_type;
|
||||
*(uint32_t *)&task->cdb[6] = htonl(alloc_len);
|
||||
@@ -228,7 +228,7 @@ scsi_cdb_readcapacity10(int lba, int pmi)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READCAPACITY10;
|
||||
|
||||
*(uint32_t *)&task->cdb[2] = htonl(lba);
|
||||
@@ -296,7 +296,7 @@ scsi_cdb_inquiry(int evpd, int page_code, int alloc_len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_INQUIRY;
|
||||
|
||||
if (evpd) {
|
||||
@@ -516,7 +516,7 @@ scsi_cdb_read10(int lba, int xferlen, int blocksize)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_READ10;
|
||||
|
||||
*(uint32_t *)&task->cdb[2] = htonl(lba);
|
||||
@@ -542,7 +542,7 @@ scsi_cdb_write10(int lba, int xferlen, int fua, int fuanv, int blocksize)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_WRITE10;
|
||||
|
||||
if (fua) {
|
||||
@@ -579,7 +579,7 @@ scsi_cdb_modesense6(int dbd, enum scsi_modesense_page_control pc,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_MODESENSE6;
|
||||
|
||||
if (dbd) {
|
||||
@@ -629,7 +629,7 @@ scsi_cdb_synchronizecache10(int lba, int num_blocks, int syncnv, int immed)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bzero(task, sizeof(struct scsi_task));
|
||||
memset(task, 0, sizeof(struct scsi_task));
|
||||
task->cdb[0] = SCSI_OPCODE_SYNCHRONIZECACHE10;
|
||||
|
||||
if (syncnv) {
|
||||
|
||||
@@ -185,7 +185,7 @@ iscsi_read_from_socket(struct iscsi_context *iscsi)
|
||||
iscsi_set_error(iscsi, "Out-of-memory: failed to malloc iscsi_in_pdu");
|
||||
return -1;
|
||||
}
|
||||
bzero(iscsi->incoming, sizeof(struct iscsi_in_pdu));
|
||||
memset(iscsi->incoming, 0, sizeof(struct iscsi_in_pdu));
|
||||
}
|
||||
in = iscsi->incoming;
|
||||
|
||||
|
||||
20
lib/sync.c
20
lib/sync.c
@@ -73,7 +73,7 @@ iscsi_connect_sync(struct iscsi_context *iscsi, const char *portal)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_connect_async(iscsi, portal,
|
||||
iscsi_sync_cb, &state) != 0) {
|
||||
@@ -94,7 +94,7 @@ iscsi_full_connect_sync(struct iscsi_context *iscsi,
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_full_connect_async(iscsi, portal, lun,
|
||||
iscsi_sync_cb, &state) != 0) {
|
||||
@@ -113,7 +113,7 @@ int iscsi_login_sync(struct iscsi_context *iscsi)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_login_async(iscsi, iscsi_sync_cb, &state) != 0) {
|
||||
iscsi_set_error(iscsi, "Failed to login. %s",
|
||||
@@ -130,7 +130,7 @@ int iscsi_logout_sync(struct iscsi_context *iscsi)
|
||||
{
|
||||
struct iscsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_logout_async(iscsi, iscsi_sync_cb, &state) != 0) {
|
||||
iscsi_set_error(iscsi, "Failed to start logout() %s",
|
||||
@@ -167,7 +167,7 @@ iscsi_reportluns_sync(struct iscsi_context *iscsi, int report_type,
|
||||
{
|
||||
struct scsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_reportluns_async(iscsi, report_type, alloc_len,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
@@ -186,7 +186,7 @@ iscsi_testunitready_sync(struct iscsi_context *iscsi, int lun)
|
||||
{
|
||||
struct scsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_testunitready_async(iscsi, lun,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
@@ -206,7 +206,7 @@ iscsi_inquiry_sync(struct iscsi_context *iscsi, int lun, int evpd,
|
||||
{
|
||||
struct scsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_inquiry_async(iscsi, lun, evpd, page_code, maxsize,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
@@ -225,7 +225,7 @@ iscsi_readcapacity10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
{
|
||||
struct scsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_readcapacity10_async(iscsi, lun, lba, pmi,
|
||||
scsi_sync_cb, &state) != 0) {
|
||||
@@ -245,7 +245,7 @@ iscsi_synchronizecache10_sync(struct iscsi_context *iscsi, int lun, int lba,
|
||||
{
|
||||
struct scsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_synchronizecache10_async(iscsi, lun, lba, num_blocks,
|
||||
syncnv, immed,
|
||||
@@ -266,7 +266,7 @@ iscsi_scsi_command_sync(struct iscsi_context *iscsi, int lun,
|
||||
{
|
||||
struct scsi_sync_state state;
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
if (iscsi_scsi_command_async(iscsi, lun, task,
|
||||
scsi_sync_cb, data, &state) != 0) {
|
||||
|
||||
@@ -281,7 +281,7 @@ int main(int argc, const char *argv[])
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
||||
bzero(&state, sizeof(state));
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_POSIXMEHARDER);
|
||||
if ((res = poptGetNextOpt(pc)) < -1) {
|
||||
|
||||
Reference in New Issue
Block a user