Skip to content

Commit ccf5da0

Browse files
committed
libnvme: read-only subsystem attributes
Nearly all 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 f191ece commit ccf5da0

5 files changed

Lines changed: 14 additions & 126 deletions

File tree

libnvme/src/accessors.ld

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,12 @@ LIBNVME_ACCESSORS_3 {
7171
nvme_ctrl_get_persistent;
7272
nvme_ctrl_set_persistent;
7373
nvme_subsystem_get_name;
74-
nvme_subsystem_set_name;
7574
nvme_subsystem_get_sysfs_dir;
76-
nvme_subsystem_set_sysfs_dir;
7775
nvme_subsystem_get_subsysnqn;
78-
nvme_subsystem_set_subsysnqn;
7976
nvme_subsystem_get_model;
80-
nvme_subsystem_set_model;
8177
nvme_subsystem_get_serial;
82-
nvme_subsystem_set_serial;
8378
nvme_subsystem_get_firmware;
84-
nvme_subsystem_set_firmware;
8579
nvme_subsystem_get_subsystype;
86-
nvme_subsystem_set_subsystype;
8780
nvme_subsystem_get_application;
8881
nvme_subsystem_set_application;
8982
nvme_subsystem_get_iopolicy;

libnvme/src/nvme/accessors.c

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

362-
void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name)
363-
{
364-
free(p->name);
365-
p->name = name ? strdup(name) : NULL;
366-
}
367-
368362
const char *nvme_subsystem_get_name(const struct nvme_subsystem *p)
369363
{
370364
return p->name;
371365
}
372366

373-
void nvme_subsystem_set_sysfs_dir(
374-
struct nvme_subsystem *p,
375-
const char *sysfs_dir)
376-
{
377-
free(p->sysfs_dir);
378-
p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL;
379-
}
380-
381367
const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p)
382368
{
383369
return p->sysfs_dir;
384370
}
385371

386-
void nvme_subsystem_set_subsysnqn(
387-
struct nvme_subsystem *p,
388-
const char *subsysnqn)
389-
{
390-
free(p->subsysnqn);
391-
p->subsysnqn = subsysnqn ? strdup(subsysnqn) : NULL;
392-
}
393-
394372
const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p)
395373
{
396374
return p->subsysnqn;
397375
}
398376

399-
void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model)
400-
{
401-
free(p->model);
402-
p->model = model ? strdup(model) : NULL;
403-
}
404-
405377
const char *nvme_subsystem_get_model(const struct nvme_subsystem *p)
406378
{
407379
return p->model;
408380
}
409381

410-
void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial)
411-
{
412-
free(p->serial);
413-
p->serial = serial ? strdup(serial) : NULL;
414-
}
415-
416382
const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p)
417383
{
418384
return p->serial;
419385
}
420386

421-
void nvme_subsystem_set_firmware(struct nvme_subsystem *p, const char *firmware)
422-
{
423-
free(p->firmware);
424-
p->firmware = firmware ? strdup(firmware) : NULL;
425-
}
426-
427387
const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p)
428388
{
429389
return p->firmware;
430390
}
431391

432-
void nvme_subsystem_set_subsystype(
433-
struct nvme_subsystem *p,
434-
const char *subsystype)
435-
{
436-
free(p->subsystype);
437-
p->subsystype = subsystype ? strdup(subsystype) : NULL;
438-
}
439-
440392
const char *nvme_subsystem_get_subsystype(const struct nvme_subsystem *p)
441393
{
442394
return p->subsystype;

libnvme/src/nvme/accessors.h

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

519-
/**
520-
* nvme_subsystem_set_name() - Set name.
521-
* @p: The &struct nvme_subsystem instance to update.
522-
* @name: New string; a copy is stored. Pass NULL to clear.
523-
*/
524-
void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name);
525-
526519
/**
527520
* nvme_subsystem_get_name() - Get name.
528521
* @p: The &struct nvme_subsystem instance to query.
@@ -531,15 +524,6 @@ void nvme_subsystem_set_name(struct nvme_subsystem *p, const char *name);
531524
*/
532525
const char *nvme_subsystem_get_name(const struct nvme_subsystem *p);
533526

534-
/**
535-
* nvme_subsystem_set_sysfs_dir() - Set sysfs_dir.
536-
* @p: The &struct nvme_subsystem instance to update.
537-
* @sysfs_dir: New string; a copy is stored. Pass NULL to clear.
538-
*/
539-
void nvme_subsystem_set_sysfs_dir(
540-
struct nvme_subsystem *p,
541-
const char *sysfs_dir);
542-
543527
/**
544528
* nvme_subsystem_get_sysfs_dir() - Get sysfs_dir.
545529
* @p: The &struct nvme_subsystem instance to query.
@@ -548,15 +532,6 @@ void nvme_subsystem_set_sysfs_dir(
548532
*/
549533
const char *nvme_subsystem_get_sysfs_dir(const struct nvme_subsystem *p);
550534

