summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2017-07-26 11:33:29 -0700
committerAleksander Morgado <aleksander@aleksander.es>2017-07-26 20:52:56 +0200
commit752855389c8fc7f23e74f2e9e4224dee4e28362d (patch)
treef2e12b00206c62610195aa7ecdc09a0b034ecd62
parent221ab6581f589ed720419c7459e6ae597ead4e05 (diff)
mbimcli: ensure 'cancellable' in Context is always initialized
As the Context struct is allocated via g_slice_new and its 'cancellable' field is only set when a GCancellable is provided, there is no guarantee that the cancellable field is always initialized. This patch fixes the code to always initialize the cancellable field of the Context struct.
-rw-r--r--src/mbimcli/mbimcli-atds.c3
-rw-r--r--src/mbimcli/mbimcli-basic-connect.c3
-rw-r--r--src/mbimcli/mbimcli-dss.c3
-rw-r--r--src/mbimcli/mbimcli-ms-firmware-id.c3
-rw-r--r--src/mbimcli/mbimcli-ms-host-shutdown.c3
-rw-r--r--src/mbimcli/mbimcli-phonebook.c3
6 files changed, 6 insertions, 12 deletions
diff --git a/src/mbimcli/mbimcli-atds.c b/src/mbimcli/mbimcli-atds.c
index c25f71f..b991120 100644
--- a/src/mbimcli/mbimcli-atds.c
+++ b/src/mbimcli/mbimcli-atds.c
@@ -297,8 +297,7 @@ mbimcli_atds_run (MbimDevice *device,
/* Initialize context */
ctx = g_slice_new (Context);
ctx->device = g_object_ref (device);
- if (cancellable)
- ctx->cancellable = g_object_ref (cancellable);
+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
/* Request to get signal info? */
if (query_signal_flag) {
diff --git a/src/mbimcli/mbimcli-basic-connect.c b/src/mbimcli/mbimcli-basic-connect.c
index cae1f99..204ecb9 100644
--- a/src/mbimcli/mbimcli-basic-connect.c
+++ b/src/mbimcli/mbimcli-basic-connect.c
@@ -1548,8 +1548,7 @@ mbimcli_basic_connect_run (MbimDevice *device,
/* Initialize context */
ctx = g_slice_new (Context);
ctx->device = g_object_ref (device);
- if (cancellable)
- ctx->cancellable = g_object_ref (cancellable);
+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
/* Request to get capabilities? */
if (query_device_caps_flag) {
diff --git a/src/mbimcli/mbimcli-dss.c b/src/mbimcli/mbimcli-dss.c
index 76866b9..1e26130 100644
--- a/src/mbimcli/mbimcli-dss.c
+++ b/src/mbimcli/mbimcli-dss.c
@@ -259,8 +259,7 @@ mbimcli_dss_run (MbimDevice *device,
/* Initialize context */
ctx = g_slice_new (Context);
ctx->device = g_object_ref (device);
- if (cancellable)
- ctx->cancellable = g_object_ref (cancellable);
+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
/* Connect? */
if (connect_str) {
diff --git a/src/mbimcli/mbimcli-ms-firmware-id.c b/src/mbimcli/mbimcli-ms-firmware-id.c
index 9cbd255..69d662e 100644
--- a/src/mbimcli/mbimcli-ms-firmware-id.c
+++ b/src/mbimcli/mbimcli-ms-firmware-id.c
@@ -153,8 +153,7 @@ mbimcli_ms_firmware_id_run (MbimDevice *device,
/* Initialize context */
ctx = g_slice_new (Context);
ctx->device = g_object_ref (device);
- if (cancellable)
- ctx->cancellable = g_object_ref (cancellable);
+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
/* Request to get firmware ID? */
if (query_firmware_id_flag) {
diff --git a/src/mbimcli/mbimcli-ms-host-shutdown.c b/src/mbimcli/mbimcli-ms-host-shutdown.c
index 3fa7869..ee6361a 100644
--- a/src/mbimcli/mbimcli-ms-host-shutdown.c
+++ b/src/mbimcli/mbimcli-ms-host-shutdown.c
@@ -137,8 +137,7 @@ mbimcli_ms_host_shutdown_run (MbimDevice *device,
/* Initialize context */
ctx = g_slice_new (Context);
ctx->device = g_object_ref (device);
- if (cancellable)
- ctx->cancellable = g_object_ref (cancellable);
+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
/* Request to notify that host is shutting down */
if (notify_host_shutdown_flag) {
diff --git a/src/mbimcli/mbimcli-phonebook.c b/src/mbimcli/mbimcli-phonebook.c
index bb4e1c0..2fa46a6 100644
--- a/src/mbimcli/mbimcli-phonebook.c
+++ b/src/mbimcli/mbimcli-phonebook.c
@@ -353,8 +353,7 @@ mbimcli_phonebook_run (MbimDevice *device,
/* Initialize context */
ctx = g_slice_new (Context);
ctx->device = g_object_ref (device);
- if (cancellable)
- ctx->cancellable = g_object_ref (cancellable);
+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
/* Request to get configuration? */
if (phonebook_configuration_flag) {