Skip to content

Commit 179d832

Browse files
committed
libnvme: read-only controller accessors
Some controller attributes are fixed for the lifetime of the controller, 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 a89d312 commit 179d832

3 files changed

Lines changed: 16 additions & 224 deletions

File tree

libnvme/src/nvme/accessors.c

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -171,122 +171,56 @@ uint64_t nvme_ns_get_lba_util(const struct nvme_ns *p)
171171
* Accessors for: struct nvme_ctrl
172172
****************************************************************************/
173173

174-
void nvme_ctrl_set_name(struct nvme_ctrl *p, const char *name)
175-
{
176-
free(p->name);
177-
p->name = name ? strdup(name) : NULL;
178-
}
179-
180174
const char *nvme_ctrl_get_name(const struct nvme_ctrl *p)
181175
{
182176
return p->name;
183177
}
184178

185-
void nvme_ctrl_set_sysfs_dir(struct nvme_ctrl *p, const char *sysfs_dir)
186-
{
187-
free(p->sysfs_dir);
188-
p->sysfs_dir = sysfs_dir ? strdup(sysfs_dir) : NULL;
189-
}
190-
191179
const char *nvme_ctrl_get_sysfs_dir(const struct nvme_ctrl *p)
192180
{
193181
return p->sysfs_dir;
194182
}
195183

196-
void nvme_ctrl_set_firmware(struct nvme_ctrl *p, const char *firmware)
197-
{
198-
free(p->firmware);
199-
p->firmware = firmware ? strdup(firmware) : NULL;
200-
}
201-
202184
const char *nvme_ctrl_get_firmware(const struct nvme_ctrl *p)
203185
{
204186
return p->firmware;
205187
}
206188

207-
void nvme_ctrl_set_model(struct nvme_ctrl *p, const char *model)
208-
{
209-
free(p->model);
210-
p->model = model ? strdup(model) : NULL;
211-
}
212-
213189
const char *nvme_ctrl_get_model(const struct nvme_ctrl *p)
214190
{
215191
return p->model;
216192
}
217193

218-
void nvme_ctrl_set_numa_node(struct nvme_ctrl *p, const char *numa_node)
219-
{
220-
free(p->numa_node);
221-
p->numa_node = numa_node ? strdup(numa_node) : NULL;
222-
}
223-
224194
const char *nvme_ctrl_get_numa_node(const struct nvme_ctrl *p)
225195
{
226196
return p->numa_node;
227197
}
228198

229-
void nvme_ctrl_set_queue_count(struct nvme_ctrl *p, const char *queue_count)
230-
{
231-
free(p->queue_count);
232-
p->queue_count = queue_count ? strdup(queue_count) : NULL;
233-
}
234-
235199
const char *nvme_ctrl_get_queue_count(const struct nvme_ctrl *p)
236200
{
237201
return p->queue_count;
238202
}
239203

240-
void nvme_ctrl_set_serial(struct nvme_ctrl *p, const char *serial)
241-
{
242-
free(p->serial);
243-
p->serial = serial ? strdup(serial) : NULL;
244-
}
245-
246204
const char *nvme_ctrl_get_serial(const struct nvme_ctrl *p)
247205
{
248206
return p->serial;
249207
}
250208

251-
void nvme_ctrl_set_sqsize(struct nvme_ctrl *p, const char *sqsize)
252-
{
253-
free(p->sqsize);
254-
p->sqsize = sqsize ? strdup(sqsize) : NULL;
255-
}
256-
257209
const char *nvme_ctrl_get_sqsize(const struct nvme_ctrl *p)
258210
{
259211
return p->sqsize;
260212
}
261213

262-
void nvme_ctrl_set_transport(struct nvme_ctrl *p, const char *transport)
263-
{
264-
free(p->transport);
265-
p->transport = transport ? strdup(transport) : NULL;
266-
}
267-
268214
const char *nvme_ctrl_get_transport(const struct nvme_ctrl *p)
269215
{
270216
return p->transport;
271217
}
272218

273-
void nvme_ctrl_set_traddr(struct nvme_ctrl *p, const char *traddr)
274-
{
275-
free(p->traddr);
276-
p->traddr = traddr ? strdup(traddr) : NULL;
277-
}
278-
279219
const char *nvme_ctrl_get_traddr(const struct nvme_ctrl *p)
280220
{
281221
return p->traddr;
282222
}
283223

284-
void nvme_ctrl_set_trsvcid(struct nvme_ctrl *p, const char *trsvcid)
285-
{
286-
free(p->trsvcid);
287-
p->trsvcid = trsvcid ? strdup(trsvcid) : NULL;
288-
}
289-
290224
const char *nvme_ctrl_get_trsvcid(const struct nvme_ctrl *p)
291225
{
292226
return p->trsvcid;
@@ -354,34 +288,16 @@ const char *nvme_ctrl_get_tls_key(const struct nvme_ctrl *p)
354288
return p->tls_key;
355289
}
356290

357-
void nvme_ctrl_set_cntrltype(struct nvme_ctrl *p, const char *cntrltype)
358-
{
359-
free(p->cntrltype);
360-
p->cntrltype = cntrltype ? strdup(cntrltype) : NULL;
361-
}
362-
363291
const char *nvme_ctrl_get_cntrltype(const struct nvme_ctrl *p)
364292
{
365293
return p->cntrltype;
366294
}
367295

368-
void nvme_ctrl_set_cntlid(struct nvme_ctrl *p, const char *cntlid)
369-
{
370-
free(p->cntlid);
371-
p->cntlid = cntlid ? strdup(cntlid) : NULL;
372-
}
373-
374296
const char *nvme_ctrl_get_cntlid(const struct nvme_ctrl *p)
375297
{
376298
return p->cntlid;
377299
}
378300

379-
void nvme_ctrl_set_dctype(struct nvme_ctrl *p, const char *dctype)
380-
{
381-
free(p->dctype);
382-
p->dctype = dctype ? strdup(dctype) : NULL;
383-
}
384-
385301
const char *nvme_ctrl_get_dctype(const struct nvme_ctrl *p)
386302
{
387303
return p->dctype;
@@ -392,23 +308,11 @@ const char *nvme_ctrl_get_phy_slot(const struct nvme_ctrl *p)
392308
return p->phy_slot;
393309
}
394310

395-
void nvme_ctrl_set_host_traddr(struct nvme_ctrl *p, const char *host_traddr)
396-
{
397-
free(p->host_traddr);
398-
p->host_traddr = host_traddr ? strdup(host_traddr) : NULL;
399-
}
400-
401311
const char *nvme_ctrl_get_host_traddr(const struct nvme_ctrl *p)
402312
{
403313
return p->host_traddr;
404314
}
405315

406-
void nvme_ctrl_set_host_iface(struct nvme_ctrl *p, const char *host_iface)
407-
{
408-
free(p->host_iface);
409-
p->host_iface = host_iface ? strdup(host_iface) : NULL;
410-
}
411-
412316
const char *nvme_ctrl_get_host_iface(const struct nvme_ctrl *p)
413317
{
414318
return p->host_iface;

0 commit comments

Comments
 (0)