Skip to content
  • Eric Blake's avatar
    9d26dfcb
    nbd/server: Favor [u]int64_t over off_t · 9d26dfcb
    Eric Blake authored
    
    
    Although our compile-time environment is set up so that we always
    support long files with 64-bit off_t, we have no guarantee whether
    off_t is the same type as int64_t.  This requires casts when
    printing values, and prevents us from directly using qemu_strtoi64()
    (which will be done in the next patch). Let's just flip to uint64_t
    where possible, and stick to int64_t for detecting failure of
    blk_getlength(); we also keep the assertions added in the previous
    patch that the resulting values fit in 63 bits.  The overflow check
    in nbd_co_receive_request() was already sane (request->from is
    validated to fit in 63 bits, and request->len is 32 bits, so the
    addition can't overflow 64 bits), but rewrite it in a form easier
    to recognize as a typical overflow check.
    
    Rename the variable 'description' to keep line lengths reasonable.
    
    Suggested-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20190117193658.16413-7-eblake@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    9d26dfcb
    nbd/server: Favor [u]int64_t over off_t
    Eric Blake authored
    
    
    Although our compile-time environment is set up so that we always
    support long files with 64-bit off_t, we have no guarantee whether
    off_t is the same type as int64_t.  This requires casts when
    printing values, and prevents us from directly using qemu_strtoi64()
    (which will be done in the next patch). Let's just flip to uint64_t
    where possible, and stick to int64_t for detecting failure of
    blk_getlength(); we also keep the assertions added in the previous
    patch that the resulting values fit in 63 bits.  The overflow check
    in nbd_co_receive_request() was already sane (request->from is
    validated to fit in 63 bits, and request->len is 32 bits, so the
    addition can't overflow 64 bits), but rewrite it in a form easier
    to recognize as a typical overflow check.
    
    Rename the variable 'description' to keep line lengths reasonable.
    
    Suggested-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20190117193658.16413-7-eblake@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Loading