Skip to content

Commit cf68b03

Browse files
committed
libnvme: read-only host attributes
Some host attributes are fixed for the lifetime of the host, so once established they cannot be changed. Consequently it's pointless to have a 'setter' function as this would not do what's expected. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent ccf5da0 commit cf68b03

5 files changed

Lines changed: 4 additions & 32 deletions

File tree

libnvme/src/accessors.ld

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ LIBNVME_ACCESSORS_3 {
8282
nvme_subsystem_get_iopolicy;
8383
nvme_subsystem_set_iopolicy;
8484
nvme_host_get_hostnqn;
85-
nvme_host_set_hostnqn;
8685
nvme_host_get_hostid;
87-
nvme_host_set_hostid;
8886
nvme_host_get_dhchap_host_key;
8987
nvme_host_set_dhchap_host_key;
9088
nvme_host_get_hostsymname;

libnvme/src/nvme/accessors.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,23 +422,11 @@ const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p)
422422
* Accessors for: struct nvme_host
423423
****************************************************************************/
424424

425-
void nvme_host_set_hostnqn(struct nvme_host *p, const char *hostnqn)
426-
{
427-
free(p->hostnqn);
428-
p->hostnqn = hostnqn ? strdup(hostnqn) : NULL;
429-
}
430-
431425
const char *nvme_host_get_hostnqn(const struct nvme_host *p)
432426
{
433427
return p->hostnqn;
434428
}
435429

436-
void nvme_host_set_hostid(struct nvme_host *p, const char *hostid)
437-
{
438-
free(p->hostid);
439-
p->hostid = hostid ? strdup(hostid) : NULL;
440-
}
441-
442430
const char *nvme_host_get_hostid(const struct nvme_host *p)
443431
{
444432
return p->hostid;

libnvme/src/nvme/accessors.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,6 @@ const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p);
610610
* Accessors for: struct nvme_host
611611
****************************************************************************/
612612

613-
/**
614-
* nvme_host_set_hostnqn() - Set hostnqn.
615-
* @p: The &struct nvme_host instance to update.
616-
* @hostnqn: New string; a copy is stored. Pass NULL to clear.
617-
*/
618-
void nvme_host_set_hostnqn(struct nvme_host *p, const char *hostnqn);
619-
620613
/**
621614
* nvme_host_get_hostnqn() - Get hostnqn.
622615
* @p: The &struct nvme_host instance to query.
@@ -625,13 +618,6 @@ void nvme_host_set_hostnqn(struct nvme_host *p, const char *hostnqn);
625618
*/
626619
const char *nvme_host_get_hostnqn(const struct nvme_host *p);
627620

628-
/**
629-
* nvme_host_set_hostid() - Set hostid.
630-
* @p: The &struct nvme_host instance to update.
631-
* @hostid: New string; a copy is stored. Pass NULL to clear.
632-
*/
633-
void nvme_host_set_hostid(struct nvme_host *p, const char *hostid);
634-
635621
/**
636622
* nvme_host_get_hostid() - Get hostid.
637623
* @p: The &struct nvme_host instance to query.

libnvme/src/nvme/private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ struct nvme_host {
238238
struct list_head subsystems;
239239
struct nvme_global_ctx *ctx;
240240

241-
char *hostnqn;
242-
char *hostid;
241+
const char *hostnqn;
242+
const char *hostid;
243243
char *dhchap_host_key;
244244
char *hostsymname;
245245
bool pdc_enabled;

libnvme/src/nvme/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,8 @@ void __nvme_free_host(struct nvme_host *h)
599599
list_del_init(&h->entry);
600600
nvme_for_each_subsystem_safe(h, s, _s)
601601
__nvme_free_subsystem(s);
602-
free(h->hostnqn);
603-
free(h->hostid);
602+
free((char *)h->hostnqn);
603+
free((char *)h->hostid);
604604
free(h->dhchap_host_key);
605605
nvme_host_set_hostsymname(h, NULL);
606606
free(h);

0 commit comments

Comments
 (0)