From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D33B01382C5 for ; Wed, 21 Feb 2018 19:50:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2D17CE0917; Wed, 21 Feb 2018 19:50:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0F1EEE0917 for ; Wed, 21 Feb 2018 19:50:47 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E79B2335C30 for ; Wed, 21 Feb 2018 19:50:46 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A1D411F1 for ; Wed, 21 Feb 2018 19:50:45 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1519242581.a6cc7f06cf3807a0e0590697e1f14e6ab9055271.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/rc.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: a6cc7f06cf3807a0e0590697e1f14e6ab9055271 X-VCS-Branch: master Date: Wed, 21 Feb 2018 19:50:45 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 7f47c1ca-66d1-4014-be06-af7e1483e603 X-Archives-Hash: 9d30ba6b0780843517bb16321e86fb2a commit: a6cc7f06cf3807a0e0590697e1f14e6ab9055271 Author: William Hubbs gmail com> AuthorDate: Wed Feb 21 19:49:41 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Wed Feb 21 19:49:41 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a6cc7f06 rc.c: remove PATH_MAX references src/rc/rc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/rc/rc.c b/src/rc/rc.c index 110591e4..1f462c66 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -336,26 +336,26 @@ set_krunlevel(const char *level) return true; } -static size_t -get_krunlevel(char *buffer, int buffer_len) +static char *get_krunlevel(void) { + char *buffer = NULL; FILE *fp; size_t i = 0; if (!exists(RC_KRUNLEVEL)) - return 0; + return NULL; if (!(fp = fopen(RC_KRUNLEVEL, "r"))) { eerror("fopen `%s': %s", RC_KRUNLEVEL, strerror(errno)); - return 0; + return NULL; } - if (fgets(buffer, buffer_len, fp)) { + if (getline(&buffer, &i, fp) != -1) { i = strlen(buffer); if (buffer[i - 1] == '\n') buffer[i - 1] = 0; } fclose(fp); - return i; + return buffer; } static void @@ -743,7 +743,7 @@ int main(int argc, char **argv) RC_STRING *service; bool going_down = false; int depoptions = RC_DEP_STRICT | RC_DEP_TRACE; - char krunlevel [PATH_MAX]; + char *krunlevel = NULL; char pidstr[10]; int opt; bool parallel; @@ -892,7 +892,8 @@ int main(int argc, char **argv) (strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 && strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0)) { - if (get_krunlevel(krunlevel, sizeof(krunlevel))) { + krunlevel = get_krunlevel(); + if (krunlevel) { newlevel = krunlevel; set_krunlevel(NULL); }