551-
/**
552-
* nvme_subsystem_set_subsysnqn() - Set subsysnqn.
553-
* @p: The &struct nvme_subsystem instance to update.
554-
* @subsysnqn: New string; a copy is stored. Pass NULL to clear.
555-
*/
556-
void nvme_subsystem_set_subsysnqn(
557-
struct nvme_subsystem *p,
558-
const char *subsysnqn);
559-
560535
/**
561536
* nvme_subsystem_get_subsysnqn() - Get subsysnqn.
562537
* @p: The &struct nvme_subsystem instance to query.
@@ -565,13 +540,6 @@ void nvme_subsystem_set_subsysnqn(
565540
*/
566541
const char *nvme_subsystem_get_subsysnqn(const struct nvme_subsystem *p);
567542

568-
/**
569-
* nvme_subsystem_set_model() - Set model.
570-
* @p: The &struct nvme_subsystem instance to update.
571-
* @model: New string; a copy is stored. Pass NULL to clear.
572-
*/
573-
void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model);
574-
575543
/**
576544
* nvme_subsystem_get_model() - Get model.
577545
* @p: The &struct nvme_subsystem instance to query.
@@ -580,13 +548,6 @@ void nvme_subsystem_set_model(struct nvme_subsystem *p, const char *model);
580548
*/
581549
const char *nvme_subsystem_get_model(const struct nvme_subsystem *p);
582550

583-
/**
584-
* nvme_subsystem_set_serial() - Set serial.
585-
* @p: The &struct nvme_subsystem instance to update.
586-
* @serial: New string; a copy is stored. Pass NULL to clear.
587-
*/
588-
void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial);
589-
590551
/**
591552
* nvme_subsystem_get_serial() - Get serial.
592553
* @p: The &struct nvme_subsystem instance to query.
@@ -595,15 +556,6 @@ void nvme_subsystem_set_serial(struct nvme_subsystem *p, const char *serial);
595556
*/
596557
const char *nvme_subsystem_get_serial(const struct nvme_subsystem *p);
597558

598-
/**
599-
* nvme_subsystem_set_firmware() - Set firmware.
600-
* @p: The &struct nvme_subsystem instance to update.
601-
* @firmware: New string; a copy is stored. Pass NULL to clear.
602-
*/
603-
void nvme_subsystem_set_firmware(
604-
struct nvme_subsystem *p,
605-
const char *firmware);
606-
607559
/**
608560
* nvme_subsystem_get_firmware() - Get firmware.
609561
* @p: The &struct nvme_subsystem instance to query.
@@ -612,15 +564,6 @@ void nvme_subsystem_set_firmware(
612564
*/
613565
const char *nvme_subsystem_get_firmware(const struct nvme_subsystem *p);
614566

615-
/**
616-
* nvme_subsystem_set_subsystype() - Set subsystype.
617-
* @p: The &struct nvme_subsystem instance to update.
618-
* @subsystype: New string; a copy is stored. Pass NULL to clear.
619-
*/
620-
void nvme_subsystem_set_subsystype(
621-
struct nvme_subsystem *p,
622-
const char *subsystype);
623-
624567
/**
625568
* nvme_subsystem_get_subsystype() - Get subsystype.
626569
* @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 {
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+
const char *name;
226+
const char *sysfs_dir;
227+
const char *subsysnqn;
228+
const char *model;
229+
const char *serial;
230+
const char *firmware;
231+
const char *subsystype;
232232
char *application;
233233
char *iopolicy;
234234
};

libnvme/src/nvme/tree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ static void __nvme_free_subsystem(struct nvme_subsystem *s)
501501
nvme_subsystem_for_each_ns_safe(s, n, _n)
502502
__nvme_free_ns(n);
503503

504-
free(s->name);
505-
free(s->sysfs_dir);
506-
free(s->subsysnqn);
507-
free(s->model);
508-
free(s->serial);
509-
free(s->firmware);
510-
free(s->subsystype);
504+
free((char *)s->name);
505+
free((char *)s->sysfs_dir);
506+
free((char *)s->subsysnqn);
507+
free((char *)s->model);
508+
free((char *)s->serial);
509+
free((char *)s->firmware);
510+
free((char *)s->subsystype);
511511
free(s->application);
512512
free(s->iopolicy);
513513
free(s);

0 commit comments

Comments
 (0)