Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Ubuntu Studio User (http://www.linux-archive.org/ubuntu-studio-user/)
-   -   memory: check for URL install in loader too (#596993). (http://www.linux-archive.org/ubuntu-studio-user/379828-memory-check-url-install-loader-too-596993-a.html)

Hans de Goede 06-01-2010 01:13 PM

memory: check for URL install in loader too (#596993).
 
Hi,

On 06/01/2010 02:14 PM, Ales Kozumplik wrote:

---
loader/loader.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index fbbd13b..59d5beb 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -1142,12 +1142,22 @@ static void parseCmdLineFlags(struct loaderData_s * loaderData,
}

/* make sure they have enough ram */
-static void checkForRam(void) {
- if (totalMemory()< MIN_RAM) {
+static void checkForRam(int install_method) {
+ char reason_no[] = "";
+ char reason_method[] = " using this install method";

> + char *reason = reason_no;

It would better to use:

const char *reason_no = "";
const char *reason_method = " using this install method";
const char *reason = reason_no;


When you write:
char reason_method[] = " using this install method";

You are asking the compiler to create a const string
" using this install method" in the constant segment, and
to allocate an array on the stack large enough to hold this
string, and upon entering of the function to copy the contents
of the const string to the array on the stack. It would be
better (more efficient) to just pass a pointer around.

Other then this, ack.


+ int needed = MIN_RAM;
+
+ if (install_method == METHOD_URL) {
+ needed += URL_INSTALL_EXTRA_RAM;
+ reason = reason_method;
+ }
+
+ if (totalMemory()< needed) {
char *buf;

checked_asprintf(&buf, _("You do not have enough RAM to install %s "
- "on this machine."), getProductName());
+ "on this machine%s."), getProductName(), reason);

startNewt();
newtWinMessage(_("Error"), _("OK"), buf);
@@ -1535,6 +1545,7 @@ static char *doLoaderMain(struct loaderData_s *loaderData,
}

logMessage(INFO, "starting STEP_STAGE2");
+ checkForRam(loaderData->method);
url = installMethods[validMethods[loaderData->method]].mountImage(
installMethods + validMethods[loaderData->method],
"/mnt/stage2", loaderData);
@@ -1949,7 +1960,7 @@ int main(int argc, char ** argv) {
}
initializeConsole();

- checkForRam();
+ checkForRam(-1);

/* iSeries vio console users will be ssh'ing in to the primary
partition, so use a terminal type that is appripriate */


Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 06:44 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.