Skip to content

Commit 5eb2413

Browse files
ikegami-tigaw
authored andcommitted
libnvme: replace fprintf to nvme_msg
Since the struct nvme_global_ctx is available. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 9cae9d1 commit 5eb2413

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

libnvme/src/nvme/fabrics.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,8 +2376,9 @@ static int nvmf_create_discovery_ctrl(struct nvme_global_ctx *ctx,
23762376
/* Find out the name of discovery controller */
23772377
ret = nvme_ctrl_identify(c, id);
23782378
if (ret) {
2379-
fprintf(stderr, "failed to identify controller, error %s\n",
2380-
nvme_strerror(-ret));
2379+
nvme_msg(ctx, LOG_ERR,
2380+
"failed to identify controller, error %s\n",
2381+
nvme_strerror(-ret));
23812382
nvme_disconnect_ctrl(c);
23822383
nvme_free_ctrl(c);
23832384
return ret;
@@ -2431,16 +2432,16 @@ int _discovery_config_json(struct nvme_global_ctx *ctx,
24312432
/* ignore if no host_traddr for fc */
24322433
if (!strcmp(transport, "fc")) {
24332434
if (!host_traddr) {
2434-
fprintf(stderr, "host_traddr required for fc\n");
2435+
nvme_msg(ctx, LOG_ERR, "host_traddr required for fc\n");
24352436
return 0;
24362437
}
24372438
}
24382439

24392440
/* ignore if host_iface set for any transport other than tcp */
24402441
if (!strcmp(transport, "rdma") || !strcmp(transport, "fc")) {
24412442
if (host_iface) {
2442-
fprintf(stderr,
2443-
"host_iface not permitted for rdma or fc\n");
2443+
nvme_msg(ctx, LOG_ERR,
2444+
"host_iface not permitted for rdma or fc\n");
24442445
return 0;
24452446
}
24462447
}
@@ -2580,11 +2581,11 @@ int nvmf_connect_config_json(struct nvme_global_ctx *ctx,
25802581
if (err == -ENVME_CONNECT_ALREADY)
25812582
continue;
25822583

2583-
fprintf(stderr,
2584-
"failed to connect to hostnqn=%s,nqn=%s,%s\n",
2585-
nvme_host_get_hostnqn(h),
2586-
nvme_subsystem_get_name(s),
2587-
nvme_ctrl_get_address(c));
2584+
nvme_msg(ctx, LOG_ERR,
2585+
"failed to connect to hostnqn=%s,nqn=%s,%s\n",
2586+
nvme_host_get_hostnqn(h),
2587+
nvme_subsystem_get_name(s),
2588+
nvme_ctrl_get_address(c));
25882589

25892590
if (!ret)
25902591
ret = err;
@@ -3233,8 +3234,9 @@ static int nvmf_create_discover_ctrl(struct nvme_global_ctx *ctx,
32333234
/* Find out the name of discovery controller */
32343235
ret = nvme_ctrl_identify(c, id);
32353236
if (ret) {
3236-
fprintf(stderr, "failed to identify controller, error %s\n",
3237-
nvme_strerror(-ret));
3237+
nvme_msg(ctx, LOG_ERR,
3238+
"failed to identify controller, error %s\n",
3239+
nvme_strerror(-ret));
32383240
nvme_disconnect_ctrl(c);
32393241
nvme_free_ctrl(c);
32403242
return ret;

libnvme/src/nvme/linux.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ int nvme_get_uuid_list(struct nvme_transport_handle *hdl, struct nvme_id_uuid_li
326326
nvme_init_identify_ctrl(&cmd, &ctrl);
327327
err = nvme_submit_admin_passthru(hdl, &cmd);
328328
if (err) {
329-
fprintf(stderr, "ERROR: nvme_identify_ctrl() failed 0x%x\n", err);
329+
nvme_msg(hdl->ctx, LOG_ERR,
330+
"ERROR: nvme_identify_ctrl() failed 0x%x\n", err);
330331
return err;
331332
}
332333

0 commit comments

Comments
 (0)