You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2015/10/11 00:52:52 UTC

thrift git commit: THRIFT-3378 c_glib service does not handle negative Thrift byte values correctly

Repository: thrift
Updated Branches:
  refs/heads/master 64b8f6ca1 -> 30f465db9


THRIFT-3378 c_glib service does not handle negative Thrift byte values correctly

This closes #644


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/30f465db
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/30f465db
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/30f465db

Branch: refs/heads/master
Commit: 30f465db92b95d6beedb8d5d056792a4e75f0158
Parents: 64b8f6c
Author: Nobuaki Sukegawa <ns...@gmail.com>
Authored: Sat Oct 10 10:45:42 2015 +0900
Committer: Roger Meier <ro...@apache.org>
Committed: Sun Oct 11 00:40:37 2015 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_c_glib_generator.cc |  8 +++++++-
 test/c_glib/src/test_client.c                   | 16 ++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/30f465db/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index 47aa4d2..bf5dc7d 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -2302,7 +2302,13 @@ void t_c_glib_generator::generate_service_processor(t_service* tservice) {
     // The handler reported success; return the result, if any, to the caller
     if (!(*function_iter)->is_oneway()) {
       if (has_return_value) {
-        f_service_ << indent() << "g_object_set (result_struct, \"success\", return_value, "
+        f_service_ << indent() << "g_object_set (result_struct, \"success\", ";
+        if (type_name(return_type) != property_type_name(return_type)) {
+          // Roundtrip cast to fix the position of sign bit.
+          f_service_ << "(" << property_type_name(return_type) << ")"
+                     << "(" << type_name(return_type) << ")";
+        }
+        f_service_ << "return_value, "
                    << "NULL);" << endl;
 
         // Deallocate (or unref) return_value

http://git-wip-us.apache.org/repos/asf/thrift/blob/30f465db/test/c_glib/src/test_client.c
----------------------------------------------------------------------
diff --git a/test/c_glib/src/test_client.c b/test/c_glib/src/test_client.c
index fd429c8..0f8a713 100644
--- a/test/c_glib/src/test_client.c
+++ b/test/c_glib/src/test_client.c
@@ -356,6 +356,22 @@ main (int argc, char **argv)
 
         fail_count++;
       }
+      printf ("testByte(-1)");
+      if (t_test_thrift_test_if_test_byte (test_client,
+                                           &byte,
+                                           -1,
+                                           &error)) {
+        printf (" = %d\n", byte);
+        if (byte != -1)
+          fail_count++;
+      }
+      else {
+        printf ("%s\n", error->message);
+        g_error_free (error);
+        error = NULL;
+
+        fail_count++;
+      }
 
       /**
        * I32 TEST