[PATCH BlueZ 3/4] shared/shell: Create command_isskipped()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/shared/shell.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index f9dbdb194..26194f758 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -169,6 +169,22 @@ static const struct bt_shell_menu_entry default_menu[] = {
 	{ }
 };
 
+static bool command_isskipped(const char *cmd)
+{
+	/* Skip menu command if not on main menu or if there are no
+	 * submenus.
+	 */
+	if (!strcmp(cmd, "menu") &&
+		(data.menu != data.main || queue_isempty(data.submenus)))
+		return true;
+
+	/* Skip back command if on main menu */
+	if (data.menu == data.main && !strcmp(cmd, "back"))
+		return true;
+
+	return false;
+}
+
 static void shell_print_menu(void)
 {
 	const struct bt_shell_menu_entry *entry;
@@ -195,16 +211,7 @@ static void shell_print_menu(void)
 	}
 
 	for (entry = default_menu; entry->cmd; entry++) {
-		/* Skip menu command if not on main menu or if there are no
-		 * submenus.
-		 */
-		if (!strcmp(entry->cmd, "menu") &&
-			(data.menu != data.main ||
-				queue_isempty(data.submenus)))
-			continue;
-
-		/* Skip back command if on main menu */
-		if (data.menu == data.main && !strcmp(entry->cmd, "back"))
+		if (command_isskipped(entry->cmd))
 			continue;
 
 		print_menu(entry->cmd, entry->arg ? : "", entry->desc ? : "");
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux