Commit 6649e6ce authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

uuid: use spdk_uuid_{is|set}_null() where applicable



Commit 95a367d6 ("util/uuid: add API to test/set null uuid")
introduced spdk_uuid_is_null() and spdk_uuid_set_null() functions and
refactored the code to use them. Convert the remaining occurances that
were added since then.

Change-Id: I10a88a527ad92eb23e630d015c4b9d161df6b865
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18237


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 0f4785ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -601,7 +601,7 @@ spdk_bdev_part_construct_ext(struct spdk_bdev_part *part, struct spdk_bdev_part_
	 * based on the namespace UUID, the base bdev's UUID and the block range of the
	 * partition.
	 */
	if (!spdk_mem_all_zero(&opts.uuid, sizeof(opts.uuid))) {
	if (!spdk_uuid_is_null(&opts.uuid)) {
		spdk_uuid_copy(&part->internal.bdev.uuid, &opts.uuid);
	} else {
		struct {
+2 −2
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ _delay_write_conf_values(struct vbdev_delay *delay_node, struct spdk_json_write_

	spdk_json_write_named_string(w, "name", spdk_bdev_get_name(&delay_node->delay_bdev));
	spdk_json_write_named_string(w, "base_bdev_name", spdk_bdev_get_name(delay_node->base_bdev));
	if (!spdk_mem_all_zero(uuid, sizeof(*uuid))) {
	if (!spdk_uuid_is_null(uuid)) {
		spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), uuid);
		spdk_json_write_named_string(w, "uuid", uuid_str);
	}
@@ -827,7 +827,7 @@ vbdev_delay_register(const char *bdev_name)
		delay_node->average_write_latency_ticks = ticks_mhz * assoc->avg_write_latency;
		delay_node->p99_write_latency_ticks = ticks_mhz * assoc->p99_write_latency;

		if (spdk_mem_all_zero(&assoc->uuid, sizeof(assoc->uuid))) {
		if (spdk_uuid_is_null(&assoc->uuid)) {
			/* Generate UUID based on namespace UUID + base bdev UUID */
			rc = spdk_uuid_generate_sha1(&delay_node->delay_bdev.uuid, &ns_uuid,
						     (const char *)&bdev->uuid, sizeof(struct spdk_uuid));
+1 −1
Original line number Diff line number Diff line
@@ -526,7 +526,7 @@ vbdev_error_config_json(struct spdk_json_write_ctx *w)
		spdk_json_write_named_string(w, "method", "bdev_error_create");
		spdk_json_write_named_object_begin(w, "params");
		spdk_json_write_named_string(w, "base_name", cfg->base_bdev);
		if (!spdk_mem_all_zero(&cfg->uuid, sizeof(struct spdk_uuid))) {
		if (!spdk_uuid_is_null(&cfg->uuid)) {
			spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &cfg->uuid);
			spdk_json_write_named_string(w, "uuid", uuid_str);
		}
+2 −2
Original line number Diff line number Diff line
@@ -3655,8 +3655,8 @@ nvme_generate_uuid(const char *sn, uint32_t nsid)

	assert(strlen(sn) <= SPDK_NVME_CTRLR_SN_LEN);

	memset(&new_uuid, 0, sizeof(new_uuid));
	memset(&namespace_uuid, 0, sizeof(namespace_uuid));
	spdk_uuid_set_null(&new_uuid);
	spdk_uuid_set_null(&namespace_uuid);

	size = snprintf(merged_str, sizeof(merged_str), "%s%"PRIu32, sn, nsid);
	assert(size > 0 && (unsigned long)size < sizeof(merged_str));