Re: [Qemu-devel] [PATCH] use int64_t for return values from rbd instead of int
On 22 November 2012 08:23, Stefan Priebe - Profihost AG wrote: > Am 21.11.2012 23:32, schrieb Peter Maydell: >> Looking at the librbd API (which is what the size and ret >> values come from), it uses size_t and ssize_t for these. >> So I think probably ssize_t is the right type for ret >> (and size) in our structs here. > > > This sounds reasonable but does ssize_t support negative values? For error > values. Yes, the first 's' in ssize_t means 'signed' and is the difference between it and size_t. -- PMM -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Qemu-devel] [PATCH] use int64_t for return values from rbd instead of int
On 21 November 2012 17:03, Stefan Weil wrote: > Why do you use int64_t instead of off_t? > If the value is related to file sizes, off_t would be a good choice. Looking at the librbd API (which is what the size and ret values come from), it uses size_t and ssize_t for these. So I think probably ssize_t is the right type for ret (and size) in our structs here. -- PMM -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] overflow of int ret: use ssize_t for ret
On 23 November 2012 14:11, Stefan Hajnoczi wrote: > On Thu, Nov 22, 2012 at 10:07 AM, Stefan Priebe wrote: >> diff --git a/block/rbd.c b/block/rbd.c >> index 5a0f79f..0384c6c 100644 >> --- a/block/rbd.c >> +++ b/block/rbd.c >> @@ -69,7 +69,7 @@ typedef enum { >> typedef struct RBDAIOCB { >> BlockDriverAIOCB common; >> QEMUBH *bh; >> -int ret; >> +ssize_t ret; >> QEMUIOVector *qiov; >> char *bounce; >> RBDAIOCmd cmd; >> @@ -86,7 +86,7 @@ typedef struct RADOSCB { >> int done; >> int64_t size; >> char *buf; >> -int ret; >> +ssize_t ret; >> } RADOSCB; >> >> #define RBD_FD_READ 0 > > I preferred your previous patch: > > ssize_t on 32-bit hosts has sizeof(ssize_t) == 4. In > qemu_rbd_complete_aio() we may assign acb->ret = rcb->size. Here the > size field is int64_t, so ssize_t ret would truncate the value. The rcb size field should be a size_t: it is used for calling rbd_aio_write and rbd_aio_read so if we've overflowed 32 bits then we've already got a problem there. -- PMM -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html