Commit 77e499c3 authored by Érico Nogueira Rolim's avatar Érico Nogueira Rolim

sdbfs: fix void* usage in pointer arithmetic

parent af63b97c
......@@ -31,7 +31,7 @@ int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count)
count = fs->f_len - offset;
ret = count;
if (fs->data)
memcpy(buf, fs->data + fs->f_offset + offset, count);
memcpy(buf, (unsigned char *)fs->data + fs->f_offset + offset, count);
else
ret = fs->read(fs, fs->f_offset + offset, buf, count);
if (ret > 0)
......@@ -51,7 +51,7 @@ int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count)
count = fs->f_len - offset;
ret = count;
if (fs->data)
memcpy(fs->data + fs->f_offset + offset, buf, count);
memcpy((unsigned char *)fs->data + fs->f_offset + offset, buf, count);
else
ret = fs->write(fs, fs->f_offset + offset, buf, count);
if (ret > 0)
......@@ -71,7 +71,7 @@ int sdbfs_ferase(struct sdbfs *fs, int offset, int count)
count = fs->f_len - offset;
ret = count;
if (fs->data)
memset(fs->data + fs->f_offset + offset, 0xFF, count);
memset((unsigned char *)fs->data + fs->f_offset + offset, 0xFF, count);
else
ret = fs->erase(fs, fs->f_offset + offset, count);
if (ret > 0)
......
......@@ -20,7 +20,7 @@ int sdbfs_dev_create(struct sdbfs *fs)
/* First, check we have the magic */
if (fs->data || (fs->flags & SDBFS_F_ZEROBASED))
magic = *(unsigned int *)(fs->data + fs->entrypoint);
magic = *(unsigned int *)((unsigned char *)fs->data + fs->entrypoint);
else
fs->read(fs, fs->entrypoint, &magic, sizeof(magic));
if (magic == SDB_MAGIC) {
......@@ -77,9 +77,9 @@ static struct sdb_device *sdbfs_readentry(struct sdbfs *fs,
*/
if (fs->data || (fs->flags & SDBFS_F_ZEROBASED)) {
if (!(fs->flags & SDBFS_F_CONVERT32))
return (struct sdb_device *)(fs->data + offset);
return (struct sdb_device *)((unsigned char *)fs->data + offset);
/* copy to local storage for conversion */
memcpy(&fs->current_record, fs->data + offset,
memcpy(&fs->current_record, (unsigned char *)fs->data + offset,
sizeof(fs->current_record));
} else {
if (!fs->read)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment