osaf/services/saf/logsv/lgs/lgs_imm.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
On UML based on ubuntu, the following code fails consistently. if ((val_str = getenv(LOGSV_MAX_LOGRECSIZE)) != NULL) { val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER(Illegal value for LOGSV_MAX_LOGRECSIZE -....., strerror(errno), lgsConf->logMaxLogrecsize); lgsConf->logMaxLogrecsize_noteflag = true; i.e. the errno is always getting set to a nonzero value. Because of this, when user configures an environment variable, the above code fails causing log to assign default values rather than the values from the environment variables. As per strotul, errno = 0 has to be done before calling strotul. The following NOTE from the man page of strtoul is for reference: NOTES Since strtoul() can legitimately return 0 or ULONG_MAX (ULLONG_MAX for strtoull()) on both success and failure, the calling program should set errno to 0 before the call, and then determine if an error occurred by checking whether errno has a nonzero value after the call. . With this patch, when a environment variable is configured(when the default configuration object is not configured) then LOG shall use the value specified in the environment variable instead of setting default values. diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.c b/osaf/services/saf/logsv/lgs/lgs_imm.c --- a/osaf/services/saf/logsv/lgs/lgs_imm.c +++ b/osaf/services/saf/logsv/lgs/lgs_imm.c @@ -1890,6 +1890,14 @@ static void read_logsv_config_environ_va /* logMaxLogrecsize */ if ((val_str = getenv("LOGSV_MAX_LOGRECSIZE")) != NULL) { +/* errno = 0 is necessary as per the manpage of strtoul. Quoting here: + * NOTES: + * Since strtoul() can legitimately return 0 or ULONG_MAX (ULLONG_MAX for strtoull()) + * on both success and failure, the calling program should set errno to 0 before the call, + * and then determine if an error occurred by checking whether errno has a + * nonzero value after the call. + */ + errno = 0; val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER("Illegal value for LOGSV_MAX_LOGRECSIZE - %s, default %u", @@ -1907,6 +1915,7 @@ static void read_logsv_config_environ_va /* logStreamSystemHighLimit */ if ((val_str = getenv("LOG_STREAM_SYSTEM_HIGH_LIMIT")) != NULL) { + errno = 0; val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER("Illegal value for LOG_STREAM_SYSTEM_HIGH_LIMIT - %s, default %u", @@ -1924,6 +1933,7 @@ static void read_logsv_config_environ_va /* logStreamSystemLowLimit */ if ((val_str = getenv("LOG_STREAM_SYSTEM_LOW_LIMIT")) != NULL) { + errno = 0; val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER("Illegal value for LOG_STREAM_SYSTEM_LOW_LIMIT - %s, default %u", @@ -1941,6 +1951,7 @@ static void read_logsv_config_environ_va /* logStreamAppHighLimit */ if ((val_str = getenv("LOG_STREAM_APP_HIGH_LIMIT")) != NULL) { + errno = 0; val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER("Illegal value for LOG_STREAM_APP_HIGH_LIMIT - %s, default %u", @@ -1958,6 +1969,7 @@ static void read_logsv_config_environ_va /* logStreamAppLowLimit */ if ((val_str = getenv("LOG_STREAM_APP_LOW_LIMIT")) != NULL) { + errno = 0; val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER("Illegal value for LOG_STREAM_APP_LOW_LIMIT - %s, default %u", @@ -1975,6 +1987,7 @@ static void read_logsv_config_environ_va /* logMaxApplicationStreams */ if ((val_str = getenv("LOG_MAX_APPLICATION_STREAMS")) != NULL) { + errno = 0; val_uint = strtoul(val_str, NULL, 0); if ((errno != 0) || (val_uint > UINT_MAX)) { LOG_ER("Illegal value for LOG_MAX_APPLICATION_STREAMS - %s, default %u", ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available. Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel