From: ogasawara@osdl.org Date: Sat, 15 May 2004 06:18:46 +0000 (-0700) Subject: [PATCH] evaluate getenv() return value for udev_config.c X-Git-Tag: 026~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=c33359307b4a337d6c4f2f4fbe4451544fa5cc1f [PATCH] evaluate getenv() return value for udev_config.c Small patch to fix the evaluation logic for the return value of getenv() in udev_config.c file. Basically, the actual values for the environment variables "UDEV_NO_SLEEP" and "UDEV_NO_DEVD" were not being checked. For example UDEV_NO_SLEEP could have been set to false but the line: if (getenv("UDEV_NO_SLEEP") != NULL) in this case would always evaluate to true, since getenv() returns char*, thus the "udev_sleep" variable would be set incorrectly. The patch makes sure to check the value returned by getenv() not just if getenv() returned a value. Hope this made sense. Thanks, --- diff --git a/udev_config.c b/udev_config.c index 51a91d009..19f690c7e 100644 --- a/udev_config.c +++ b/udev_config.c @@ -60,11 +60,15 @@ static int string_is_true(char *str) return 1; if (strcasecmp(str, "yes") == 0) return 1; + if (strcasecmp(str, "1") == 0) + return 1; return 0; } static void init_variables(void) { + char *env; + /* fill up the defaults. * If any config values are specified, they will * override these values. */ @@ -76,11 +80,13 @@ static void init_variables(void) udev_log = string_is_true(UDEV_LOG_DEFAULT); udev_sleep = 1; - if (getenv("UDEV_NO_SLEEP") != NULL) + env = getenv("UDEV_NO_SLEEP"); + if (env && string_is_true(env)) udev_sleep = 0; udev_dev_d = 1; - if (getenv("UDEV_NO_DEVD") != NULL) + env = getenv("UDEV_NO_DEVD"); + if (env && string_is_true(env)) udev_dev_d = 0; }