You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The other functions listed above have no options at all AFAICT. However, that's not so bad. If we ignore test and example code, as well as the functions which alternatives, we're left with:
I will write a tree-surgeon script for getpwnam -> getpwnam_r, getservbyname -> getaddrinfo, localeconv -> nl_langinfo_l, nl_langinfo -> nl_langinfo_l, strerror -> strerror_r and strtok -> strtok_r.
basename and dirname are marked thread-safe on Linux and I don't know why they wouldn't be on any platform, AFAIK getenv can only race with setenv, which we only use in tests, and getopt is only used in the deprecated pythongen code. So I think we can ignore all of these.
The text was updated successfully, but these errors were encountered:
I will still write a migration script for strerror, but it will be specific to Elektra and rely on a elektraStrError function I'll add to libelektra-core or as static inline to a suitable header. The reason is that glibc and POSIX have conflicting implementations for strerror_r and you cannot write a generic migration script without knowing which implementation will be used.
Automatic migration for getpwnam would probably be possible, but it's very non-trivial because it involves additional calls to sysconf and possible repeated attempts in a loop for the generic case. We only use it once, developing a script is simply not worth it. I'll refactor manually.
It's a similar story for getservbyname.
Generic scripts for nl_langinfo, localconv and strtok should be doable.
strtok cannot be migrated with a generic script. A restricted script that makes some assumptions about how strtok is used (*1) would be possible. But by now we use the function exactly 5 times in the entire repo. Writing and testing a script would not be worth it.
Similarly for the two uses of localeconv the time for developing a script is too much. However, in this case a more generic script would be possible (*2).
So only nl_langinfo can actually be updated in generic fashion, by replacing nl_langinfo(X) with
locale_tloc=newlocale (LC_ALL, setlocale (LC_ALL, NULL), NULL);
// nl_langinfo line with nl_langinfo(X) replaced by nl_langinfo_l(X, loc)freelocale (loc);
(*1) not across different scopes, not switching delimiters, etc.
(*2) it would still be necessary to assume the result of localeconv is only used within a single function call, so that stack allocation can be used as a replacement for the global result of localeconv
Using the list of functions for which POSIX does not guarantee thread-safety from here, I have now found that we use (with usage counts):
basename
: 1dirname
: 3dlerror
: 1getenv
: 9getopt
: 1getpwnam
: 1getservbyname
: 1localeconv
: 1nl_langinfo
: 1rand
: 1setenv
: 2setlocale
: 3strerror
: 18strsignal
: 1strtok
: 3system
: 1unsetenv
: 1wctomb
: 1Full results here
I found these replacement functions
getpwnam
->getpwnam_r
getservbyname
->getaddrinfo
localeconv
->nl_langinfo_l
nl_langinfo
->nl_langinfo_l
strerror
->strerror_r
strsignal
->strdescr_np
(GNU)strtok
->strtok_r
The other functions listed above have no options at all AFAICT. However, that's not so bad. If we ignore test and example code, as well as the functions which alternatives, we're left with:
basename
:dirname
:getservbyname
:getopt
:getenv
:I will write a
tree-surgeon
script forgetpwnam
->getpwnam_r
,getservbyname
->getaddrinfo
,localeconv
->nl_langinfo_l
,nl_langinfo
->nl_langinfo_l
,strerror
->strerror_r
andstrtok
->strtok_r
.basename
anddirname
are marked thread-safe on Linux and I don't know why they wouldn't be on any platform, AFAIKgetenv
can only race withsetenv
, which we only use in tests, andgetopt
is only used in the deprecated pythongen code. So I think we can ignore all of these.The text was updated successfully, but these errors were encountered: