Re: [libvirt] [PATCH] Add VIR_DIV_UP to divide memory or storage request sizes with round up

2011-01-28 Thread Matthias Bolte
2011/1/28 Eric Blake : > [replying to myself - never a good sign on Friday afternoon] > > On 01/28/2011 02:59 PM, Eric Blake wrote: >>> +/* divide value by size, rounding up */ >>> +# define VIR_DIV_UP(value, size) (((value) + (size) - 1) / (size)) >> >> Hmm - now that we are codifying it, can we m

Re: [libvirt] [PATCH] Add VIR_DIV_UP to divide memory or storage request sizes with round up

2011-01-28 Thread Eric Blake
[replying to myself - never a good sign on Friday afternoon] On 01/28/2011 02:59 PM, Eric Blake wrote: >> +/* divide value by size, rounding up */ >> +# define VIR_DIV_UP(value, size) (((value) + (size) - 1) / (size)) > > Hmm - now that we are codifying it, can we make it less prone to > overflow

Re: [libvirt] [PATCH] Add VIR_DIV_UP to divide memory or storage request sizes with round up

2011-01-28 Thread Eric Blake
On 01/28/2011 02:14 PM, Matthias Bolte wrote: > Use it in all places where a memory or storage request size is converted > to a larger granularity. This avoids requesting too small memory or storage > sizes that could result from the truncation done by a simple division. Much nicer than open-codin