Use G_N_ELEMENTS in for loop
authorPeng Huang <shawn.p.huang@gmail.com>
Fri, 19 Feb 2010 05:51:53 +0000 (13:51 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Sat, 20 Feb 2010 02:43:14 +0000 (10:43 +0800)
bus/ibusimpl.c
bus/panelproxy.c
src/ibuspanelservice.c

index 889b9faad7060a0a0663b519073aee0eda52dbed..64550af3f5ac581dbd04921626611055ce91a162 100644 (file)
@@ -357,10 +357,9 @@ bus_ibus_impl_reload_config (BusIBusImpl *ibus)
         { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout },
         { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine },
         { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text },
-        { NULL, NULL, NULL },
     };
 
-    for (i = 0; entries[i].section != NULL; i++) {
+    for (i = 0; i < G_N_ELEMENTS (entries); i++) {
         if (ibus->config != NULL &&
             ibus_config_get_value (ibus->config,
                                    entries[i].section,
@@ -402,10 +401,9 @@ _config_value_changed_cb (IBusConfig  *config,
         { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout },
         { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine },
         { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text },
-        { NULL, NULL, NULL },
     };
 
-    for (i = 0; entries[i].section != NULL; i++) {
+    for (i = 0; i < G_N_ELEMENTS (entries); i++) {
         if (g_strcmp0 (entries[i].section, section) == 0 &&
             g_strcmp0 (entries[i].key, key) == 0) {
             entries[i].func (ibus, value);
index ec58212d7314f620623343744859792c34f6a742..33a91f37d6a09648199086dbf8c726519947f75b 100644 (file)
@@ -218,14 +218,11 @@ bus_panel_proxy_ibus_signal (IBusProxy      *proxy,
         { "PageDown",       PAGE_DOWN },
         { "CursorUp",       CURSOR_UP },
         { "CursorDown",     CURSOR_DOWN },
-        { NULL, 0},
     };
 
     panel = BUS_PANEL_PROXY (proxy);
 
-    for (i = 0; ; i++) {
-        if (signals[i].member == NULL)
-            break;
+    for (i = 0; i < G_N_ELEMENTS (signals); i++) {
         if (ibus_message_is_signal (message, IBUS_INTERFACE_PANEL, signals[i].member)) {
             g_signal_emit (panel, panel_signals[signals[i].signal_id], 0);
             goto handled;
index 8420f2cc6f87f0b949bf04b8f42a27b6e35aa936..67371cb26f70472394d49b435a5112700c0a3292 100644 (file)
@@ -224,13 +224,12 @@ ibus_panel_service_ibus_message (IBusPanelService *panel,
         { "ShowPreeditText",       G_STRUCT_OFFSET (IBusPanelServiceClass, show_preedit_text) },
         { "StartSetup",            G_STRUCT_OFFSET (IBusPanelServiceClass, start_setup) },
         { "StateChanged",          G_STRUCT_OFFSET (IBusPanelServiceClass, state_changed) },
-        { NULL, 0 },
     };
 
     IBusMessage *reply = NULL;
 
     gint i;
-    for (i = 0; no_arg_methods[i].name != NULL; i++) {
+    for (i = 0; i < G_N_ELEMENTS (no_arg_methods); i++) {
         if (!ibus_message_is_method_call (message, IBUS_INTERFACE_PANEL,
                                           no_arg_methods[i].name))
             continue;