<div dir="auto"><div>Hi Aleksander,</div><div dir="auto"><br></div><div dir="auto">What do you think about this two patches?</div><div dir="auto"><br></div><div dir="auto">Thanks</div><div dir="auto">Ben<br><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Wed, Jan 31, 2018, 9:56 PM Ben Chan <<a href="mailto:benchan@chromium.org">benchan@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">g_set_error_literal() requires a non-NULL 'message' argument. Passing<br>
mbim_status_error_get_string() as the 'message' argument to<br>
g_set_error_literal() could result in an assertion as<br>
mbim_status_error_get_string() returns NULL for a status code without an<br>
associated MbimStatusError enum.<br>
---<br>
src/libmbim-glib/mbim-message.c | 40 ++++++++++++++++++++++++----------------<br>
1 file changed, 24 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/libmbim-glib/mbim-message.c b/src/libmbim-glib/mbim-message.c<br>
index 06b9eb8..0ab4667 100644<br>
--- a/src/libmbim-glib/mbim-message.c<br>
+++ b/src/libmbim-glib/mbim-message.c<br>
@@ -59,6 +59,26 @@ bytearray_apply_padding (GByteArray *buffer,<br>
}<br>
}<br>
<br>
+static void<br>
+set_error_from_status (GError **error,<br>
+ MbimStatusError status)<br>
+{<br>
+ const gchar *error_string;<br>
+<br>
+ error_string = mbim_status_error_get_string (status);<br>
+ if (error_string)<br>
+ g_set_error_literal (error,<br>
+ MBIM_STATUS_ERROR,<br>
+ status,<br>
+ error_string);<br>
+ else<br>
+ g_set_error (error,<br>
+ MBIM_STATUS_ERROR,<br>
+ status,<br>
+ "Unknown status 0x%08x",<br>
+ status);<br>
+}<br>
+<br>
/*****************************************************************************/<br>
<br>
GType<br>
@@ -1605,10 +1625,7 @@ mbim_message_open_done_get_result (const MbimMessage *self,<br>
if (status == MBIM_STATUS_ERROR_NONE)<br>
return TRUE;<br>
<br>
- g_set_error_literal (error,<br>
- MBIM_STATUS_ERROR,<br>
- status,<br>
- mbim_status_error_get_string (status));<br>
+ set_error_from_status (error, status);<br>
return FALSE;<br>
}<br>
<br>
@@ -1701,10 +1718,7 @@ mbim_message_close_done_get_result (const MbimMessage *self,<br>
if (status == MBIM_STATUS_ERROR_NONE)<br>
return TRUE;<br>
<br>
- g_set_error_literal (error,<br>
- MBIM_STATUS_ERROR,<br>
- status,<br>
- mbim_status_error_get_string (status));<br>
+ set_error_from_status (error, status);<br>
return FALSE;<br>
}<br>
<br>
@@ -2066,10 +2080,7 @@ mbim_message_command_done_get_result (const MbimMessage *self,<br>
if (status == MBIM_STATUS_ERROR_NONE)<br>
return TRUE;<br>
<br>
- g_set_error_literal (error,<br>
- MBIM_STATUS_ERROR,<br>
- status,<br>
- mbim_status_error_get_string (status));<br>
+ set_error_from_status (error, status);<br>
return FALSE;<br>
}<br>
<br>
@@ -2238,9 +2249,6 @@ mbim_message_response_get_result (const MbimMessage *self,<br>
return TRUE;<br>
<br>
/* Build error */<br>
- g_set_error_literal (error,<br>
- MBIM_STATUS_ERROR,<br>
- status,<br>
- mbim_status_error_get_string (status));<br>
+ set_error_from_status (error, status);<br>
return FALSE;<br>
}<br>
--<br>
2.16.0.rc1.238.g530d649a79-goog<br>
<br>
_______________________________________________<br>
libmbim-devel mailing list<br>
<a href="mailto:libmbim-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">libmbim-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/libmbim-devel" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/libmbim-devel</a><br>
</blockquote></div></div></div>