git: 0d03585e6bc7 - stable/14 - jedec_dimm: Use device_set_descf()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Jun 2024 15:31:17 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=0d03585e6bc7effbbf52bbe49a4ee33e4b8a7889
commit 0d03585e6bc7effbbf52bbe49a4ee33e4b8a7889
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-06-05 19:34:30 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-27 15:27:42 +0000
jedec_dimm: Use device_set_descf()
Note that it is ok to use device_get_desc() as one of the format string
parameters because it is set using device_set_desc() (not
device_set_desc_copy()) and so won't be freed when the description is
updated.
No functional change intended.
MFC after: 1 week
(cherry picked from commit 83caa244bc9eef6949a1250a875ad1409775a46e)
---
sys/dev/jedec_dimm/jedec_dimm.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/sys/dev/jedec_dimm/jedec_dimm.c b/sys/dev/jedec_dimm/jedec_dimm.c
index ddaa0e96856e..697e7695a009 100644
--- a/sys/dev/jedec_dimm/jedec_dimm.c
+++ b/sys/dev/jedec_dimm/jedec_dimm.c
@@ -265,7 +265,6 @@ jedec_dimm_attach(device_t dev)
uint16_t vendorid;
bool tsod_present;
int rc;
- int new_desc_len;
enum dram_type type;
struct jedec_dimm_softc *sc;
struct sysctl_ctx_list *ctx;
@@ -273,7 +272,6 @@ jedec_dimm_attach(device_t dev)
struct sysctl_oid_list *children;
const char *tsod_match;
const char *slotid_str;
- char *new_desc;
sc = device_get_softc(dev);
ctx = device_get_sysctl_ctx(dev);
@@ -447,26 +445,13 @@ no_tsod:
* device description.
*/
if ((tsod_match != NULL) || (sc->slotid_str != NULL)) {
- new_desc_len = strlen(device_get_desc(dev));
- if (tsod_match != NULL) {
- new_desc_len += strlen(tsod_match);
- new_desc_len += 4; /* " w/ " */
- }
- if (sc->slotid_str != NULL) {
- new_desc_len += strlen(sc->slotid_str);
- new_desc_len += 3; /* space + parens */
- }
- new_desc_len++; /* terminator */
- new_desc = malloc(new_desc_len, M_TEMP, (M_WAITOK | M_ZERO));
- (void) snprintf(new_desc, new_desc_len, "%s%s%s%s%s%s",
+ device_set_descf(dev, "%s%s%s%s%s%s",
device_get_desc(dev),
(tsod_match ? " w/ " : ""),
(tsod_match ? tsod_match : ""),
(sc->slotid_str ? " (" : ""),
(sc->slotid_str ? sc->slotid_str : ""),
(sc->slotid_str ? ")" : ""));
- device_set_desc_copy(dev, new_desc);
- free(new_desc, M_TEMP);
}
out: