chameleon keeps printing sscanf: Success
If one have an env variable set to empty tring instead of int and chameleon_getenv_get_value_int() is used to retrieve it, it will print "sscanf: Success".
A more precise error message or no error message could help: A possible fix:
static inline int
chameleon_getenv_get_value_int(char * string, int default_value) {
long int ret;
char *str = chameleon_getenv(string);
if (str == NULL) return default_value;
errno = 0;
if ( sscanf( str, "%ld", &ret ) != 1 ) {
if (errno != 0) {
perror("sscanf");
}
else {
// Or we can even remove this message and consider that empty string means default value with no error message.
fprintf(stderr, "CHAMELEON ERROR: %s() : Empty env variable %s while int value expected\n", __FUNCTION__, string);
}
return default_value;
}
return (int)ret;
}
This requires also to add include <errno.h>
Edited by Xavier Lacoste