On Mon, 2018-10-29 at 12:15 -0400, Theodore Ts'o wrote:
> Signed-off-by: Theodore Ts'o <[email protected]>
> ---
>  src/discontiguous-io.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/discontiguous-io.cpp b/src/discontiguous-io.cpp
> index 5e0ee0f..a59c18d 100644
> --- a/src/discontiguous-io.cpp
> +++ b/src/discontiguous-io.cpp
> @@ -291,7 +291,7 @@ int main(int argc, char **argv)
>                       unsigned char *p = &*buf.begin();
>                       for (int i = 0; i < len / 4; i++)
>                               iov.append(p + 4 + i * 8,
> -                                        std::min(4ul, len - i * 4));
> +                                        std::min(4ul, (unsigned long) len - 
> i * 4));
>               } else {
>                       iov.append(&*buf.begin(), buf.size());
>               }

Hi Ted,

Have you considered to change the data type of 'len' from size_t into unsigned 
long
instead of inserting this cast? That would make it clear that no integer 
truncation
happens in the iov.append() call.

Thanks,

Bart.

Reply via email to