From dc23c85085f9121ce9ad7fb6298b9172330a8f5b Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 21 Apr 2021 05:59:04 -0700 Subject: [PATCH] px4/common:mtd Use inttypes --- platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c | 11 ++++++----- platforms/nuttx/src/px4/common/px4_mtd.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c b/platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c index 178888b096..8f635bcfd8 100644 --- a/platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c +++ b/platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c @@ -14,7 +14,7 @@ * * Derived from drivers/mtd/m25px.c * - * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2011, 2021 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ #include #include +#include #include #include #include @@ -270,7 +271,7 @@ void at24c_test(void) } } else if (result != 1) { - syslog(LOG_INFO, "unexpected %u\n", result); + syslog(LOG_INFO, "unexpected %zu\n", result); } if ((count % 100) == 0) { @@ -314,7 +315,7 @@ static ssize_t at24c_bread(FAR struct mtd_dev_s *dev, off_t startblock, #endif blocksleft = nblocks; - finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); + finfo("startblock: %08jx nblocks: %zu\n", (intmax_t)startblock, nblocks); if (startblock >= priv->npages) { return 0; @@ -409,7 +410,7 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks = priv->npages - startblock; } - finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); + finfo("startblock: %08jx nblocks: %zu\n", (intmax_t)startblock, nblocks); BOARD_EEPROM_WP_CTRL(false); @@ -505,7 +506,7 @@ static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) #endif ret = OK; - finfo("blocksize: %d erasesize: %d neraseblocks: %d\n", + finfo("blocksize: %" PRId32 " erasesize: %" PRId32 " neraseblocks: %" PRId32 "\n", geo->blocksize, geo->erasesize, geo->neraseblocks); } } diff --git a/platforms/nuttx/src/px4/common/px4_mtd.cpp b/platforms/nuttx/src/px4/common/px4_mtd.cpp index ab0f48504e..f835bb5950 100644 --- a/platforms/nuttx/src/px4/common/px4_mtd.cpp +++ b/platforms/nuttx/src/px4/common/px4_mtd.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (c) 2020 PX4 Development Team. All rights reserved. + * Copyright (c) 2020, 2021 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -49,6 +49,7 @@ #include #include +#include #include #include #include "systemlib/px4_macros.h" @@ -363,7 +364,7 @@ memoryout: char blockname[32]; - unsigned offset; + unsigned long offset; unsigned part; for (offset = 0, part = 0; rv == 0 && part < nparts; offset += instances[i].partition_block_counts[part], part++) { @@ -373,8 +374,8 @@ memoryout: instances[i].part_dev[part] = mtd_partition(instances[i].mtd_dev, offset, instances[i].partition_block_counts[part]); if (instances[i].part_dev[part] == nullptr) { - PX4_ERR("mtd_partition failed. offset=%lu nblocks=%lu", - (unsigned long)offset, (unsigned long)nblocks); + PX4_ERR("mtd_partition failed. offset=%lu nblocks=%u", + offset, nblocks); rv = -ENOSPC; goto errout; } @@ -407,7 +408,7 @@ memoryout: errout: if (rv < 0) { - PX4_ERR("mtd failure: %d bus %d address %d class %d", + PX4_ERR("mtd failure: %d bus %" PRId32 " address %" PRId32 " class %d", rv, PX4_I2C_DEVID_BUS(instances[i].devid), PX4_I2C_DEVID_ADDR(instances[i].devid),