Skip to contentSkip to conversation

Trivial fixes and clean ups

PATCH Applied Cleber Rosa 9 participants 41 messages Oct 4, 2018 – Oct 26, 2018

lore
Share & tools
lore
#0 lore raw

cover Trivial fixes and clean ups

Just a collection of trivial fixes and clean ups that have been lying around here for some time.

Cleber Rosa (10):
qemu-img.c: comment typo fix
tests/tcg/README: fix location for lm32 tests
qemu-iotests: make 218 executable
qemu-iotests: fix filename containing checks docs/devel/testing.rst: add missing newlines after code block thunk.c: clean up commented out definition scripts/decodetree.py: remove unused imports scripts/decodetree.py: fix reference to attributes scripts/qemu.py: use a more consistent docstring style scripts/qemu.py: remove trailing quotes on docstring

 docs/devel/testing.rst       |  2 ++
 dtc                          |  2 +-
 qemu-img.c                   |  2 +-
 scripts/decodetree.py        |  4 +--
 scripts/qemu.py              | 67 ++++++++++++++++++++++--------------
 tests/qemu-iotests/218       |  0
 tests/qemu-iotests/common.rc |  4 +--
 tests/tcg/README             |  2 +-
 thunk.c                      |  2 --
 9 files changed, 50 insertions(+), 35 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/10 qemu-img.c: comment typo fix

A trivial comment typo fix.

---
 qemu-img.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +1 -1
