Skip to content

Commit 7651f89

Browse files
committed
libnvme: rename accessor functions for boolean value to 'nvme_ctrl_is_XXX'
When checking a boolean flag we should name the accessor functions 'nvme_ctrl_is_XXX' to avoid the rather awkward 'nvme_ctrl_get_XXX'. And we should drop the duplicate functions from tree.c Signed-off-by: Hannes Reinecke <[email protected]>
1 parent e448ef0 commit 7651f89

5 files changed

Lines changed: 20 additions & 75 deletions

File tree

libnvme/src/nvme/accessors.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void nvme_ctrl_set_discovery_ctrl(struct nvme_ctrl *p, bool discovery_ctrl)
407407
p->discovery_ctrl = discovery_ctrl;
408408
}
409409

410-
bool nvme_ctrl_get_discovery_ctrl(const struct nvme_ctrl *p)
410+
bool nvme_ctrl_is_discovery_ctrl(const struct nvme_ctrl *p)
411411
{
412412
return p->discovery_ctrl;
413413
}
@@ -419,7 +419,7 @@ void nvme_ctrl_set_unique_discovery_ctrl(
419419
p->unique_discovery_ctrl = unique_discovery_ctrl;
420420
}
421421

422-
bool nvme_ctrl_get_unique_discovery_ctrl(const struct nvme_ctrl *p)
422+
bool nvme_ctrl_is_unique_discovery_ctrl(const struct nvme_ctrl *p)
423423
{
424424
return p->unique_discovery_ctrl;
425425
}
@@ -429,7 +429,7 @@ void nvme_ctrl_set_discovered(struct nvme_ctrl *p, bool discovered)
429429
p->discovered = discovered;
430430
}
431431

432-
bool nvme_ctrl_get_discovered(const struct nvme_ctrl *p)
432+
bool nvme_ctrl_is_discovered(const struct nvme_ctrl *p)
433433
{
434434
return p->discovered;
435435
}
@@ -439,7 +439,7 @@ void nvme_ctrl_set_persistent(struct nvme_ctrl *p, bool persistent)
439439
p->persistent = persistent;
440440
}
441441

442-
bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p)
442+
bool nvme_ctrl_is_persistent(const struct nvme_ctrl *p)
443443
{
444444
return p->persistent;
445445
}

libnvme/src/nvme/accessors.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,22 +558,22 @@ void nvme_ctrl_set_host_iface(struct nvme_ctrl *p, const char *host_iface);
558558
const char *nvme_ctrl_get_host_iface(const struct nvme_ctrl *p);
559559

560560
/**
561-
* nvme_ctrl_set_discovery_ctrl() - Set discovery_ctrl.
561+
* nvme_ctrl_set_discovery_ctrl() - Set discovery flag.
562562
* @p: The &struct nvme_ctrl instance to update.
563563
* @discovery_ctrl: Value to assign to the discovery_ctrl field.
564564
*/
565565
void nvme_ctrl_set_discovery_ctrl(struct nvme_ctrl *p, bool discovery_ctrl);
566566

567567
/**
568-
* nvme_ctrl_get_discovery_ctrl() - Get discovery_ctrl.
568+
* nvme_ctrl_is_discovery_ctrl() - Check discovery flag.
569569
* @p: The &struct nvme_ctrl instance to query.
570570
*
571571
* Return: The value of the discovery_ctrl field.
572572
*/
573-
bool nvme_ctrl_get_discovery_ctrl(const struct nvme_ctrl *p);
573+
bool nvme_ctrl_is_discovery_ctrl(const struct nvme_ctrl *p);
574574

575575
/**
576-
* nvme_ctrl_set_unique_discovery_ctrl() - Set unique_discovery_ctrl.
576+
* nvme_ctrl_set_unique_discovery_ctrl() - Set unique_discovery flag.
577577
* @p: The &struct nvme_ctrl instance to update.
578578
* @unique_discovery_ctrl: Value to assign to the unique_discovery_ctrl field.
579579
*/
@@ -582,42 +582,42 @@ void nvme_ctrl_set_unique_discovery_ctrl(
582582
bool unique_discovery_ctrl);
583583

584584
/**
585-
* nvme_ctrl_get_unique_discovery_ctrl() - Get unique_discovery_ctrl.
585+
* nvme_ctrl_is_unique_discovery_ctrl() - Check unique_discovery flag.
586586
* @p: The &struct nvme_ctrl instance to query.
587587
*
588588
* Return: The value of the unique_discovery_ctrl field.
589589
*/
590-
bool nvme_ctrl_get_unique_discovery_ctrl(const struct nvme_ctrl *p);
590+
bool nvme_ctrl_is_unique_discovery_ctrl(const struct nvme_ctrl *p);
591591

592592
/**
593-
* nvme_ctrl_set_discovered() - Set discovered.
593+
* nvme_ctrl_set_discovered() - Set discovered flag.
594594
* @p: The &struct nvme_ctrl instance to update.
595595
* @discovered: Value to assign to the discovered field.
596596
*/
597597
void nvme_ctrl_set_discovered(struct nvme_ctrl *p, bool discovered);
598598

