[PATCH] mbimcli: consolidate VALIDATE_UNKNOWN definitions in one common place

Ben Chan benchan at chromium.org
Tue Feb 25 01:46:27 PST 2014


---
 src/mbimcli/mbimcli-basic-connect.c | 30 ------------------------------
 src/mbimcli/mbimcli-phonebook.c     |  8 +-------
 src/mbimcli/mbimcli.h               |  2 ++
 3 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/src/mbimcli/mbimcli-basic-connect.c b/src/mbimcli/mbimcli-basic-connect.c
index b97154c..a73da19 100644
--- a/src/mbimcli/mbimcli-basic-connect.c
+++ b/src/mbimcli/mbimcli-basic-connect.c
@@ -301,9 +301,6 @@ query_device_caps_ready (MbimDevice   *device,
     sms_caps_str = mbim_sms_caps_build_string_from_mask (sms_caps);
     ctrl_caps_str = mbim_ctrl_caps_build_string_from_mask (ctrl_caps);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("[%s] Device capabilities retrieved:\n"
              "\t      Device type: '%s'\n"
              "\t   Cellular class: '%s'\n"
@@ -388,9 +385,6 @@ query_subscriber_ready_status_ready (MbimDevice   *device,
     ready_state_str = mbim_subscriber_ready_state_get_string (ready_state);
     ready_info_str = mbim_ready_info_flag_build_string_from_mask (ready_info);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("[%s] Subscriber ready status retrieved:\n"
              "\t      Ready state: '%s'\n"
              "\t    Subscriber ID: '%s'\n"
@@ -447,9 +441,6 @@ query_radio_state_ready (MbimDevice   *device,
     hardware_radio_state_str = mbim_radio_switch_state_get_string (hardware_radio_state);
     software_radio_state_str = mbim_radio_switch_state_get_string (software_radio_state);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("[%s] Radio state retrieved:\n"
              "\t     Hardware Radio State: '%s'\n"
              "\t     Software Radio State: '%s'\n",
@@ -585,9 +576,6 @@ pin_ready (MbimDevice   *device,
         g_print ("[%s] PIN operation successful\n\n",
                  mbim_device_get_path_display (device));
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     pin_state_str = mbim_pin_state_get_string (pin_state);
 
     g_print ("[%s] Pin Info:\n"
@@ -702,9 +690,6 @@ connect_ready (MbimDevice   *device,
         break;
     }
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("[%s] Connection status:\n"
              "\t      Session ID: '%u'\n"
              "\tActivation state: '%s'\n"
@@ -818,9 +803,6 @@ home_provider_ready (MbimDevice   *device,
     provider_state_str = mbim_provider_state_build_string_from_mask (provider->provider_state);
     cellular_class_str = mbim_cellular_class_build_string_from_mask (provider->cellular_class);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("[%s] Home provider:\n"
              "\t   Provider ID: '%s'\n"
              "\t Provider Name: '%s'\n"
@@ -888,9 +870,6 @@ preferred_providers_ready (MbimDevice   *device,
         provider_state_str = mbim_provider_state_build_string_from_mask (providers[i]->provider_state);
         cellular_class_str = mbim_cellular_class_build_string_from_mask (providers[i]->cellular_class);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
         g_print ("\tProvider [%u]:\n"
                  "\t\t    Provider ID: '%s'\n"
                  "\t\t  Provider Name: '%s'\n"
@@ -959,9 +938,6 @@ visible_providers_ready (MbimDevice   *device,
         provider_state_str = mbim_provider_state_build_string_from_mask (providers[i]->provider_state);
         cellular_class_str = mbim_cellular_class_build_string_from_mask (providers[i]->cellular_class);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
         g_print ("\tProvider [%u]:\n"
                  "\t\t    Provider ID: '%s'\n"
                  "\t\t  Provider Name: '%s'\n"
@@ -1039,9 +1015,6 @@ register_state_ready (MbimDevice   *device,
     cellular_class_str = mbim_cellular_class_build_string_from_mask (cellular_class);
     registration_flag_str = mbim_registration_flag_build_string_from_mask (registration_flag);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("[%s] Registration status:\n"
              "\t         Network error: '%s'\n"
              "\t        Register state: '%s'\n"
@@ -1182,9 +1155,6 @@ packet_service_ready (MbimDevice   *device,
         break;
     }
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     highest_available_data_class_str = mbim_data_class_build_string_from_mask (highest_available_data_class);
 
     g_print ("[%s] Packet service status:\n"
diff --git a/src/mbimcli/mbimcli-phonebook.c b/src/mbimcli/mbimcli-phonebook.c
index 0cbb85f..95c3c48 100644
--- a/src/mbimcli/mbimcli-phonebook.c
+++ b/src/mbimcli/mbimcli-phonebook.c
@@ -276,9 +276,6 @@ query_phonebook_read_ready (MbimDevice   *device,
         return;
     }
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("Successfully read phonebook entries (%d)\n", entry_count);
     for (i = 0; i < entry_count; i++) {
         g_print ("\tEntry index : %d \n"
@@ -330,16 +327,13 @@ query_phonebook_configuration_ready (MbimDevice   *device,
 
     state_str = mbim_phonebook_state_get_string (state);
 
-#undef VALIDATE_UNKNOWN
-#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
-
     g_print ("\n Phonebook configuration retrived... \n"
              "\t   Phonebook state: %s \n"
              "\t Number of entries: %d \n"
              "\t      used entries: %d \n"
              "\t max number length: %d \n"
              "\t         max name : %d \n",
-             VALIDATE_UNKNOWN(state_str),
+             VALIDATE_UNKNOWN (state_str),
              number_of_entries,
              used_entries,
              max_number_length,
diff --git a/src/mbimcli/mbimcli.h b/src/mbimcli/mbimcli.h
index 411b776..5fcdc7a 100644
--- a/src/mbimcli/mbimcli.h
+++ b/src/mbimcli/mbimcli.h
@@ -23,6 +23,8 @@
 #ifndef __MBIMCLI_H__
 #define __MBIMCLI_H__
 
+#define VALIDATE_UNKNOWN(str) ((str) ? (str) : "unknown")
+
 /* Common */
 void mbimcli_async_operation_done (gboolean operation_status);
 
-- 
1.9.0.rc1.175.g0b1dcb5



More information about the libmbim-devel mailing list