[Spice-commits] python_modules/codegen.py python_modules/demarshal.py

Hans de Goede jwrdegoede at kemper.freedesktop.org
Fri Sep 30 05:06:20 PDT 2011


 python_modules/codegen.py   |    6 ++++++
 python_modules/demarshal.py |    5 +++++
 2 files changed, 11 insertions(+)

New commits:
commit 858e5def68e74e1f10842ba5a1c46f9898b55751
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Fri Sep 30 11:19:38 2011 +0200

    spice_codegen: Always write a channels entry for an ifdef-ed channel
    
    Before this patch, if a channel is defined conditionally in spice.proto
    (because it depends on external headers like the smartcard channel),
    spice_codegen would write an entry to the channels array in
    spice_get_*_channel_parser which would only take up a place in the array
    if the ifdef condition is true, thus moving up all other intializers
    one place when it is not true. This was causing issues (crashes) when building
    spice-gtk with the combination of usbredir support enabled and smartcard
    support disabled.
    
    This patch fixes this by adding #else { NULL, 0 }, to the generated code.
    
    Thanks to coolper chen <lixin.chen at saicocch.com> for reporting this!
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/python_modules/codegen.py b/python_modules/codegen.py
index e438e4d..a2c010b 100644
--- a/python_modules/codegen.py
+++ b/python_modules/codegen.py
@@ -328,6 +328,12 @@ class CodeWriter:
         self.write("#ifdef %s" % (name)).newline()
         self.indentation = indentation
 
+    def ifdef_else(self, name):
+        indentation = self.indentation
+        self.indentation = 0;
+        self.write("#else /* %s */" % (name)).newline()
+        self.indentation = indentation
+
     def endif(self, name):
         indentation = self.indentation
         self.indentation = 0;
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 5a5a744..9847fb4 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -1192,6 +1192,11 @@ def write_get_channel_parser(writer, channel_parsers, max_channel, is_server):
             writer.write(",")
         writer.newline()
         if channel and channel.has_attr("ifdef"):
+            writer.ifdef_else(channel.attributes["ifdef"][0])
+            writer.write("{ NULL, 0 }")
+            if i != max_channel:
+                writer.write(",")
+            writer.newline()
             writer.endif(channel.attributes["ifdef"][0])
     writer.end_block(semicolon = True)
 


More information about the Spice-commits mailing list