From a44252d21a1e548d8cbafd63d6b3a16b083b08c0 Mon Sep 17 00:00:00 2001 From: Dylan Lom Date: Sat, 16 Jan 2021 14:20:29 +1100 Subject: [PATCH] Rename variable fp to pp in command_execute This makes it clearer the it is a pipe being read, not a file and distinguishes it from fp, which is being used elsewhere to mean the source of incoming shmd (e.g. stdin). --- shmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shmd.c b/shmd.c index 8cad291..86b8e18 100644 --- a/shmd.c +++ b/shmd.c @@ -7,9 +7,9 @@ const char* argv0; char* command_execute(const char* command) { - FILE *fp; - fp = popen(command, "r"); - if (fp == NULL) edie("popen: "); + FILE *pp; + pp = popen(command, "r"); + if (pp == NULL) edie("popen: "); char* result = calloc(1, sizeof(char)); if (result == NULL) edie("calloc: "); @@ -23,13 +23,13 @@ char* command_execute(const char* command) { * str_concat allocates a new string on the heap, so free the old memory * when we concat the next line of output. */ - while (fgets(buf, buf_size, fp) != NULL) { + while (fgets(buf, buf_size, pp) != NULL) { char* tmp = result; result = str_concat(2, result, buf); free(tmp); } free(buf); - pclose(fp); + pclose(pp); result = str_trimr(result, '\n', 1); return result;