tree-wide: replace string functions with fundamental functions

This commit is contained in:
Rose
2024-01-11 13:36:25 +09:00
committed by Yu Watanabe
parent 658169e6d3
commit aa9ff6c28d
7 changed files with 30 additions and 38 deletions
+5 -4
View File
@@ -1024,7 +1024,7 @@ int getenv_for_pid(pid_t pid, const char *field, char **ret) {
_cleanup_fclose_ FILE *f = NULL;
char *value = NULL;
const char *path;
size_t l, sum = 0;
size_t sum = 0;
int r;
assert(pid >= 0);
@@ -1059,9 +1059,9 @@ int getenv_for_pid(pid_t pid, const char *field, char **ret) {
if (r < 0)
return r;
l = strlen(field);
for (;;) {
_cleanup_free_ char *line = NULL;
const char *match;
if (sum > ENVIRONMENT_BLOCK_MAX) /* Give up searching eventually */
return -ENOBUFS;
@@ -1074,8 +1074,9 @@ int getenv_for_pid(pid_t pid, const char *field, char **ret) {
sum += r;
if (strneq(line, field, l) && line[l] == '=') {
value = strdup(line + l + 1);
match = startswith(line, field);
if (match && *match == '=') {
value = strdup(match + 1);
if (!value)
return -ENOMEM;