aboutsummaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-01-15 12:02:57 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-01-15 12:03:37 +0100
commit5b7c6cd35e970bb9b2a0e9f3681fa8b0d94c2412 (patch)
tree90e891b4369a59bbb9a75727ec0ce6c6330bde01 /build-aux
parentb5599b8e369c747ee54902f9467288f3713f93bc (diff)
qmi-codegen,message: use g_autoptr in the request creator
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/qmi-codegen/Field.py4
-rw-r--r--build-aux/qmi-codegen/Message.py17
-rw-r--r--build-aux/qmi-codegen/VariableInteger.py6
-rw-r--r--build-aux/qmi-codegen/VariableString.py2
4 files changed, 11 insertions, 18 deletions
diff --git a/build-aux/qmi-codegen/Field.py b/build-aux/qmi-codegen/Field.py
index 80c5c9e..8e7fa50 100644
--- a/build-aux/qmi-codegen/Field.py
+++ b/build-aux/qmi-codegen/Field.py
@@ -244,7 +244,7 @@ class Field:
'\n'
'${lp}if (!(tlv_offset = qmi_message_tlv_write_init (self, (guint8)${tlv_id}, error))) {\n'
'${lp} g_prefix_error (error, "Cannot initialize TLV \'${name}\': ");\n'
- '${lp} goto error_out;\n'
+ '${lp} return NULL;\n'
'${lp}}\n'
'\n')
f.write(string.Template(template).substitute(translations))
@@ -256,7 +256,7 @@ class Field:
'\n'
'${lp}if (!qmi_message_tlv_write_complete (self, tlv_offset, error)) {\n'
'${lp} g_prefix_error (error, "Cannot complete TLV \'${name}\': ");\n'
- '${lp} goto error_out;\n'
+ '${lp} return NULL;\n'
'${lp}}\n')
f.write(string.Template(template).substitute(translations))
diff --git a/build-aux/qmi-codegen/Message.py b/build-aux/qmi-codegen/Message.py
index ba78310..475e310 100644
--- a/build-aux/qmi-codegen/Message.py
+++ b/build-aux/qmi-codegen/Message.py
@@ -114,7 +114,7 @@ class Message:
' %s,\n'
' GError **error)\n'
'{\n'
- ' QmiMessage *self;\n'
+ ' g_autoptr(QmiMessage) self = NULL;\n'
'\n'
' self = qmi_message_new (QMI_SERVICE_${service},\n'
' cid,\n'
@@ -136,7 +136,7 @@ class Message:
'\n'
' /* All TLVs are optional, we allow NULL input */\n'
' if (!input)\n'
- ' return self;\n')
+ ' return g_steal_pointer (&self);\n')
else:
# If we do have mandatory fields, issue error if no input
# given.
@@ -148,7 +148,7 @@ class Message:
' QMI_CORE_ERROR,\n'
' QMI_CORE_ERROR_INVALID_ARGS,\n'
' "Message \'${name}\' has mandatory TLVs");\n'
- ' goto error_out;\n'
+ ' return NULL;\n'
' }\n')
cfile.write(string.Template(template).substitute(translations))
@@ -172,21 +172,14 @@ class Message:
' QMI_CORE_ERROR,\n'
' QMI_CORE_ERROR_INVALID_ARGS,\n'
' "Missing mandatory TLV \'${tlv_name}\' in message \'${name}\'");\n'
- ' goto error_out;\n')
+ ' return NULL;\n')
cfile.write(string.Template(template).substitute(translations))
cfile.write(
' }\n')
cfile.write(
'\n'
- ' return self;\n')
- if self.input.fields:
- cfile.write(
- '\n'
- 'error_out:\n'
- ' qmi_message_unref (self);\n'
- ' return NULL;\n')
- cfile.write(
+ ' return g_steal_pointer (&self);\n'
'}\n')
diff --git a/build-aux/qmi-codegen/VariableInteger.py b/build-aux/qmi-codegen/VariableInteger.py
index a498b05..cb8178b 100644
--- a/build-aux/qmi-codegen/VariableInteger.py
+++ b/build-aux/qmi-codegen/VariableInteger.py
@@ -137,14 +137,14 @@ class VariableInteger(Variable):
'${lp}/* Write the ${len}-byte long variable to the buffer */\n'
'${lp}if (!qmi_message_tlv_write_sized_guint (self, ${len},${endian} ${variable_name}, error)) {\n'
'${lp} g_prefix_error (error, "Cannot write sized integer in TLV \'${tlv_name}\': ");\n'
- '${lp} goto error_out;\n'
+ '${lp} return NULL;\n'
'${lp}}\n')
elif self.private_format == self.public_format:
template = (
'${lp}/* Write the ${private_format} variable to the buffer */\n'
'${lp}if (!qmi_message_tlv_write_${private_format} (self,${endian} ${variable_name}, error)) {\n'
'${lp} g_prefix_error (error, "Cannot write integer in TLV \'${tlv_name}\': ");\n'
- '${lp} goto error_out;\n'
+ '${lp} return NULL;\n'
'${lp}}\n')
else:
template = (
@@ -155,7 +155,7 @@ class VariableInteger(Variable):
'${lp} /* Write the ${private_format} variable to the buffer */\n'
'${lp} if (!qmi_message_tlv_write_${private_format} (self,${endian} tmp, error)) {\n'
'${lp} g_prefix_error (error, "Cannot write enum in TLV \'${tlv_name}\': ");\n'
- '${lp} goto error_out;\n'
+ '${lp} return NULL;\n'
'${lp} }\n'
'${lp}}\n')
f.write(string.Template(template).substitute(translations))
diff --git a/build-aux/qmi-codegen/VariableString.py b/build-aux/qmi-codegen/VariableString.py
index ed7851e..4e9faa9 100644
--- a/build-aux/qmi-codegen/VariableString.py
+++ b/build-aux/qmi-codegen/VariableString.py
@@ -123,7 +123,7 @@ class VariableString(Variable):
template = (
'${lp}if (!qmi_message_tlv_write_string (self, ${n_size_prefix_bytes}, ${variable_name}, ${fixed_size}, error)) {\n'
'${lp} g_prefix_error (error, "Cannot write string in TLV \'${tlv_name}\': ");\n'
- '${lp} goto error_out;\n'
+ '${lp} return NULL;\n'
'${lp}}\n')
f.write(string.Template(template).substitute(translations))