[PATCH 5/5] Use size_t for memory offsets

Loïc Minier lool at dooz.org
Fri Oct 14 04:59:03 EDT 2011

On Fri, Oct 14, 2011, Sascha Hauer wrote:
> You should change the prototypes in include/driver.h aswell.

 Ah thanks, now it strikes me that the very same constructs are present
 in many file_operations implementations; e.g. imx_iim_cdev_read and
 imx_iim_cdev_write also use an ulong offset, as well as
 ubi_volume_cdev_read/ubi_volume_cdev_write (unsigned long), lp_read,
 miidev_read/_write etc.

 I had a look at file_operations in linux now, and it uses
 size_t/ssize_t and a loff_t type for regular read/write:
struct file_operations {
        loff_t (*llseek) (struct file *, loff_t, int);
        ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
        ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);

 however for aio:
        ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
        ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);

 loff_t is defined as long long on 32-bits and 64-bits arches, which I
 believe are both 8 bytes.

 So perhaps it's better to switch from ulong to unsigned long long for
 offsets?  This isn't important for mem_read/mem_write, but it would be
 for e.g. MMC accesses as it's of course valid to seek after the first
 4 G of a MMC on a 32-bits system.

Loïc Minier

More information about the barebox mailing list