On Mon, Nov 06, 2023 at 09:09:28AM +0000, Daniel P. Berrangé wrote:
On Fri, Nov 03, 2023 at 03:44:44PM -0500, Eric Blake wrote:
On Fri, Nov 03, 2023 at 08:32:41PM +0000, Richard W.M. Jones wrote:
It's better to update the 'b' pointer and the 'offset' using the calculated increment 'n', rather than using '8-o' which might be larger than the remainder of the buffer. Previously we could create a dangling pointer beyond the end of the output buffer, and this should not matter, but it's best not to do this if we can easily avoid it.
Also improve the test by replacing qemu-io with nbdsh. It is able to make non-aligned requests so we can now test those. --- plugins/pattern/pattern.c | 4 +- tests/test-pattern.sh | 129 ++++++++++++++++++++++---------------- 2 files changed, 77 insertions(+), 56 deletions(-)
+ +# Run nbdkit-pattern-plugin. Use a disk > 4G so we can test 2G and 4G +# boundaries. +nbdkit pattern 5G --run 'nbdsh -u "$uri" -c -' <<EOF + +# Generate the expected pattern in the given range. +# This only works for 8-byte aligned ranges. +def generated_expected(start,end):
I think Python prefers a space after that comma.
FWIW, rather than reviewing code style, I can recommend just feeding any python code through 'black'. It is an opinionated python code formatter intended to bring a consistent style to all python programs.
We use flake8 in the test suite, but it doesn't catch code embedded inside shell scripts as happens here. I had a look at the documentation just now but it doesn't seem there's any way to do that. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v