From e21407d07b82a11ecff5cdd27acf2c51fa6030c2 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 14 May 2011 20:37:37 +0000 Subject: [PATCH] When applying settings from the boot menus, aggregate them and then add them to the kernel args in a single go. Otherwise we wind up with more link list entries than expected, which in turn resulted in settings not quite being parsed properly upon entering the kernel, which meant that if options were chosen in both the debug and safe mode menus, only the debug ones were applied. This might also have resulted in the kernel settings not being loaded correctly in such an instance. Should fix various issues people have had with safe mode settings not being applied properly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41500 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/loader/menu.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/system/boot/loader/menu.cpp b/src/system/boot/loader/menu.cpp index 2c2c307088..4593f92d3e 100644 --- a/src/system/boot/loader/menu.cpp +++ b/src/system/boot/loader/menu.cpp @@ -837,12 +837,9 @@ add_debug_menu() static void -apply_safe_mode_options(Menu* menu) +apply_safe_mode_options(Menu* menu, char *buffer, size_t bufferSize) { - char buffer[2048]; - int32 pos = 0; - - buffer[0] = '\0'; + int32 pos = strlen(buffer); MenuItemIterator iterator = menu->ItemIterator(); while (MenuItem* item = iterator.Next()) { @@ -850,12 +847,10 @@ apply_safe_mode_options(Menu* menu) || item->Data() == NULL || (uint32)pos > sizeof(buffer)) continue; - size_t totalBytes = snprintf(buffer + pos, sizeof(buffer) - pos, + size_t totalBytes = snprintf(buffer + pos, bufferSize - pos, "%s true\n", (const char*)item->Data()); pos += std::min(totalBytes, sizeof(buffer) - pos - 1); } - - add_safe_mode_settings(buffer); } @@ -911,10 +906,16 @@ user_menu(Directory** _bootVolume) if (item->Data() != NULL) *_bootVolume = (Directory*)item->Data(); - apply_safe_mode_options(safeModeMenu); - apply_safe_mode_options(debugMenu); + char buffer[2048]; + + memset(buffer, 0, sizeof(buffer)); + + apply_safe_mode_options(safeModeMenu, buffer, sizeof(buffer)); + apply_safe_mode_options(debugMenu, buffer, sizeof(buffer)); + add_safe_mode_settings(buffer); delete menu; + TRACE(("user_menu: leave\n")); return B_OK;