Skip to content

Commit

Permalink
use getline() instead of rc_getline()
Browse files Browse the repository at this point in the history
    getline has been in posix since POSIX.1-2008, so it should be safe for
    us to use it instead of our wrapper function.
  • Loading branch information
williamh committed Aug 1, 2024
1 parent ea310b2 commit e610020
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/librc/librc-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
fp = fopen("/proc/self/status", "r");
if (fp) {
while (!feof(fp)) {
rc_getline(&line, &len, fp);
getline(&line, &len, fp);
if (strncmp(line, "envID:\t0", 8) == 0) {
openvz_host = true;
break;
Expand Down Expand Up @@ -197,7 +197,7 @@ rc_find_pids(const char *exec, const char *const *argv, uid_t uid, pid_t pid)
if (!fp)
continue;
while (!feof(fp)) {
rc_getline(&line, &len, fp);
getline(&line, &len, fp);
if (strncmp(line, "envID:", 6) == 0) {
container_pid = !(strncmp(line, "envID:\t0", 8) == 0);
break;
Expand Down Expand Up @@ -346,7 +346,7 @@ _match_daemon(const char *path, const char *file, RC_STRINGLIST *match)
if (!fp)
return false;

while ((rc_getline(&line, &len, fp))) {
while ((getline(&line, &len, fp))) {
TAILQ_FOREACH(m, match, entries)
if (strcmp(line, m->value) == 0) {
TAILQ_REMOVE(match, m, entries);
Expand Down Expand Up @@ -559,7 +559,7 @@ rc_service_daemons_crashed(const char *service)
if (!fp)
break;

while ((rc_getline(&line, &len, fp))) {
while ((getline(&line, &len, fp))) {
p = line;
if ((token = strsep(&p, "=")) == NULL || !p)
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/librc/librc-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ rc_config_list(const char *file)
if (!(fp = fopen(file, "r")))
return list;

while ((rc_getline(&buffer, &len, fp))) {
while ((getline(&buffer, &len, fp))) {
p = buffer;
/* Strip leading spaces/tabs */
while ((*p == ' ') || (*p == '\t'))
Expand Down
6 changes: 3 additions & 3 deletions src/librc/librc.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ file_regex(const char *file, const char *regex)
return false;
}

while ((rc_getline(&line, &len, fp))) {
while ((getline(&line, &len, fp))) {
char *str = line;
/* some /proc files have \0 separated content so we have to
loop through the 'line' */
Expand Down Expand Up @@ -703,7 +703,7 @@ rc_service_extra_commands(const char *service)
free(svc);

if ((fp = popen(cmd, "r"))) {
rc_getline(&buffer, &len, fp);
getline(&buffer, &len, fp);
p = buffer;
commands = rc_stringlist_new();

Expand Down Expand Up @@ -741,7 +741,7 @@ rc_service_description(const char *service, const char *option)
snprintf(cmd, l, DESCSTR, svc, *option ? "_" : "", option);
free(svc);
if ((fp = popen(cmd, "r"))) {
rc_getline(&desc, &len, fp);
getline(&desc, &len, fp);
pclose(fp);
}
free(cmd);
Expand Down

0 comments on commit e610020

Please sign in to comment.