Richard W.M. Jones
2022-Feb-21 10:22 UTC
[Libguestfs] [PATCH nbdkit] cache, cow: Export block size constraints
On Mon, Feb 21, 2022 at 10:22:04AM +0100, Laszlo Ersek wrote:> > +/* Block size constraints. */ > > +static int > > +cache_block_size (nbdkit_next *next, void *handle, > > + uint32_t *minimum, uint32_t *preferred, uint32_t *maximum) > > +{ > > + if (next->block_size (next, minimum, preferred, maximum) == -1) > > + return -1; > > + > > + if (*minimum == 0) { /* No constraints set by the plugin. */ > > + *minimum = 1; > > + *preferred = blksize; > > + *maximum = 0xffffffff; > > + } > > + else if (*maximum >= blksize) { > > Do we need braces here? > > > + *preferred = MAX (*preferred, blksize); > > + }I don't think we need them, but it might be clearer with them. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Laszlo Ersek
2022-Feb-21 14:19 UTC
[Libguestfs] [PATCH nbdkit] cache, cow: Export block size constraints
On 02/21/22 11:22, Richard W.M. Jones wrote:> On Mon, Feb 21, 2022 at 10:22:04AM +0100, Laszlo Ersek wrote: >>> +/* Block size constraints. */ >>> +static int >>> +cache_block_size (nbdkit_next *next, void *handle, >>> + uint32_t *minimum, uint32_t *preferred, uint32_t *maximum) >>> +{ >>> + if (next->block_size (next, minimum, preferred, maximum) == -1) >>> + return -1; >>> + >>> + if (*minimum == 0) { /* No constraints set by the plugin. */ >>> + *minimum = 1; >>> + *preferred = blksize; >>> + *maximum = 0xffffffff; >>> + } >>> + else if (*maximum >= blksize) { >> >> Do we need braces here? >> >>> + *preferred = MAX (*preferred, blksize); >>> + } > > I don't think we need them, but it might be clearer with them.Sorry, I'm still a bit confused whether braces around single statements are *permitted* -- the rule even seems to vary across the various v2v projects. My understanding has been that we forbid braces around single statements, at least in some projects. So what's the rule? Thanks, Laszlo