599599
/**
600-
* nvme_ctrl_get_discovered() - Get discovered.
600+
* nvme_ctrl_is_discovered() - Check discovered flag.
601601
* @p: The &struct nvme_ctrl instance to query.
602602
*
603603
* Return: The value of the discovered field.
604604
*/
605-
bool nvme_ctrl_get_discovered(const struct nvme_ctrl *p);
605+
bool nvme_ctrl_is_discovered(const struct nvme_ctrl *p);
606606

607607
/**
608-
* nvme_ctrl_set_persistent() - Set persistent.
608+
* nvme_ctrl_set_persistent() - Set persistent flag.
609609
* @p: The &struct nvme_ctrl instance to update.
610610
* @persistent: Value to assign to the persistent field.
611611
*/
612612
void nvme_ctrl_set_persistent(struct nvme_ctrl *p, bool persistent);
613613

614614
/**
615-
* nvme_ctrl_get_persistent() - Get persistent.
615+
* nvme_ctrl_is_persistent() - Check persistent flag.
616616
* @p: The &struct nvme_ctrl instance to query.
617617
*
618618
* Return: The value of the persistent field.
619619
*/
620-
bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p);
620+
bool nvme_ctrl_is_persistent(const struct nvme_ctrl *p);
621621

622622
/****************************************************************************
623623
* Accessors for: struct nvme_subsystem

libnvme/src/nvme/accessors.ld

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ LIBNVME_ACCESSORS_3 {
6969
nvme_ctrl_set_host_traddr;
7070
nvme_ctrl_get_host_iface;
7171
nvme_ctrl_set_host_iface;
72-
nvme_ctrl_get_discovery_ctrl;
72+
nvme_ctrl_is_discovery_ctrl;
7373
nvme_ctrl_set_discovery_ctrl;
74-
nvme_ctrl_get_unique_discovery_ctrl;
74+
nvme_ctrl_is_unique_discovery_ctrl;
7575
nvme_ctrl_set_unique_discovery_ctrl;
76-
nvme_ctrl_get_discovered;
76+
nvme_ctrl_is_discovered;
7777
nvme_ctrl_set_discovered;
78-
nvme_ctrl_get_persistent;
78+
nvme_ctrl_is_persistent;
7979
nvme_ctrl_set_persistent;
8080
nvme_subsystem_get_name;
8181
nvme_subsystem_set_name;

libnvme/src/nvme/tree.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -955,26 +955,6 @@ struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c)
955955
return &c->cfg;
956956
}
957957

958-
bool nvme_ctrl_is_discovered(nvme_ctrl_t c)
959-
{
960-
return c->discovered;
961-
}
962-
963-
bool nvme_ctrl_is_persistent(nvme_ctrl_t c)
964-
{
965-
return c->persistent;
966-
}
967-
968-
bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c)
969-
{
970-
return c->discovery_ctrl;
971-
}
972-
973-
bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c)
974-
{
975-
return c->unique_discovery_ctrl;
976-
}
977-
978958
int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id)
979959
{
980960
struct nvme_transport_handle *hdl = nvme_ctrl_get_transport_handle(c);

libnvme/src/nvme/tree.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -775,41 +775,6 @@ const char *nvme_ns_head_get_sysfs_dir(nvme_ns_head_t head);
775775
*/
776776
struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c);
777777

778-
/**
779-
* nvme_ctrl_is_discovered() - Returns the value of the 'discovered' flag
780-
* @c: Controller instance
781-
*
782-
* Return: Value of the 'discovered' flag of @c
783-
*/
784-
bool nvme_ctrl_is_discovered(nvme_ctrl_t c);
785-
786-
/**
787-
* nvme_ctrl_is_persistent() - Returns the value of the 'persistent' flag
788-
* @c: Controller instance
789-
*
790-
* Return: Value of the 'persistent' flag of @c
791-
*/
792-
bool nvme_ctrl_is_persistent(nvme_ctrl_t c);
793-
794-
/**
795-
* nvme_ctrl_is_discovery_ctrl() - Check the 'discovery_ctrl' flag
796-
* @c: Controller to be checked
797-
*
798-
* Returns the value of the 'discovery_ctrl' flag which specifies whether
799-
* @c connects to a discovery subsystem.
800-
*
801-
* Return: Value of the 'discover_ctrl' flag
802-
*/
803-
bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c);
804-
805-
/**
806-
* nvme_ctrl_is_unique_discovery_ctrl() - Check the 'unique_discovery_ctrl' flag
807-
* @c: Controller to be checked
808-
*
809-
* Return: Value of the 'unique_discovery_ctrl' flag
810-
*/
811-
bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c);
812-
813778
/**
814779
* nvme_ctrl_identify() - Issues an 'identify controller' command
815780
* @c: Controller instance

0 commit comments

Comments
 (0)