summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-09-09 16:21:43 +0100
committerRalf Habacker <ralf.habacker@freenet.de>2022-11-29 18:50:06 +0000
commit54b56ab875fc413d56d07f04b447c02390de0efb (patch)
tree360426f9bb5519ad5a6617b4a20720d11cff59af /bus
parent2f9d987c0a5dacbf647c4328737e0dda380048eb (diff)
downloaddbus-54b56ab875fc413d56d07f04b447c02390de0efb.tar.gz
Use 'continue' keyword in preference to 'goto' where possible
In some more complicated loops, we do need to use 'goto' to exit from an inner loop, or to jump to cleanup or an increment of an iterator immediately before the next loop iteration. However, in these simple cases, jumping to a label immediately before the 'while' keyword is unnecessary: we can use an equivalent 'continue' statement for flow control. This makes it easier for maintainers to notice the loops where we are doing something more complicated, which still use 'goto', and know that they need to pay more attention in those cases. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'bus')
-rw-r--r--bus/config-parser-trivial.c3
-rw-r--r--bus/config-parser.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c
index 9a2087cf..a2174556 100644
--- a/bus/config-parser-trivial.c
+++ b/bus/config-parser-trivial.c
@@ -552,7 +552,6 @@ process_test_valid_subdir (const DBusString *test_base_dir,
else
_dbus_test_diag ("Testing unknown files:");
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -572,7 +571,7 @@ process_test_valid_subdir (const DBusString *test_base_dir,
_dbus_verbose ("Skipping non-.conf file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
diff --git a/bus/config-parser.c b/bus/config-parser.c
index 9f2e3c79..2d2a7ccd 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -3239,7 +3239,6 @@ process_test_valid_subdir (const DBusString *test_base_dir,
else
_dbus_test_diag ("Testing unknown files:");
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -3259,7 +3258,7 @@ process_test_valid_subdir (const DBusString *test_base_dir,
_dbus_verbose ("Skipping non-.conf file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));
@@ -3556,7 +3555,6 @@ all_are_equiv (const DBusString *target_directory)
_dbus_test_diag ("Comparing equivalent files:");
- next:
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
@@ -3575,7 +3573,7 @@ all_are_equiv (const DBusString *target_directory)
_dbus_verbose ("Skipping non-.conf file %s\n",
_dbus_string_get_const_data (&filename));
_dbus_string_free (&full_path);
- goto next;
+ continue;
}
_dbus_test_diag (" %s", _dbus_string_get_const_data (&filename));