On Mon, Nov 06, 2023 at 10:33:13AM +0000, Richard W.M. Jones wrote:
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.
flake8 and black are complementary tools. Black exclusively considers code formatting/layout, while flake8 does more semantic analysis. So would typically run both of them. They only clash in a couple of places and that's avoided with a $GITROOT/.flake8 config file [flake8] max-line-length = 88 extend-ignore = E203,W503 With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|