aboutsummaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-12-13 11:32:49 +0100
committerAleksander Morgado <aleksander@gnu.org>2018-12-18 09:24:20 +0000
commit0bfd89f0b61d71723e3a0dd77b198a4d9b435839 (patch)
treed12c2b9a16abfef40baf1587bcdf6baf47c4c24e /build-aux
parent235ad0f852fe5323d212912b86769858404f59e8 (diff)
qmi-codegen: avoid using qmi_utils_()* deprecated methods
The Result TLV printable getter was still using one of the deprecated qmi_utils_() TLV contents reader methods. Port them to use the newer and safer qmi_message_tlv_read_() APIs.
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/qmi-codegen/FieldResult.py47
1 files changed, 14 insertions, 33 deletions
diff --git a/build-aux/qmi-codegen/FieldResult.py b/build-aux/qmi-codegen/FieldResult.py
index c810ed5..f22f94d 100644
--- a/build-aux/qmi-codegen/FieldResult.py
+++ b/build-aux/qmi-codegen/FieldResult.py
@@ -146,42 +146,23 @@ class FieldResult(Field):
' QmiMessage *self,\n'
' const gchar *line_prefix)\n'
'{\n'
- ' const guint8 *buffer;\n'
- ' guint16 buffer_len;\n'
+ ' gsize offset = 0;\n'
+ ' gsize init_offset;\n'
+ ' guint16 error_status;\n'
+ ' guint16 error_code;\n'
'\n'
- ' buffer = qmi_message_get_raw_tlv (self,\n'
- ' ${tlv_id},\n'
- ' &buffer_len);\n'
- ' if (buffer) {\n'
- ' GString *printable;\n'
- ' guint16 error_status;\n'
- ' guint16 error_code;\n'
+ ' if ((init_offset = qmi_message_tlv_read_init (self, ${tlv_id}, NULL, NULL)) == 0)\n'
+ ' return NULL;\n'
+ ' if (!qmi_message_tlv_read_guint16 (self, init_offset, &offset, QMI_ENDIAN_LITTLE, &error_status, NULL))\n'
+ ' return NULL;\n'
+ ' if (!qmi_message_tlv_read_guint16 (self, init_offset, &offset, QMI_ENDIAN_LITTLE, &error_code, NULL))\n'
+ ' return NULL;\n'
+ ' g_warn_if_fail (__qmi_message_tlv_read_remaining_size (self, init_offset, offset) == 0);\n'
'\n'
- ' printable = g_string_new ("");\n'
- ' qmi_utils_read_guint16_from_buffer (\n'
- ' &buffer,\n'
- ' &buffer_len,\n'
- ' QMI_ENDIAN_LITTLE,\n'
- ' &error_status);\n'
- ' qmi_utils_read_guint16_from_buffer (\n'
- ' &buffer,\n'
- ' &buffer_len,\n'
- ' QMI_ENDIAN_LITTLE,\n'
- ' &error_code);\n'
+ ' if (error_status == QMI_STATUS_SUCCESS)\n'
+ ' return g_strdup ("SUCCESS");\n'
'\n'
- ' g_warn_if_fail (buffer_len == 0);\n'
- '\n'
- ' if (error_status == QMI_STATUS_SUCCESS)\n'
- ' g_string_append (printable, "SUCCESS");\n'
- ' else\n'
- ' g_string_append_printf (printable,\n'
- ' "FAILURE: %s",\n'
- ' qmi_protocol_error_get_string ((QmiProtocolError) error_code));\n'
- '\n'
- ' return g_string_free (printable, FALSE);\n'
- ' }\n'
- '\n'
- ' return NULL;\n'
+ ' return g_strdup_printf ("FAILURE: %s", qmi_protocol_error_get_string ((QmiProtocolError) error_code));\n'
'}\n')
f.write(string.Template(template).substitute(translations))