diff --git a/include/spdk/cpuset.h b/include/spdk/cpuset.h index 59f98d421..1e0f73aae 100644 --- a/include/spdk/cpuset.h +++ b/include/spdk/cpuset.h @@ -136,8 +136,10 @@ uint32_t spdk_cpuset_count(const struct spdk_cpuset *set); * \param CPU set. * \return Pointer to hexadecimal representation of CPU set. Buffer to store a * string is dynamically allocated internally and freed with CPU set object. + * Memory returned by this function might be changed after subsequent calls to + * this function so string should be copied by user. */ -char *spdk_cpuset_fmt(struct spdk_cpuset *set); +const char *spdk_cpuset_fmt(struct spdk_cpuset *set); /** * Convert a string containing a CPU core mask into a CPU set. diff --git a/lib/util/cpuset.c b/lib/util/cpuset.c index 6d74ea77e..1a02e59fe 100644 --- a/lib/util/cpuset.c +++ b/lib/util/cpuset.c @@ -132,7 +132,7 @@ spdk_cpuset_count(const struct spdk_cpuset *set) return count; } -char * +const char * spdk_cpuset_fmt(struct spdk_cpuset *set) { uint32_t lcore, lcore_max = 0; diff --git a/test/unit/lib/util/cpuset.c/cpuset_ut.c b/test/unit/lib/util/cpuset.c/cpuset_ut.c index 058b6c049..6fea0ad3e 100644 --- a/test/unit/lib/util/cpuset.c/cpuset_ut.c +++ b/test/unit/lib/util/cpuset.c/cpuset_ut.c @@ -189,7 +189,7 @@ test_cpuset_fmt(void) int i; uint32_t lcore; struct spdk_cpuset *core_mask = spdk_cpuset_alloc(); - char *hex_mask; + const char *hex_mask; char hex_mask_ref[SPDK_CPUSET_SIZE / 4 + 1]; /* Clear coremask. hex_mask should be "0" */