You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Kashirin Alex (Jira)" <ji...@apache.org> on 2021/04/11 17:54:00 UTC

[jira] [Created] (THRIFT-5397) Inconsistent int signedness for printf

Kashirin Alex created THRIFT-5397:
-------------------------------------

             Summary: Inconsistent int signedness for printf
                 Key: THRIFT-5397
                 URL: https://issues.apache.org/jira/browse/THRIFT-5397
             Project: Thrift
          Issue Type: Bug
          Components: C glib - Compiler, C glib - Library, C++ - Compiler, C++ - Library
    Affects Versions: 0.14.1
            Reporter: Kashirin Alex


The Protocol's Type Message ENUM is inconsistent with "printf" for c_glib and might be in some cases for C++.
 The issue can be seen at compiling with the flag " -Wformat-signedness".

Looks like all the printf use "%d" signed-i32 - in order to keep it consistent. It be better to have enum of type int32_t or unsigned with printf to be changed to "%u" - or further more reduce it to uint8_t (unless Message Type needs to be reserved for growing in future)

 

The *_printf_* cases can be found at [https://github.com/apache/thrift/search?q="invalid+message+type+%25d%2C"&type=code|https://github.com/apache/thrift/search?q=%22invalid+message+type+%25d%2C%22&type=code]

The corresponding ENUMs are the:

_*C++*_:
 [https://github.com/apache/thrift/blob/66d897667c451ef6560d89b979b7001c57a3eda6/lib/cpp/src/thrift/protocol/TEnum.h#L57]
{code:cpp}
enum TMessageType {
  T_CALL       = 1,
  T_REPLY      = 2,
  T_EXCEPTION  = 3,
  T_ONEWAY     = 4
};
{code}
_*c_glib:*_ 
 [https://github.com/apache/thrift/blob/66d897667c451ef6560d89b979b7001c57a3eda6/lib/c_glib/src/thrift/c_glib/protocol/thrift_protocol.h#L63]
{code:c}
typedef enum {
  T_CALL      = 1,
  T_REPLY     = 2,
  T_EXCEPTION = 3,
  T_ONEWAY    = 4
} ThriftMessageType;
{code}
 

 

I'm willing to make a pull-request, Just I would like first to know if there are any preferences/considerations on the subject.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)