Skip to content

Commit 909fc70

Browse files
committed
libnvme: read-only subsystem accessors
Most subsystem attributes are fixed for the lifetime of the subsystem, 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 179d832 commit 909fc70

3 files changed

Lines changed: 7 additions & 112 deletions

File tree

libnvme/src/nvme/accessors.c

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -364,84 +364,36 @@ bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p)
364364
* Accessors for: struct nvme_subsystem
365365
****************************************************************************/
366366

367-
void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name)
368-
{
369-
free(p->name);
370-
p->name = name ? strdup(name) : NULL;
371-
}
372-
373367
const char *nvme_subsystem_get_name(const struct nvme_subsystem *p)
374368
{
375369
return p->name;
376370
}
377371

378-
void nvme_subsystem_set_sysfs_dir(
379-
struct nvme_subsystem *p,
380-
const char *sysfs_dir)
381-
{
382-
free(p->sysfs_dir);
383-
p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL;
384-
}
385-
386372
const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p)
387373
{
388374
return p->sysfs_dir;
389375
}
390376

391-
void nvme_subsystem_set_subsysnqn(
392-
struct nvme_subsystem *p,
393-
const char *subsysnqn)
394-
{
395-
free(p->subsysnqn);
396-
p->subsysnqn = subsysnqn ? strdup(subsysnqn) : NULL;
397-
}
398-
399377
const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p)
400378
{
401379
return p->subsysnqn;
402380
}
403381

404-
void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model)
405-
{
406-
free(p->model);
407-
p->model = model ? strdup(model) : NULL;
408-
}
409-
410382
const char *nvme_subsystem_get_model(const struct nvme_subsystem *p)
411383
{
412384
return p->model;
413385
}
414386

415-
void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial)
416-
{
417-
free(p->serial);
418-
p->serial = serial ? strdup(serial) : NULL;
419-
}
420-
421387
const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p)
422388
{
423389
return p->serial;
424390
}
425391

426-
void nvme_subsystem_set_firmware(struct nvme_subsystem *p, const char *firmware)
427-
{
428-
free(p->firmware);
429-
p->firmware = firmware ? strdup(firmware) : NULL;
430-
}
431-
432392
const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p)
433393
{
434394
return p->firmware;
435395
}
436396

437-
void nvme_subsystem_set_subsystype(
438-
struct nvme_subsystem *p,
439-
const char *subsystype)
440-
{
441-
free(p->subsystype);
442-
p->subsystype = subsystype ? strdup(subsystype) : NULL;
443-
}
444-
445397
const char *nvme_subsystem_get_subsystype(const struct nvme_subsystem *p)
446398
{
447399
return p->subsystype;

libnvme/src/nvme/accessors.h

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,6 @@ bool nvme_ctrl_get_persistent(const struct nvme_ctrl *p);
524524
* Accessors for: struct nvme_subsystem
525525
****************************************************************************/
526526

527-
/**
528-
* nvme_subsystem_set_name() - Set name.
529-
* @p: The &struct nvme_subsystem instance to update.
530-
* @name: New string; a copy is stored. Pass NULL to clear.
531-
*/
532-
void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name);
533-
534527
/**
535528
* nvme_subsystem_get_name() - Get name.
536529
* @p: The &struct nvme_subsystem instance to query.
@@ -539,15 +532,6 @@ void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name);
539532
*/
540533
const char *nvme_subsystem_get_name(const struct nvme_subsystem *p);
541534

542-
/**
543-
* nvme_subsystem_set_sysfs_dir() - Set sysfs_dir.
544-
* @p: The &struct nvme_subsystem instance to update.
545-
* @sysfs_dir: New string; a copy is stored. Pass NULL to clear.
546-
*/
547-
void nvme_subsystem_set_sysfs_dir(
548-
struct nvme_subsystem *p,
549-
const char *sysfs_dir);
550-
551535
/**
552536
* nvme_subsystem_get_sysfs_dir() - Get sysfs_dir.
553537
* @p: The &struct nvme_subsystem instance to query.
@@ -556,15 +540,6 @@ void nvme_subsystem_set_sysfs_dir(
556540
*/
557541
const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p);
558542

