You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/07/19 18:49:29 UTC
[incubator-nuttx] 04/07: Cast pointer to uintptr prior to ulong for
ioctl
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 3a58926d01cf52cc743a938f7e227d09bbe7ab66
Author: Brennan Ashton <ba...@brennanashton.com>
AuthorDate: Sun Jul 19 16:53:22 2020 +0000
Cast pointer to uintptr prior to ulong for ioctl
Signed-off-by: Brennan Ashton <ba...@brennanashton.com>
---
fs/driver/fs_blockpartition.c | 8 +++++---
fs/partition/fs_partition.c | 5 +++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/driver/fs_blockpartition.c b/fs/driver/fs_blockpartition.c
index f42d7fc..1dda522 100644
--- a/fs/driver/fs_blockpartition.c
+++ b/fs/driver/fs_blockpartition.c
@@ -224,6 +224,7 @@ static int part_geometry(FAR struct inode *inode, struct geometry *geometry)
static int part_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
{
+ FAR uintptr_t ptr_arg = (uintptr_t)arg;
FAR struct part_struct_s *dev = inode->i_private;
FAR struct inode *parent = dev->parent;
int ret = -ENOTTY;
@@ -232,7 +233,8 @@ static int part_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
{
if (cmd == MTDIOC_PROTECT || cmd == MTDIOC_UNPROTECT)
{
- FAR struct mtd_protect_s *prot = (FAR struct mtd_protect_s *)arg;
+ FAR struct mtd_protect_s *prot =
+ (FAR struct mtd_protect_s *)ptr_arg;
prot->startblock += dev->firstsector;
}
@@ -242,7 +244,7 @@ static int part_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
{
if (cmd == BIOC_XIPBASE || cmd == MTDIOC_XIPBASE)
{
- FAR void **base = (FAR void **)arg;
+ FAR void **base = (FAR void **)ptr_arg;
struct geometry geo;
ret = parent->u.i_bops->geometry(parent, &geo);
@@ -255,7 +257,7 @@ static int part_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
else if (cmd == MTDIOC_GEOMETRY)
{
FAR struct mtd_geometry_s *mgeo =
- (FAR struct mtd_geometry_s *)arg;
+ (FAR struct mtd_geometry_s *)ptr_arg;
uint32_t blkper = mgeo->erasesize / mgeo->blocksize;
mgeo->neraseblocks = dev->nsectors / blkper;
diff --git a/fs/partition/fs_partition.c b/fs/partition/fs_partition.c
index 4e065e6..f9d3fc9 100644
--- a/fs/partition/fs_partition.c
+++ b/fs/partition/fs_partition.c
@@ -156,7 +156,8 @@ int parse_block_partition(FAR const char *path,
state.mtd = NULL;
- ret = state.blk->u.i_bops->ioctl(state.blk, MTDIOC_GEOMETRY, (unsigned long)&mgeo);
+ ret = state.blk->u.i_bops->ioctl(
+ state.blk, MTDIOC_GEOMETRY, (unsigned long)(uintptr_t)&mgeo);
if (ret >= 0)
{
state.blocksize = mgeo.blocksize;
@@ -207,7 +208,7 @@ int parse_mtd_partition(FAR struct mtd_dev_s *mtd,
struct mtd_geometry_s mgeo;
int ret;
- ret = mtd->ioctl(mtd, MTDIOC_GEOMETRY, (unsigned long)&mgeo);
+ ret = mtd->ioctl(mtd, MTDIOC_GEOMETRY, (unsigned long)(uintptr_t)&mgeo);
if (ret < 0)
{
return ret;