[PATCH] libmbim-glib: fix G_DEPRECATED_FOR annotations

Ben Chan benchan at chromium.org
Wed Jun 28 06:37:43 UTC 2017


mbim-compat.h defines a few deprecated enumerators as an alias to their
equivalence using macros and annotates those macros with
G_DEPRECATED_FOR, which may be expanded to
`__attribute__((deprecated))'.

Neither gcc nor clang supports `__attribute__((deprecated))' on macros.
Thus, a G_DEPRECATED_FOR annotation before a macro definition is
actually associated with the next identifier found after the macro
definition, which is incorrect.

Alternatively, the G_DEPRECATED_FOR annotation can be used on the
deprecated enumerators. But only gcc 6 or above supports enumerator
attributes.

To address the issue, this patch defines the deprecated enumerators as
`static const int' values, which can then be annotated with
G_DEPRECATED_FOR.
---
 src/libmbim-glib/mbim-compat.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/libmbim-glib/mbim-compat.h b/src/libmbim-glib/mbim-compat.h
index 0edd527..88966db 100644
--- a/src/libmbim-glib/mbim-compat.h
+++ b/src/libmbim-glib/mbim-compat.h
@@ -28,6 +28,7 @@
 #include <glib.h>
 
 #include "mbim-basic-connect.h"
+#include "mbim-cid.h"
 
 G_BEGIN_DECLS
 
@@ -42,7 +43,8 @@ G_BEGIN_DECLS
  * Deprecated:1.8.0: Use MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH instead.
  */
 G_DEPRECATED_FOR (MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH)
-#define MBIM_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH
+static const int MBIM_REGISTRATION_FLAG_MANUAL_PACKET_SERVICE_AUTOMATIC_ATTACH =
+    MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH;
 
 /*****************************************************************************/
 /* 'Service Subscriber List' rename to 'Service Subscribe List' */
@@ -55,7 +57,8 @@ G_DEPRECATED_FOR (MBIM_REGISTRATION_FLAG_PACKET_SERVICE_AUTOMATIC_ATTACH)
  * Deprecated:1.8.0: Use MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST instead.
  */
 G_DEPRECATED_FOR (MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST)
-#define MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST
+static const int MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBER_LIST =
+    MBIM_CID_BASIC_CONNECT_DEVICE_SERVICE_SUBSCRIBE_LIST;
 
 G_DEPRECATED_FOR (mbim_message_device_service_subscribe_list_set_new)
 MbimMessage *mbim_message_device_service_subscriber_list_set_new (
-- 
2.13.2.725.g09c95d1e9-goog



More information about the libmbim-devel mailing list