[07/10] image-fuzzer: Use bytes constant for field values
diff mbox series

Message ID 20191016192430.25098-8-ehabkost@redhat.com
State New
Headers show
Series
  • image-fuzzer: Port to Python 3
Related show

Commit Message

Eduardo Habkost Oct. 16, 2019, 7:24 p.m. UTC
Field values are supposed to be bytes objects, not unicode
strings.  Change two constants that were declared as strings.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 tests/image-fuzzer/qcow2/layout.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Oct. 17, 2019, 9:55 a.m. UTC | #1
On 10/16/19 9:24 PM, Eduardo Habkost wrote:
> Field values are supposed to be bytes objects, not unicode
> strings.  Change two constants that were declared as strings.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   tests/image-fuzzer/qcow2/layout.py | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/image-fuzzer/qcow2/layout.py b/tests/image-fuzzer/qcow2/layout.py
> index 0adcbd448d..a0fd53c7ad 100644
> --- a/tests/image-fuzzer/qcow2/layout.py
> +++ b/tests/image-fuzzer/qcow2/layout.py
> @@ -122,7 +122,7 @@ class Image(object):
>       def create_header(self, cluster_bits, backing_file_name=None):
>           """Generate a random valid header."""
>           meta_header = [
> -            ['>4s', 0, "QFI\xfb", 'magic'],
> +            ['>4s', 0, b"QFI\xfb", 'magic'],
>               ['>I', 4, random.randint(2, 3), 'version'],
>               ['>Q', 8, 0, 'backing_file_offset'],
>               ['>I', 16, 0, 'backing_file_size'],
> @@ -231,7 +231,7 @@ class Image(object):
>               feature_tables = []
>               feature_ids = []
>               inner_offset = self.ext_offset + ext_header_len
> -            feat_name = 'some cool feature'
> +            feat_name = b'some cool feature'
>               while len(feature_tables) < num_fnt_entries * 3:
>                   feat_type, feat_bit = gen_feat_ids()
>                   # Remove duplicates
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Patch
diff mbox series

diff --git a/tests/image-fuzzer/qcow2/layout.py b/tests/image-fuzzer/qcow2/layout.py
index 0adcbd448d..a0fd53c7ad 100644
--- a/tests/image-fuzzer/qcow2/layout.py
+++ b/tests/image-fuzzer/qcow2/layout.py
@@ -122,7 +122,7 @@  class Image(object):
     def create_header(self, cluster_bits, backing_file_name=None):
         """Generate a random valid header."""
         meta_header = [
-            ['>4s', 0, "QFI\xfb", 'magic'],
+            ['>4s', 0, b"QFI\xfb", 'magic'],
             ['>I', 4, random.randint(2, 3), 'version'],
             ['>Q', 8, 0, 'backing_file_offset'],
             ['>I', 16, 0, 'backing_file_size'],
@@ -231,7 +231,7 @@  class Image(object):
             feature_tables = []
             feature_ids = []
             inner_offset = self.ext_offset + ext_header_len
-            feat_name = 'some cool feature'
+            feat_name = b'some cool feature'
             while len(feature_tables) < num_fnt_entries * 3:
                 feat_type, feat_bit = gen_feat_ids()
                 # Remove duplicates