559-
/**
560-
* nvme_subsystem_set_subsysnqn() - Set subsysnqn.
561-
* @p: The &struct nvme_subsystem instance to update.
562-
* @subsysnqn: New string; a copy is stored. Pass NULL to clear.
563-
*/
564-
void nvme_subsystem_set_subsysnqn(
565-
struct nvme_subsystem *p,
566-
const char *subsysnqn);
567-
568543
/**
569544
* nvme_subsystem_get_subsysnqn() - Get subsysnqn.
570545
* @p: The &struct nvme_subsystem instance to query.
@@ -573,13 +548,6 @@ void nvme_subsystem_set_subsysnqn(
573548
*/
574549
const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p);
575550

576-
/**
577-
* nvme_subsystem_set_model() - Set model.
578-
* @p: The &struct nvme_subsystem instance to update.
579-
* @model: New string; a copy is stored. Pass NULL to clear.
580-
*/
581-
void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model);
582-
583551
/**
584552
* nvme_subsystem_get_model() - Get model.
585553
* @p: The &struct nvme_subsystem instance to query.
@@ -588,13 +556,6 @@ void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model);
588556
*/
589557
const char *nvme_subsystem_get_model(const struct nvme_subsystem *p);
590558

591-
/**
592-
* nvme_subsystem_set_serial() - Set serial.
593-
* @p: The &struct nvme_subsystem instance to update.
594-
* @serial: New string; a copy is stored. Pass NULL to clear.
595-
*/
596-
void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial);
597-
598559
/**
599560
* nvme_subsystem_get_serial() - Get serial.
600561
* @p: The &struct nvme_subsystem instance to query.
@@ -603,15 +564,6 @@ void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial);
603564
*/
604565
const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p);
605566

606-
/**
607-
* nvme_subsystem_set_firmware() - Set firmware.
608-
* @p: The &struct nvme_subsystem instance to update.
609-
* @firmware: New string; a copy is stored. Pass NULL to clear.
610-
*/
611-
void nvme_subsystem_set_firmware(
612-
struct nvme_subsystem *p,
613-
const char *firmware);
614-
615567
/**
616568
* nvme_subsystem_get_firmware() - Get firmware.
617569
* @p: The &struct nvme_subsystem instance to query.
@@ -620,15 +572,6 @@ void nvme_subsystem_set_firmware(
620572
*/
621573
const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p);
622574

623-
/**
624-
* nvme_subsystem_set_subsystype() - Set subsystype.
625-
* @p: The &struct nvme_subsystem instance to update.
626-
* @subsystype: New string; a copy is stored. Pass NULL to clear.
627-
*/
628-
void nvme_subsystem_set_subsystype(
629-
struct nvme_subsystem *p,
630-
const char *subsystype);
631-
632575
/**
633576
* nvme_subsystem_get_subsystype() - Get subsystype.
634577
* @p: The &struct nvme_subsystem instance to query.

libnvme/src/nvme/private.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ struct nvme_subsystem { /*!generate-accessors*/
222222
struct list_head namespaces;
223223
struct nvme_host *h;
224224

225-
char *name;
226-
char *sysfs_dir;
227-
char *subsysnqn;
228-
char *model;
229-
char *serial;
230-
char *firmware;
231-
char *subsystype;
225+
char *name; /*!accessors:readonly*/
226+
char *sysfs_dir; /*!accessors:readonly*/
227+
char *subsysnqn; /*!accessors:readonly*/
228+
char *model; /*!accessors:readonly*/
229+
char *serial; /*!accessors:readonly*/
230+
char *firmware; /*!accessors:readonly*/
231+
char *subsystype; /*!accessors:readonly*/
232232
char *application;
233233
char *iopolicy;
234234
};

0 commit comments

Comments
 (0)