index b12f4cd19b..a96b76c187 100644
@@ -1085,7 +1085,7 @@ static int64_t find_nonzero(const uint8_t *buf, int64_t n)
 }
 
 /*
- * Returns true iff the first sector pointed to by 'buf' contains at least
+ * Returns true if the first sector pointed to by 'buf' contains at least
  * a non-NUL byte.
  *
  * 'pnum' is set to the number of sectors (including and immediately following
Signature · 1 line
2.17.1
#2 lore raw

Re: [Qemu-devel] [PATCH 01/10] qemu-img.c: comment typo fix

Quoted 12 lines · Cleber Rosa

A trivial comment typo fix.

---
  qemu-img.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +0 -0
index b12f4cd19b..a96b76c187 100644

qemu-img.c static int64_t find_nonzero(const uint8_t *buf, int64_t n) · line 1088

Quoted 5 lines
qemu-img.c +1 -1
@@ -1085,7 +1085,7 @@ static int64_t find_nonzero(const uint8_t *buf, int64_t n)
  }
 
  /*
- * Returns true iff the first sector pointed to by 'buf' contains at least
+ * Returns true if the first sector pointed to by 'buf' contains at least

NACK. You're not the first person to propose this change. However, "iff" is an English word (albeit archaic) which is shorthand for "if and only if", which has a distinct logical meaning separate from the weaker "if". Spelling it out in longhand instead of calling it a typo is probably acceptable, though.

Quoted 4 lines
qemu-img.c +0 -0
   * a non-NUL byte.
   *
   * 'pnum' is set to the number of sectors (including and immediately following
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH 01/10] qemu-img.c: comment typo fix

Quoted 18 lines · Eric Blake
Quoted 17 lines · Cleber Rosa

A trivial comment typo fix.

---
  qemu-img.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +0 -1
index b12f4cd19b..a96b76c187 100644
@@ -1085,7 +1085,7 @@ static int64_t find_nonzero(const uint8_t *buf,
 int64_t n)
   }
     /*
- * Returns true iff the first sector pointed to by 'buf' contains at

least

Quoted 9 lines
Quoted 2 lines

+ * Returns true if the first sector pointed to by 'buf' contains at least

NACK.  You're not the first person to propose this change.  However, "iff" is an English word (albeit archaic) which is shorthand for "if and only if", which has a distinct logical meaning separate from the weaker "if".  Spelling it out in longhand instead of calling it a typo is probably acceptable, though.

Wow, thanks for the explanation. I agree that spelling it out is a good option, as it'll probably prevent other people from falling into the same "language trap" as I did.

Thanks!
- Cleber.

#4 lore raw

Re: [Qemu-devel] [PATCH 01/10] qemu-img.c: comment typo fix

Quoted 28 lines · Eric Blake
Quoted 18 lines · Cleber Rosa
Quoted 17 lines

A trivial comment typo fix.

---
  qemu-img.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
qemu-img.c +0 -1
index b12f4cd19b..a96b76c187 100644
@@ -1085,7 +1085,7 @@ static int64_t find_nonzero(const uint8_t *buf,
 int64_t n)
   }
     /*
- * Returns true iff the first sector pointed to by 'buf' contains at

least

Quoted 9 lines
Quoted 2 lines

+ * Returns true if the first sector pointed to by 'buf' contains at least

NACK.  You're not the first person to propose this change.  However, "iff" is an English word (albeit archaic) which is shorthand for "if and only if", which has a distinct logical meaning separate from the weaker "if".  Spelling it out in longhand instead of calling it a typo is probably acceptable, though.

Quoted 3 lines

Wow, thanks for the explanation. I agree that spelling it out is a good option, as it'll probably prevent other people from falling into the same "language trap" as I did.

https://lists.gnu.org/archive/html/qemu-devel/2011-06/msg01269.html

https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg04200.html

;)

#5 lore raw

Re: [Qemu-devel] [PATCH 01/10] qemu-img.c: comment typo fix

In reply to Eric Blake
Quoted 6 lines · Eric Blake
Quoted 4 lines · Cleber Rosa

A trivial comment typo fix.

Quoted 16 lines
Quoted 9 lines
qemu-img.c +0 -1
@@ -1085,7 +1085,7 @@ static int64_t find_nonzero(const uint8_t *buf,
 int64_t n)
  }
    /*
- * Returns true iff the first sector pointed to by 'buf' contains at

least
+ * Returns true if the first sector pointed to by 'buf' contains at least

NACK. You're not the first person to propose this change. However, "iff" is an English word (albeit archaic) which is shorthand for "if and only if", which has a distinct logical meaning separate from the weaker "if". Spelling it out in longhand instead of calling it a typo is probably acceptable, though.

Yes; if you happen to have a mathematical background then it's a familiar abbreviation; but otherwise it isn't, and it's more confusing than helpful I think. (I don't think it's archaic; it's just commonly used in university-and-higher-level maths and not elsewhere.)

git grep '\Wiff\W'
shows a surprisingly large number of uses. (NB that some of those are in 3rd-party code, notably the libdecnumber stuff, and should probably not be changed.)

thanks
-- PMM

#6 lore raw

PATCH 2/10 tests/tcg/README: fix location for lm32 tests

In reply to Cleber Rosa

Point to the right and obvious location for lm32 tests.

---
 tests/tcg/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/README +1 -1
index a5643d33e7..2a58f9a058 100644
@@ -10,6 +10,6 @@ with "make test-cris".
 
 LM32
 ====
-The testsuite for LM32 is in tests/tcg/cris.  You can run it
+The testsuite for LM32 is in tests/tcg/lm32.  You can run it
 with "make test-lm32".
 
Signature · 1 line
2.17.1
Reviewed-by on v1 2/10
#7 lore raw

Re: [Qemu-devel] [PATCH 02/10] tests/tcg/README: fix location for lm32 tests

Quoted 12 lines · Cleber Rosa

Point to the right and obvious location for lm32 tests.

---
 tests/tcg/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/README +0 -0
index a5643d33e7..2a58f9a058 100644

tests/tcg/README with "make test-cris". · line 14

Quoted 6 lines
tests/tcg/README +1 -1
@@ -10,6 +10,6 @@ with "make test-cris".
 
 LM32
 ====
-The testsuite for LM32 is in tests/tcg/cris.  You can run it
+The testsuite for LM32 is in tests/tcg/lm32.  You can run it
 with "make test-lm32".
Acked-by on v1 2/10
#8 lore raw

Re: [Qemu-devel] [PATCH 02/10] tests/tcg/README: fix location for lm32 tests

In reply to Cleber Rosa
Quoted 12 lines · Cleber Rosa

Point to the right and obvious location for lm32 tests.

---
 tests/tcg/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/README +0 -0
index a5643d33e7..2a58f9a058 100644

tests/tcg/README with "make test-cris". · line 14

Quoted 6 lines
tests/tcg/README +1 -1
@@ -10,6 +10,6 @@ with "make test-cris".
 
 LM32
 ====
-The testsuite for LM32 is in tests/tcg/cris.  You can run it
+The testsuite for LM32 is in tests/tcg/lm32.  You can run it
 with "make test-lm32".

It's a correct fix, although I note running "make test-lm32" doesn't do much either in the top of the build dir or in that directory. It's probably best to drop the second line until I fix it.

--
Alex Bennée

#9 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 02/10] tests/tcg/README: fix location for lm32 tests

In reply to Cleber Rosa
Quoted 13 lines · Cleber Rosa

Point to the right and obvious location for lm32 tests.

---
 tests/tcg/README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/README +0 -0
index a5643d33e7..2a58f9a058 100644

tests/tcg/README with "make test-cris". · line 15

Quoted 7 lines
tests/tcg/README +1 -1
@@ -10,6 +10,6 @@ with "make test-cris".
 
 LM32
 ====
-The testsuite for LM32 is in tests/tcg/cris.  You can run it
+The testsuite for LM32 is in tests/tcg/lm32.  You can run it
 with "make test-lm32".
 

Applied

Thanks,
Laurent

#10 lore raw

PATCH 3/10 qemu-iotests: make 218 executable

In reply to Cleber Rosa

Commit 990dc39c made all tests executable at the time, but 218 came in later, and missing those permissions.

---
 tests/qemu-iotests/218 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218
tests/qemu-iotests/218 +0 -0
old mode 100644
new mode 100755
Signature · 1 line
2.17.1
Reviewed-by on v1 3/10
#11 lore raw

Re: [Qemu-devel] [PATCH 03/10] qemu-iotests: make 218 executable

tests/qemu-iotests/218

Quoted 12 lines · Cleber Rosa

Commit 990dc39c made all tests executable at the time, but 218 came in later, and missing those permissions.

---
  tests/qemu-iotests/218 | 0
  1 file changed, 0 insertions(+), 0 deletions(-)

mode change 100644 => 100755 tests/qemu-iotests/218

tests/qemu-iotests/218 +0 -0
old mode 100644
new mode 100755
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#12 lore raw

Re: [Qemu-devel] [PATCH 03/10] qemu-iotests: make 218 executable

In reply to Cleber Rosa

tests/qemu-iotests/218

Quoted 12 lines · Cleber Rosa

Commit 990dc39c made all tests executable at the time, but 218 came in later, and missing those permissions.

---
 tests/qemu-iotests/218 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218
tests/qemu-iotests/218 +0 -0
old mode 100644
new mode 100755

We could add a git pre-commit hook grep'ing for "^#!\
*(/usr/bin/env|/bin/(b?a)?sh)" in the 1st line and then checking the file perms.

#13 lore raw

Re: [Qemu-devel] [PATCH 03/10] qemu-iotests: make 218 executable

Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Cleber Rosa

Commit 990dc39c made all tests executable at the time, but 218 came in later, and missing those permissions.

---
 tests/qemu-iotests/218 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218
Quoted 8 lines

tests/qemu-iotests/218

Quoted 3 lines
tests/qemu-iotests/218 +0 -0
old mode 100644
new mode 100755

We could add a git pre-commit hook grep'ing for "^#!\
*(/usr/bin/env|/bin/(b?a)?sh)" in the 1st line and then checking the file perms.

Good idea. Probably better to send that as a different patch, right?

#14 lore raw

Re: [Qemu-devel] [PATCH 03/10] qemu-iotests: make 218 executable

Quoted 7 lines · Cleber Rosa
Quoted 5 lines

We could add a git pre-commit hook grep'ing for "^#!\
*(/usr/bin/env|/bin/(b?a)?sh)" in the 1st line and then checking the file perms.

Good idea. Probably better to send that as a different patch, right?

Yes, separate patch. For that matter, "^#!/" is probably a sufficient pattern to catch any file that intends to be run via an interpreter, and therefore wants to be executable, rather than limiting to just env and specific shells.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#15 lore raw

Re: [Qemu-devel] [PATCH 03/10] qemu-iotests: make 218 executable

Quoted 11 lines · Eric Blake
Quoted 7 lines · Cleber Rosa
Quoted 5 lines

We could add a git pre-commit hook grep'ing for "^#!\
*(/usr/bin/env|/bin/(b?a)?sh)" in the 1st line and then checking the file perms.

Good idea.  Probably better to send that as a different patch, right?

Yes, separate patch. For that matter, "^#!/" is probably a sufficient pattern to catch any file that intends to be run via an interpreter, and therefore wants to be executable, rather than limiting to just env and specific shells.

Also, many maintainers already have scripts/checkpatch.pl as a git pre-commit hook, and putting the check in checkpatch.pl means that patchew would also flag the issue.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#16 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 03/10] qemu-iotests: make 218 executable

In reply to Cleber Rosa

tests/qemu-iotests/218

Quoted 13 lines · Cleber Rosa

Commit 990dc39c made all tests executable at the time, but 218 came in later, and missing those permissions.

---
 tests/qemu-iotests/218 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/218
tests/qemu-iotests/218 +0 -0
old mode 100644
new mode 100755

Applied

Thanks,
Laurent

#17 lore raw

PATCH 4/10 qemu-iotests: fix filename containing checks

In reply to Cleber Rosa

Commit cce293a2945 moved some functions from common.config to common.rc, but the error messages still reference the old file location.

---
 tests/qemu-iotests/common.rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/common.rc +2 -2
index 44bee16a5e..70ca65b49b 100644
@@ -170,7 +170,7 @@ if [ ! -e "$TEST_DIR" ]; then
 fi
 
 if [ ! -d "$TEST_DIR" ]; then
-    echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
+    echo "common.rc: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
     exit 1
 fi
 
@@ -179,7 +179,7 @@ if [ -z "$REMOTE_TEST_DIR" ]; then
 fi
 
 if [ ! -d "$SAMPLE_IMG_DIR" ]; then
-    echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
+    echo "common.rc: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
     exit 1
 fi
 
Signature · 1 line
2.17.1
Reviewed-by on v1 4/10
#18 lore raw

Re: [Qemu-devel] [PATCH 04/10] qemu-iotests: fix filename containing checks

Quoted 5 lines · Cleber Rosa

Commit cce293a2945 moved some functions from common.config to common.rc, but the error messages still reference the old file location.

Quoted 27 lines
---
 tests/qemu-iotests/common.rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/common.rc +2 -2
index 44bee16a5e..70ca65b49b 100644
@@ -170,7 +170,7 @@ if [ ! -e "$TEST_DIR" ]; then
 fi
 
 if [ ! -d "$TEST_DIR" ]; then
-    echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
+    echo "common.rc: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
     exit 1
 fi
 
@@ -179,7 +179,7 @@ if [ -z "$REMOTE_TEST_DIR" ]; then
 fi
 
 if [ ! -d "$SAMPLE_IMG_DIR" ]; then
-    echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
+    echo "common.rc: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
     exit 1
 fi
 
#19 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 04/10] qemu-iotests: fix filename containing checks

In reply to Cleber Rosa
Quoted 8 lines · Cleber Rosa

Commit cce293a2945 moved some functions from common.config to common.rc, but the error messages still reference the old file location.

---
 tests/qemu-iotests/common.rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied

Thanks,
Laurent

#20 lore raw

PATCH 5/10 docs/devel/testing.rst: add missing newlines after code block

In reply to Cleber Rosa

The line immediate following a ".. code::" block is considered to contains arguments to the "code directive". The lack of a new line gives me during at parse time:

testing.rst:63: (ERROR/3) Error in "code" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. code::
make check-unit V=1

testing.rst:120: (ERROR/3) Error in "code" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. code::
make check-qtest V=1

Let's add the missing newlines, both for consistency and to avoid the parsing errors.

---
 docs/devel/testing.rst | 2 ++
 1 file changed, 2 insertions(+)
docs/devel/testing.rst +2 -0
index 727c4019b5..9355ad49f2 100644
@@ -61,6 +61,7 @@ variable (which affects memory reclamation and catches invalid pointers better)
 and gtester options. If necessary, you can run
 
 .. code::
+
   make check-unit V=1
 
 and copy the actual command line which executes the unit test, then run
@@ -118,6 +119,7 @@ and using gdb on the test is still simple to do: find out the actual command
 from the output of
 
 .. code::
+
   make check-qtest V=1
 
 which you can run manually.
Signature · 1 line
2.17.1
Reviewed-by on v1 5/10
#21 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH 05/10] docs/devel/testing.rst: add missing newlines after code block

Quoted 7 lines · Cleber Rosa

The line immediate following a ".. code::" block is considered to contains arguments to the "code directive". The lack of a new line gives me during at parse time:

testing.rst:63: (ERROR/3) Error in "code" directive:
maximum 1 argument(s) allowed, 3 supplied.

Quoted 9 lines

.. code::
make check-unit V=1

testing.rst:120: (ERROR/3) Error in "code" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. code::
make check-qtest V=1

pandoc doesn't complain, but rst.ninjs.org does. What tool did you use to find these? we should formalize a formatting checker for rst files.

Actually, we should formalize building our RST docs at all...

--js

Quoted 4 lines

Let's add the missing newlines, both for consistency and to avoid the parsing errors.

#22 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 05/10] docs/devel/testing.rst: add missing newlines after code block

In reply to Cleber Rosa
Quoted 38 lines · Cleber Rosa

The line immediate following a ".. code::" block is considered to contains arguments to the "code directive". The lack of a new line gives me during at parse time:

testing.rst:63: (ERROR/3) Error in "code" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. code::
make check-unit V=1

testing.rst:120: (ERROR/3) Error in "code" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. code::
make check-qtest V=1

Let's add the missing newlines, both for consistency and to avoid the parsing errors.

---
 docs/devel/testing.rst | 2 ++
 1 file changed, 2 insertions(+)
docs/devel/testing.rst +1 -0
index 727c4019b5..9355ad49f2 100644
@@ -61,6 +61,7 @@ variable (which affects memory reclamation and catches invalid pointers better)
 and gtester options. If necessary, you can run
 
 .. code::
+
   make check-unit V=1
 
 and copy the actual command line which executes the unit test, then run

docs/devel/testing.rst and using gdb on the test is still simple to do: find out the actual command · line 125

Quoted 7 lines
docs/devel/testing.rst +1 -0
@@ -118,6 +119,7 @@ and using gdb on the test is still simple to do: find out the actual command
 from the output of
 
 .. code::
+
   make check-qtest V=1
 
 which you can run manually.

Applied

Thanks,
Laurent

#23 lore raw

PATCH 6/10 thunk.c: clean up commented out definition

In reply to Cleber Rosa
---
 thunk.c | 2 --
 1 file changed, 2 deletions(-)
thunk.c +0 -2
index d5d8645cd4..e351ae53af 100644
@@ -21,8 +21,6 @@
 #include "qemu.h"
 #include "exec/user/thunk.h"
 
-//#define DEBUG
-
 static unsigned int max_struct_entries;
 StructEntry *struct_entries;
 
Signature · 1 line
2.17.1
#24 lore raw

Re: [Qemu-devel] [PATCH 06/10] thunk.c: clean up commented out definition

Le 04/10/2018 à 18:18, Cleber Rosa a écrit :

Quoted 10 lines
---
 thunk.c | 2 --
 1 file changed, 2 deletions(-)
thunk.c +0 -0
index d5d8645cd4..e351ae53af 100644

thunk.c line 25

Quoted 5 lines
thunk.c +0 -2
@@ -21,8 +21,6 @@
 #include "qemu.h"
 #include "exec/user/thunk.h"
 
-//#define DEBUG
-

Generally we use that to enable easily existing debug traces.

In this case, if you remove the "#define" I think you should also replace the "#ifdef DEBUG"s by some trace_XXXX() functions.

Thanks,
Laurent

#25 lore raw

Re: [Qemu-devel] [PATCH 06/10] thunk.c: clean up commented out definition

Quoted 14 lines · Laurent Vivier

Le 04/10/2018 à 18:18, Cleber Rosa a écrit :

Quoted 13 lines
---
 thunk.c | 2 --
 1 file changed, 2 deletions(-)
thunk.c +0 -0
index d5d8645cd4..e351ae53af 100644
@@ -21,8 +21,6 @@
 #include "qemu.h"
 #include "exec/user/thunk.h"
 
Quoted 5 lines

thunk.c line 25

Quoted 2 lines
thunk.c +0 -2
-//#define DEBUG
-

Generally we use that to enable easily existing debug traces.

Oh, I wasn't aware that was intentional (I clearly lack some background here).

Quoted 3 lines

In this case, if you remove the "#define" I think you should also replace the "#ifdef DEBUG"s by some trace_XXXX() functions.

Is that desirable? I don't want to disrupt the status quo just because it looked odd to me.

Thanks!
- Cleber.

Quoted 3 lines

Thanks,
Laurent

#26 lore raw

Re: [Qemu-devel] [PATCH 06/10] thunk.c: clean up commented out definition

Le 04/10/2018 à 18:31, Cleber Rosa a écrit :

Quoted 26 lines · Laurent Vivier
Quoted 14 lines

Le 04/10/2018 à 18:18, Cleber Rosa a écrit :

Quoted 13 lines
---
 thunk.c | 2 --
 1 file changed, 2 deletions(-)
thunk.c +0 -0
index d5d8645cd4..e351ae53af 100644
@@ -21,8 +21,6 @@
 #include "qemu.h"
 #include "exec/user/thunk.h"
 
Quoted 5 lines

thunk.c line 25

Quoted 2 lines
thunk.c +0 -2
-//#define DEBUG
-

Generally we use that to enable easily existing debug traces.

Oh, I wasn't aware that was intentional (I clearly lack some background here).

Quoted 6 lines
Quoted 3 lines

In this case, if you remove the "#define" I think you should also replace the "#ifdef DEBUG"s by some trace_XXXX() functions.

Is that desirable? I don't want to disrupt the status quo just because it looked odd to me.

Yes, it's better to have trace_XXX() functions than DEBUG macros. The change is trivial (add the format strings in ./trace-events and call them from thunk.c with the existing parameters)

Thanks,
Laurent

#27 lore raw

PATCH 7/10 scripts/decodetree.py: remove unused imports

In reply to Cleber Rosa
---
 scripts/decodetree.py | 2 --
 1 file changed, 2 deletions(-)
scripts/decodetree.py +0 -2
index 277f9a9bba..457cffea90 100755
@@ -149,12 +149,10 @@
 #   trans_addl_i(ctx, &arg_opi, insn)
 #
 
-import io
 import os
 import re
 import sys
 import getopt
-import pdb
 
 insnwidth = 32
 insnmask = 0xffffffff
Signature · 1 line
2.17.1
Reviewed-by on v1 7/10
#28 lore raw

Re: [Qemu-devel] [PATCH 07/10] scripts/decodetree.py: remove unused imports

Quoted 1 line · Cleber Rosa
Quoted 22 lines
---
 scripts/decodetree.py | 2 --
 1 file changed, 2 deletions(-)
scripts/decodetree.py +0 -2
index 277f9a9bba..457cffea90 100755
@@ -149,12 +149,10 @@
 #   trans_addl_i(ctx, &arg_opi, insn)
 #
 
-import io
 import os
 import re
 import sys
 import getopt
-import pdb
 
 insnwidth = 32
 insnmask = 0xffffffff
#29 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 07/10] scripts/decodetree.py: remove unused imports

In reply to Cleber Rosa
Quoted 13 lines · Cleber Rosa
---
 scripts/decodetree.py | 2 --
 1 file changed, 2 deletions(-)
scripts/decodetree.py +0 -0
index 277f9a9bba..457cffea90 100755
@@ -149,12 +149,10 @@
 #   trans_addl_i(ctx, &arg_opi, insn)
 #

scripts/decodetree.py line 158

Quoted 10 lines
scripts/decodetree.py +0 -2
 
-import io
 import os
 import re
 import sys
 import getopt
-import pdb
 
 insnwidth = 32
 insnmask = 0xffffffff

Applied

Thanks,
Laurent

#30 lore raw

PATCH 8/10 scripts/decodetree.py: fix reference to attributes

In reply to Cleber Rosa
---
 scripts/decodetree.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/decodetree.py +1 -1
index 457cffea90..37c76b5507 100755
@@ -298,7 +298,7 @@ class Field:
             s = 's'
         else:
             s = ''
-        return str(pos) + ':' + s + str(len)
+        return str(self.pos) + ':' + s + str(self.len)
 
     def str_extract(self):
         if self.sign:
Signature · 1 line
2.17.1
Reviewed-by on v1 8/10
#31 lore raw

Re: [Qemu-devel] [PATCH 08/10] scripts/decodetree.py: fix reference to attributes

Quoted 1 line · Cleber Rosa
Quoted 18 lines
---
 scripts/decodetree.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/decodetree.py +1 -1
index 457cffea90..37c76b5507 100755
@@ -298,7 +298,7 @@ class Field:
             s = 's'
         else:
             s = ''
-        return str(pos) + ':' + s + str(len)
+        return str(self.pos) + ':' + s + str(self.len)
 
     def str_extract(self):
         if self.sign:
#32 lore raw

PATCH 9/10 scripts/qemu.py: use a more consistent docstring style

In reply to Cleber Rosa
---
 dtc             |  2 +-
 scripts/qemu.py | 65 +++++++++++++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 25 deletions(-)
dtc +1 -1
index 88f18909db..e54388015a 160000
@@ -1 +1 @@
-Subproject commit 88f18909db731a627456f26d779445f84e449536
+Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
scripts/qemu.py +41 -24

180 lines not on this page · raw message

Signature · 1 line
2.17.1
#33 lore raw

Re: [Qemu-devel] [PATCH 09/10] scripts/qemu.py: use a more consistent docstring style

dtc line 1

Quoted 13 lines · Cleber Rosa
---
  dtc             |  2 +-
  scripts/qemu.py | 65 +++++++++++++++++++++++++++++++------------------
  2 files changed, 42 insertions(+), 25 deletions(-)
dtc +1 -1
index 88f18909db..e54388015a 160000
@@ -1 +1 @@
-Subproject commit 88f18909db731a627456f26d779445f84e449536
+Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42

The submodule change was probably unintended.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#34 lore raw

Re: [Qemu-devel] [PATCH 09/10] scripts/qemu.py: use a more consistent docstring style

Quoted 7 lines · Eric Blake
Quoted 6 lines · Cleber Rosa

---
  dtc             |  2 +-
  scripts/qemu.py | 65 +++++++++++++++++++++++++++++++------------------

  2 files changed, 42 insertions(+), 25 deletions(-)
Quoted 10 lines

dtc line 1

Quoted 7 lines
dtc +1 -1
index 88f18909db..e54388015a 160000
@@ -1 +1 @@
-Subproject commit 88f18909db731a627456f26d779445f84e449536
+Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42

The submodule change was probably unintended.

Yep, my bad.

#35 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH 09/10] scripts/qemu.py: use a more consistent docstring style

In reply to Cleber Rosa
Quoted 18 lines · Cleber Rosa
---
 dtc             |  2 +-
 scripts/qemu.py | 65 +++++++++++++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 25 deletions(-)
dtc +1 -1
index 88f18909db..e54388015a 160000
@@ -1 +1 @@
-Subproject commit 88f18909db731a627456f26d779445f84e449536
+Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
scripts/qemu.py +0 -0
index f099ce7278..7abe26de69 100644

scripts/qemu.py class QEMUMachineAddDeviceError(QEMUMachineError): · line 58

Quoted 8 lines
scripts/qemu.py +2 -2
@@ -53,9 +53,9 @@ class QEMUMachineAddDeviceError(QEMUMachineError):
     """
 
 class MonitorResponseError(qmp.qmp.QMPError):
-    '''
+    """
     Represents erroneous QMP monitor reply
-    '''
+    """

This seems obviously correct, as per the Python Dogma Handbook ...

Quoted 8 lines
scripts/qemu.py +0 -1
     def __init__(self, reply):
         try:
             desc = reply["error"]["desc"]
@@ -66,14 +66,15 @@ class MonitorResponseError(qmp.qmp.QMPError):
 
 
 class QEMUMachine(object):
-    '''A QEMU VM

scripts/qemu.py class MonitorResponseError(qmp.qmp.QMPError): · line 77

Quoted 10 lines
scripts/qemu.py +3 -1
+    """
+    A QEMU VM
 
     Use this object as a context manager to ensure the QEMU process terminates::
 
         with VM(binary) as vm:
...
         # vm is guaranteed to be shut down here
-    '''
+    """

As does this,,

scripts/qemu.py class QEMUMachine(object): · line 141

Quoted 11 lines

def __init__(self, binary, args=None, wrapper=None, name=None,
test_dir="/var/tmp", monitor_address=None,

scripts/qemu.py +3 -1
@@ -135,7 +136,9 @@ class QEMUMachine(object):
         self._args.append(args)
 
     def add_fd(self, fd, fdset, opaque, opts=''):
-        '''Pass a file descriptor to the VM'''
+        """
+        Pass a file descriptor to the VM
+        """

However, is it established practice among ne'er-do-wells to format one-line docstrings as three-liners? (And without punctuation to boot -- for shame!)

PEP257 suggests that one-liners are allowed, but doesn't seem to necessitate their usage. Does this kind of change have any kind of benefit?

Quoted 156 lines
scripts/qemu.py +33 -19
         options = ['fd=%d' % fd,
                    'set=%d' % fdset,
                    'opaque=%s' % opaque]
@@ -168,7 +171,9 @@ class QEMUMachine(object):
 
     @staticmethod
     def _remove_if_exists(path):
-        '''Remove file object at path if it exists'''
+        """
+        Remove file object at path if it exists
+        """
         try:
             os.remove(path)
         except OSError as exception:
@@ -271,7 +276,9 @@ class QEMUMachine(object):
             raise
 
     def _launch(self):
-        '''Launch the VM and establish a QMP connection'''
+        """
+        Launch the VM and establish a QMP connection
+        """
         devnull = open(os.path.devnull, 'rb')
         self._pre_launch()
         self._qemu_full_args = (self._wrapper + [self._binary] +
@@ -284,14 +291,18 @@ class QEMUMachine(object):
         self._post_launch()
 
     def wait(self):
-        '''Wait for the VM to power off'''
+        """
+        Wait for the VM to power off
+        """
         self._popen.wait()
         self._qmp.close()
         self._load_io_log()
         self._post_shutdown()
 
     def shutdown(self):
-        '''Terminate the VM and clean up'''
+        """
+        Terminate the VM and clean up
+        """
         if self.is_running():
             try:
                 self._qmp.cmd('quit')
@@ -315,7 +326,9 @@ class QEMUMachine(object):
         self._launched = False
 
     def qmp(self, cmd, conv_keys=True, **args):
-        '''Invoke a QMP command and return the response dict'''
+        """
+        Invoke a QMP command and return the response dict
+        """
         qmp_args = dict()
         for key, value in args.items():
             if conv_keys:
@@ -326,11 +339,11 @@ class QEMUMachine(object):
         return self._qmp.cmd(cmd, args=qmp_args)
 
     def command(self, cmd, conv_keys=True, **args):
-        '''
+        """
         Invoke a QMP command.
         On success return the response dict.
         On failure raise an exception.
-        '''
+        """
         reply = self.qmp(cmd, conv_keys, **args)
         if reply is None:
             raise qmp.qmp.QMPError("Monitor is closed")
@@ -339,13 +352,17 @@ class QEMUMachine(object):
         return reply["return"]
 
     def get_qmp_event(self, wait=False):
-        '''Poll for one queued QMP events and return it'''
+        """
+        Poll for one queued QMP events and return it
+        """
         if len(self._events) > 0:
             return self._events.pop(0)
         return self._qmp.pull_event(wait=wait)
 
     def get_qmp_events(self, wait=False):
-        '''Poll for queued QMP events and return a list of dicts'''
+        """
+        Poll for queued QMP events and return a list of dicts
+        """
         events = self._qmp.get_events(wait=wait)
         events.extend(self._events)
         del self._events[:]
@@ -353,7 +370,7 @@ class QEMUMachine(object):
         return events
 
     def event_wait(self, name, timeout=60.0, match=None):
-        '''
+        """
         Wait for specified timeout on named event in QMP; optionally filter
         results by match.
 
@@ -361,7 +378,7 @@ class QEMUMachine(object):
         branch processing on match's value None
            {"foo": {"bar": 1}} matches {"foo": None}
            {"foo": {"bar": 1}} does not matches {"foo": {"baz": None}}
-        '''
+        """
         def event_match(event, match=None):
             if match is None:
                 return True
@@ -394,29 +411,29 @@ class QEMUMachine(object):
         return None
 
     def get_log(self):
-        '''
+        """
         After self.shutdown or failed qemu execution, this returns the output
         of the qemu process.
-        '''
+        """
         return self._iolog
 
     def add_args(self, *args):
-        '''
+        """
         Adds to the list of extra arguments to be given to the QEMU binary
-        '''
+        """
         self._args.extend(args)
 
     def set_machine(self, machine_type):
-        '''
+        """
         Sets the machine type
 
         If set, the machine type will be added to the base arguments
         of the resulting QEMU command line.
-        '''
+        """
         self._machine = machine_type
 
     def set_console(self, device_type=None):
-        '''
+        """
         Sets the device type for a console device
 
         If set, the console device and a backing character device will
@@ -434,7 +451,7 @@ class QEMUMachine(object):
         @param device_type: the device type, such as "isa-serial"
         @raises: QEMUMachineAddDeviceError if the device type is not given
                  and can not be determined.
-        '''
+        """
         if device_type is None:
             if self._machine is None:
                 raise QEMUMachineAddDeviceError("Can not add a console device:"
#36 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH 09/10] scripts/qemu.py: use a more consistent docstring style

Quoted 32 lines · John Snow
Quoted 18 lines · Cleber Rosa
---
 dtc             |  2 +-
 scripts/qemu.py | 65 +++++++++++++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 25 deletions(-)
dtc +1 -1
index 88f18909db..e54388015a 160000
@@ -1 +1 @@
-Subproject commit 88f18909db731a627456f26d779445f84e449536
+Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
scripts/qemu.py +0 -0
index f099ce7278..7abe26de69 100644

scripts/qemu.py class QEMUMachineAddDeviceError(QEMUMachineError): · line 58

Quoted 8 lines
scripts/qemu.py +2 -2
@@ -53,9 +53,9 @@ class QEMUMachineAddDeviceError(QEMUMachineError):
     """
 
 class MonitorResponseError(qmp.qmp.QMPError):
-    '''
+    """
     Represents erroneous QMP monitor reply
-    '''
+    """

This seems obviously correct, as per the Python Dogma Handbook ...

[...]

Quoted 6 lines

scripts/qemu.py class QEMUMachine(object): · line 141

Quoted 5 lines

def add_fd(self, fd, fdset, opaque, opts=''):

scripts/qemu.py +3 -1
-        '''Pass a file descriptor to the VM'''
+        """
+        Pass a file descriptor to the VM
+        """
Quoted 6 lines

However, is it established practice among ne'er-do-wells to format one-line docstrings as three-liners? (And without punctuation to boot -- for shame!)

PEP257 suggests that one-liners are allowed, but doesn't seem to necessitate their usage. Does this kind of change have any kind of benefit?

I don't mind having one-line docstrings. But if we're already touching multiple docstrings, consistency with the rest of the module code sounds nice.

I'm queueing this on python-next.

Signature · 1 line
Eduardo
#37 lore raw

PATCH 10/10 scripts/qemu.py: remove trailing quotes on docstring

In reply to Cleber Rosa
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu.py +1 -1
index 7abe26de69..676eb9709a 100644
@@ -88,7 +88,7 @@ class QEMUMachine(object):
         @param name: prefix for socket and log file names (default: qemu-PID)
         @param test_dir: where to create socket and log file
         @param monitor_address: address for QMP monitor
-        @param socket_scm_helper: helper program, required for send_fd_scm()"
+        @param socket_scm_helper: helper program, required for send_fd_scm()
         @note: Qemu process is not started until launch() is used.
         '''
         if args is None:
Signature · 1 line
2.17.1
Reviewed-by on v1 10/10
#38 lore raw

Re: [Qemu-devel] [PATCH 10/10] scripts/qemu.py: remove trailing quotes on docstring

Quoted 1 line · Cleber Rosa
Quoted 18 lines
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu.py +1 -1
index 7abe26de69..676eb9709a 100644
@@ -88,7 +88,7 @@ class QEMUMachine(object):
         @param name: prefix for socket and log file names (default: qemu-PID)
         @param test_dir: where to create socket and log file
         @param monitor_address: address for QMP monitor
-        @param socket_scm_helper: helper program, required for send_fd_scm()"
+        @param socket_scm_helper: helper program, required for send_fd_scm()
         @note: Qemu process is not started until launch() is used.
         '''
         if args is None:
#39 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 10/10] scripts/qemu.py: remove trailing quotes on docstring

In reply to Cleber Rosa
Quoted 11 lines · Cleber Rosa
---
 scripts/qemu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu.py +0 -0
index 7abe26de69..676eb9709a 100644

scripts/qemu.py class QEMUMachine(object): · line 94

Quoted 8 lines
scripts/qemu.py +1 -1
@@ -88,7 +88,7 @@ class QEMUMachine(object):
         @param name: prefix for socket and log file names (default: qemu-PID)
         @param test_dir: where to create socket and log file
         @param monitor_address: address for QMP monitor
-        @param socket_scm_helper: helper program, required for send_fd_scm()"
+        @param socket_scm_helper: helper program, required for send_fd_scm()
         @note: Qemu process is not started until launch() is used.
         '''
         if args is None:

Applied

Thanks,
Laurent

#40 lore raw
In reply to Cleber Rosa
Quoted 2 lines · Cleber Rosa

Just a collection of trivial fixes and clean ups that have been lying around here for some time.

I'm queueing patches 07-10 on python-next. I'm aware that Laurent already queued some of them (thanks!), but I want to avoid conflicts in case other patches touching these modules are queued on python-next.

Signature · 1 line
Eduardo