lib: Use PRId64 for portability
POSIX defines PRId64/PRIu64/PRIx64 for printing 64-bit values in a portable way. Replace a few references to %ld to remove the assumption about the size of a long. Similarly, use %z with size_t arguments. Where the value being printed is an unsigned 64-bit value, use PRIu64 instead of %ld. Explicitly test for not __linux__ where that is the intent, rather than testing for __FreeBSD__. Cast pointer to uintptr_t before aligning it, rather than using a specific integer size which may not be large enough to store a pointer. Signed-off-by: Nick Connolly <nick.connolly@mayadata.io> Change-Id: Icfe219e1bbb2d06b3ef05710fac5b7091d340251 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5142 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
bb19c18f6a
commit
b8c99a3aad
@ -181,7 +181,7 @@ bs_allocate_cluster(struct spdk_blob *blob, uint32_t cluster_num,
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Claiming cluster %lu for blob %lu\n", *cluster, blob->id);
|
||||
SPDK_DEBUGLOG(blob, "Claiming cluster %" PRIu64 " for blob %" PRIu64 "\n", *cluster, blob->id);
|
||||
|
||||
if (update_map) {
|
||||
blob_insert_cluster(blob, cluster_num, *cluster);
|
||||
@ -782,7 +782,7 @@ blob_parse(const struct spdk_blob_md_page *pages, uint32_t page_count,
|
||||
* happen for example if a bogus blobid is passed in through open.
|
||||
*/
|
||||
if (blob->id != pages[0].id) {
|
||||
SPDK_ERRLOG("Blobid (%lu) doesn't match what's in metadata (%lu)\n",
|
||||
SPDK_ERRLOG("Blobid (%" PRIu64 ") doesn't match what's in metadata (%" PRIu64 ")\n",
|
||||
blob->id, pages[0].id);
|
||||
return -ENOENT;
|
||||
}
|
||||
@ -1422,7 +1422,7 @@ blob_load_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
}
|
||||
|
||||
if (bserrno) {
|
||||
SPDK_ERRLOG("Metadata page %d read failed for blobid %lu: %d\n",
|
||||
SPDK_ERRLOG("Metadata page %d read failed for blobid %" PRIu64 ": %d\n",
|
||||
current_page, blob->id, bserrno);
|
||||
blob_load_final(ctx, bserrno);
|
||||
return;
|
||||
@ -1431,7 +1431,7 @@ blob_load_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
page = &ctx->pages[ctx->num_pages - 1];
|
||||
crc = blob_md_page_calc_crc(page);
|
||||
if (crc != page->crc) {
|
||||
SPDK_ERRLOG("Metadata page %d crc mismatch for blobid %lu\n",
|
||||
SPDK_ERRLOG("Metadata page %d crc mismatch for blobid %" PRIu64 "\n",
|
||||
current_page, blob->id);
|
||||
blob_load_final(ctx, -EINVAL);
|
||||
return;
|
||||
@ -2048,7 +2048,7 @@ blob_persist_generate_new_md(struct spdk_blob_persist_ctx *ctx)
|
||||
ctx->pages[i - 1].crc = blob_md_page_calc_crc(&ctx->pages[i - 1]);
|
||||
blob->active.pages[i] = page_num;
|
||||
bs_claim_md_page(bs, page_num);
|
||||
SPDK_DEBUGLOG(blob, "Claiming page %u for blob %lu\n", page_num, blob->id);
|
||||
SPDK_DEBUGLOG(blob, "Claiming page %u for blob %" PRIu64 "\n", page_num, blob->id);
|
||||
page_num++;
|
||||
}
|
||||
ctx->pages[i - 1].crc = blob_md_page_calc_crc(&ctx->pages[i - 1]);
|
||||
@ -4222,7 +4222,7 @@ bs_load_super_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
}
|
||||
|
||||
if (ctx->super->size > ctx->bs->dev->blockcnt * ctx->bs->dev->blocklen) {
|
||||
SPDK_NOTICELOG("Size mismatch, dev size: %lu, blobstore size: %lu\n",
|
||||
SPDK_NOTICELOG("Size mismatch, dev size: %" PRIu64 ", blobstore size: %" PRIu64 "\n",
|
||||
ctx->bs->dev->blockcnt * ctx->bs->dev->blocklen, ctx->super->size);
|
||||
bs_load_ctx_fail(ctx, -EILSEQ);
|
||||
return;
|
||||
@ -5256,7 +5256,7 @@ bs_create_blob(struct spdk_blob_store *bs,
|
||||
|
||||
id = bs_page_to_blobid(page_idx);
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Creating blob with id %lu at page %u\n", id, page_idx);
|
||||
SPDK_DEBUGLOG(blob, "Creating blob with id %" PRIu64 " at page %u\n", id, page_idx);
|
||||
|
||||
blob = blob_alloc(bs, id);
|
||||
if (!blob) {
|
||||
@ -5673,7 +5673,7 @@ bs_snapshot_origblob_open_cpl(void *cb_arg, struct spdk_blob *_blob, int bserrno
|
||||
ctx->original.blob = _blob;
|
||||
|
||||
if (_blob->data_ro || _blob->md_ro) {
|
||||
SPDK_DEBUGLOG(blob, "Cannot create snapshot from read only blob with id %lu\n",
|
||||
SPDK_DEBUGLOG(blob, "Cannot create snapshot from read only blob with id %" PRIu64 "\n",
|
||||
_blob->id);
|
||||
ctx->bserrno = -EINVAL;
|
||||
spdk_blob_close(_blob, bs_clone_snapshot_cleanup_finish, ctx);
|
||||
@ -6104,7 +6104,7 @@ spdk_blob_resize(struct spdk_blob *blob, uint64_t sz, spdk_blob_op_complete cb_f
|
||||
|
||||
blob_verify_md_op(blob);
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Resizing blob %lu to %lu clusters\n", blob->id, sz);
|
||||
SPDK_DEBUGLOG(blob, "Resizing blob %" PRIu64 " to %" PRIu64 " clusters\n", blob->id, sz);
|
||||
|
||||
if (blob->md_ro) {
|
||||
cb_fn(cb_arg, -EPERM);
|
||||
@ -6631,7 +6631,7 @@ spdk_bs_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
struct spdk_bs_cpl cpl;
|
||||
spdk_bs_sequence_t *seq;
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Deleting blob %lu\n", blobid);
|
||||
SPDK_DEBUGLOG(blob, "Deleting blob %" PRIu64 "\n", blobid);
|
||||
|
||||
assert(spdk_get_thread() == bs->md_thread);
|
||||
|
||||
@ -6695,7 +6695,7 @@ bs_open_blob(struct spdk_blob_store *bs,
|
||||
spdk_bs_sequence_t *seq;
|
||||
uint32_t page_num;
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Opening blob %lu\n", blobid);
|
||||
SPDK_DEBUGLOG(blob, "Opening blob %" PRIu64 "\n", blobid);
|
||||
assert(spdk_get_thread() == bs->md_thread);
|
||||
|
||||
page_num = bs_blobid_to_page(blobid);
|
||||
@ -6805,7 +6805,7 @@ spdk_blob_sync_md(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_
|
||||
{
|
||||
blob_verify_md_op(blob);
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Syncing blob %lu\n", blob->id);
|
||||
SPDK_DEBUGLOG(blob, "Syncing blob %" PRIu64 "\n", blob->id);
|
||||
|
||||
if (blob->md_ro) {
|
||||
assert(blob->state == SPDK_BLOB_STATE_CLEAN);
|
||||
@ -6994,7 +6994,7 @@ void spdk_blob_close(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *
|
||||
|
||||
blob_verify_md_op(blob);
|
||||
|
||||
SPDK_DEBUGLOG(blob, "Closing blob %lu\n", blob->id);
|
||||
SPDK_DEBUGLOG(blob, "Closing blob %" PRIu64 "\n", blob->id);
|
||||
|
||||
if (blob->open_ref == 0) {
|
||||
cb_fn(cb_arg, -EBADF);
|
||||
@ -7173,7 +7173,7 @@ blob_set_xattr(struct spdk_blob *blob, const char *name, const void *value,
|
||||
|
||||
desc_size = sizeof(struct spdk_blob_md_descriptor_xattr) + strlen(name) + value_len;
|
||||
if (desc_size > SPDK_BS_MAX_DESC_SIZE) {
|
||||
SPDK_DEBUGLOG(blob, "Xattr '%s' of size %ld does not fix into single page %ld\n", name,
|
||||
SPDK_DEBUGLOG(blob, "Xattr '%s' of size %zu does not fix into single page %zu\n", name,
|
||||
desc_size, SPDK_BS_MAX_DESC_SIZE);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count)
|
||||
void
|
||||
spdk_env_dpdk_dump_mem_stats(FILE *file)
|
||||
{
|
||||
fprintf(file, "DPDK memory size %lu\n", rte_eal_get_physmem_size());
|
||||
fprintf(file, "DPDK memory size %" PRIu64 "\n", rte_eal_get_physmem_size());
|
||||
fprintf(file, "DPDK memory layout\n");
|
||||
rte_dump_physmem_layout(file);
|
||||
fprintf(file, "DPDK memzones.\n");
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "spdk/env_dpdk.h"
|
||||
#include "spdk/log.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#ifndef __linux__
|
||||
#define VFIO_ENABLED 0
|
||||
#else
|
||||
#include <linux/version.h>
|
||||
@ -605,13 +605,13 @@ spdk_mem_map_set_translation(struct spdk_mem_map *map, uint64_t vaddr, uint64_t
|
||||
struct map_2mb *map_2mb;
|
||||
|
||||
if ((uintptr_t)vaddr & ~MASK_256TB) {
|
||||
DEBUG_PRINT("invalid usermode virtual address %lu\n", vaddr);
|
||||
DEBUG_PRINT("invalid usermode virtual address %" PRIu64 "\n", vaddr);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* For now, only 2 MB-aligned registrations are supported */
|
||||
if (((uintptr_t)vaddr & MASK_2MB) || (size & MASK_2MB)) {
|
||||
DEBUG_PRINT("invalid %s parameters, vaddr=%lu len=%ju\n",
|
||||
DEBUG_PRINT("invalid %s parameters, vaddr=%" PRIu64 " len=%" PRIu64 "\n",
|
||||
__func__, vaddr, size);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1299,7 +1299,7 @@ iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn)
|
||||
if (conn->nop_outstanding) {
|
||||
if ((tsc - conn->last_nopin) > conn->timeout) {
|
||||
SPDK_ERRLOG("Timed out waiting for NOP-Out response from initiator\n");
|
||||
SPDK_ERRLOG(" tsc=0x%lx, last_nopin=0x%lx\n", tsc, conn->last_nopin);
|
||||
SPDK_ERRLOG(" tsc=0x%" PRIx64 ", last_nopin=0x%" PRIx64 "\n", tsc, conn->last_nopin);
|
||||
SPDK_ERRLOG(" initiator=%s, target=%s\n", conn->initiator_name,
|
||||
conn->target_short_name);
|
||||
conn->state = ISCSI_CONN_STATE_EXITING;
|
||||
|
@ -67,7 +67,7 @@ mobj_ctor(struct spdk_mempool *mp, __attribute__((unused)) void *arg,
|
||||
|
||||
m->mp = mp;
|
||||
m->buf = (uint8_t *)m + sizeof(struct spdk_mobj);
|
||||
m->buf = (void *)((unsigned long)((uint8_t *)m->buf + ISCSI_DATA_BUFFER_ALIGNMENT) &
|
||||
m->buf = (void *)((uintptr_t)((uint8_t *)m->buf + ISCSI_DATA_BUFFER_ALIGNMENT) &
|
||||
~ISCSI_DATA_BUFFER_MASK);
|
||||
}
|
||||
|
||||
|
@ -439,14 +439,14 @@ spdk_nvme_ctrlr_alloc_io_qpair(struct spdk_nvme_ctrlr *ctrlr,
|
||||
/* If user passes buffers, make sure they're big enough for the requested queue size */
|
||||
if (opts.sq.vaddr) {
|
||||
if (opts.sq.buffer_size < (opts.io_queue_size * sizeof(struct spdk_nvme_cmd))) {
|
||||
SPDK_ERRLOG("sq buffer size %lx is too small for sq size %lx\n",
|
||||
SPDK_ERRLOG("sq buffer size %" PRIx64 " is too small for sq size %zx\n",
|
||||
opts.sq.buffer_size, (opts.io_queue_size * sizeof(struct spdk_nvme_cmd)));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (opts.cq.vaddr) {
|
||||
if (opts.cq.buffer_size < (opts.io_queue_size * sizeof(struct spdk_nvme_cpl))) {
|
||||
SPDK_ERRLOG("cq buffer size %lx is too small for cq size %lx\n",
|
||||
SPDK_ERRLOG("cq buffer size %" PRIx64 " is too small for cq size %zx\n",
|
||||
opts.cq.buffer_size, (opts.io_queue_size * sizeof(struct spdk_nvme_cpl)));
|
||||
return NULL;
|
||||
}
|
||||
@ -4151,7 +4151,7 @@ spdk_nvme_map_prps(void *prv, struct spdk_nvme_cmd *cmd, struct iovec *iovs,
|
||||
iovcnt = 2;
|
||||
vva = gpa_to_vva(prv, prp2, len);
|
||||
if (spdk_unlikely(vva == NULL)) {
|
||||
SPDK_ERRLOG("no VVA for %#lx, len%#x\n",
|
||||
SPDK_ERRLOG("no VVA for %#" PRIx64 ", len%#x\n",
|
||||
prp2, len);
|
||||
return -1;
|
||||
}
|
||||
@ -4162,7 +4162,7 @@ spdk_nvme_map_prps(void *prv, struct spdk_nvme_cmd *cmd, struct iovec *iovs,
|
||||
nents = (len + mps - 1) / mps;
|
||||
vva = gpa_to_vva(prv, prp2, nents * sizeof(*prp_list));
|
||||
if (spdk_unlikely(vva == NULL)) {
|
||||
SPDK_ERRLOG("no VVA for %#lx, nents=%#x\n",
|
||||
SPDK_ERRLOG("no VVA for %#" PRIx64 ", nents=%#x\n",
|
||||
prp2, nents);
|
||||
return -1;
|
||||
}
|
||||
@ -4172,7 +4172,7 @@ spdk_nvme_map_prps(void *prv, struct spdk_nvme_cmd *cmd, struct iovec *iovs,
|
||||
residue_len = spdk_min(len, mps);
|
||||
vva = gpa_to_vva(prv, prp_list[i], residue_len);
|
||||
if (spdk_unlikely(vva == NULL)) {
|
||||
SPDK_ERRLOG("no VVA for %#lx, residue_len=%#x\n",
|
||||
SPDK_ERRLOG("no VVA for %#" PRIx64 ", residue_len=%#x\n",
|
||||
prp_list[i], residue_len);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1199,8 +1199,8 @@ poll_group_update_subsystem(struct spdk_nvmf_poll_group *group,
|
||||
ns_info->channel = ch;
|
||||
} else if (ns_info->num_blocks != spdk_bdev_get_num_blocks(ns->bdev)) {
|
||||
/* Namespace is still there but size has changed */
|
||||
SPDK_DEBUGLOG(nvmf, "Namespace resized: subsystem_id %d,"
|
||||
" nsid %u, pg %p, old %lu, new %lu\n",
|
||||
SPDK_DEBUGLOG(nvmf, "Namespace resized: subsystem_id %u,"
|
||||
" nsid %u, pg %p, old %" PRIu64 ", new %" PRIu64 "\n",
|
||||
subsystem->id,
|
||||
ns->nsid,
|
||||
group,
|
||||
|
@ -1429,7 +1429,7 @@ __copy_desc(struct spdk_bdev_scsi_unmap_ctx *ctx, uint8_t *data, size_t data_len
|
||||
desc_count = desc_data_len / 16;
|
||||
|
||||
if (desc_data_len > (data_len - 8)) {
|
||||
SPDK_ERRLOG("Error - desc_data_len (%u) > data_len (%lu) - 8\n",
|
||||
SPDK_ERRLOG("Error - desc_data_len (%u) > data_len (%zu) - 8\n",
|
||||
desc_data_len, data_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ rpc_trace_get_tpoint_group_mask(struct spdk_jsonrpc_request *request,
|
||||
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
snprintf(mask_str, sizeof(mask_str), "0x%lx", tpoint_group_mask);
|
||||
snprintf(mask_str, sizeof(mask_str), "0x%" PRIx64, tpoint_group_mask);
|
||||
spdk_json_write_named_string(w, "tpoint_group_mask", mask_str);
|
||||
|
||||
register_fn = spdk_trace_get_first_register_fn();
|
||||
|
@ -248,7 +248,7 @@ vmd_allocate_base_addr(struct vmd_adapter *vmd, struct vmd_pci_device *dev, uint
|
||||
vmd->current_addr_size -= size + padding;
|
||||
}
|
||||
|
||||
SPDK_DEBUGLOG(vmd, "allocated(size) %lx (%x)\n", base_address, size);
|
||||
SPDK_DEBUGLOG(vmd, "allocated(size) %" PRIx64 " (%x)\n", base_address, size);
|
||||
|
||||
return base_address;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user