-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement fullGetEnv
function
#1503
Conversation
2a36252
to
8aeb125
Compare
|
||
// if g_fn.getenv was not yet defined try to parse environ | ||
size_t l = scope_strchrnul(name, '=') - name; | ||
if (l && !name[l] && environ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we please use braces here for the if and for statements here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -265,7 +265,7 @@ cfgPathSearch(const char* cfgname) | |||
char * | |||
cfgPath(void) | |||
{ | |||
const char* envPath = getenv("SCOPE_CONF_PATH"); | |||
const char* envPath = fullGetEnv("SCOPE_CONF_PATH"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are using a fullGetEnv() then checkEnv() in utils.c should be using that, it seems?
there are numerous instances where getenv() is called directly. do those need to change?
checkEnv() is called in the constructor before initFn() is called to build the g_fn object.
for verification: ld.so must be resolving getenv() to bash:getenv() else fullSetEnv() would not be required for cfgPath(). accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My focus was to support the init problem - but You are right regarding above especially the part initFn
and checkEnv
- let's discuss it.
if (!scope_strncmp(name, *e, l) && l[*e] == '=') | ||
return *e + l+1; | ||
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming that the manual check of environ works, i haven't looked or tested yet, why use g_fn.getenv? is it needed?
on the other side of the same question; there is only place where a manual check of environ could be needed. let's not use it unless it's absolutely needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intentions are following:
- I want to use
g_fn.getenv()
as first priority since this exact implementation ofgetenv
function used by the application. - Manual check of environment is the implementation taken from our internal library. I treated this as last resort in case we did not able to resolve the
g_fn.getenv
function.
My init intentions after the discussion:
|
bb20c7a
to
0960c65
Compare
- use only environ variant - replace getenv calls with fullGetEnv
0960c65
to
441a08a
Compare
LGTM |
g_fn.getenv
and a manual parsing of environgetenv("SCOPE_CONF_PATH")
will return NULLRef: #401
Fixes: #1502