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 C5E39138334 for ; Tue, 19 Jun 2018 22:07:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CB173E0849; Tue, 19 Jun 2018 22:07:10 +0000 (UTC) Received: from smtp.gentoo.org (dev.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 97118E0849 for ; Tue, 19 Jun 2018 22:07:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 09D98335C60 for ; Tue, 19 Jun 2018 22:07:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5AA9C2DA for ; Tue, 19 Jun 2018 22:07:07 +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: <1529445993.be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/rc-status.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4 X-VCS-Branch: master Date: Tue, 19 Jun 2018 22:07:07 +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: 66b1d9e1-b3e3-4b06-bca2-3d926b0ebd9d X-Archives-Hash: 4686df2f13614a9e95e194b889105f57 commit: be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 22:06:33 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 22:06:33 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=be7ad06d rc-status: convert snprintf calls to xasprintf src/rc/rc-status.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index a6b8d299..85e71dbb 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -126,7 +126,7 @@ static char *get_uptime(const char *service) static void print_service(const char *service) { - char status[60]; + char *status = NULL; char *uptime = NULL; char *child_pid = NULL; char *start_time = NULL; @@ -136,12 +136,12 @@ print_service(const char *service) ECOLOR color = ECOLOR_BAD; if (state & RC_SERVICE_STOPPING) - snprintf(status, sizeof(status), "stopping "); + xasprintf(&status, "stopping "); else if (state & RC_SERVICE_STARTING) { - snprintf(status, sizeof(status), "starting "); + xasprintf(&status, "starting "); color = ECOLOR_WARN; } else if (state & RC_SERVICE_INACTIVE) { - snprintf(status, sizeof(status), "inactive "); + xasprintf(&status, "inactive "); color = ECOLOR_WARN; } else if (state & RC_SERVICE_STARTED) { errno = 0; @@ -150,30 +150,31 @@ print_service(const char *service) child_pid = rc_service_value_get(service, "child_pid"); start_time = rc_service_value_get(service, "start_time"); if (start_time && child_pid) - snprintf(status, sizeof(status), " unsupervised "); + xasprintf(&status, " unsupervised "); else - snprintf(status, sizeof(status), " crashed "); + xasprintf(&status, " crashed "); free(child_pid); free(start_time); } else { uptime = get_uptime(service); if (uptime) { - snprintf(status, sizeof(status), " started %s", uptime); + xasprintf(&status, " started %s", uptime); free(uptime); } else - snprintf(status, sizeof(status), " started "); + xasprintf(&status, " started "); color = ECOLOR_GOOD; } } else if (state & RC_SERVICE_SCHEDULED) { - snprintf(status, sizeof(status), "scheduled"); + xasprintf(&status, "scheduled"); color = ECOLOR_WARN; } else - snprintf(status, sizeof(status), " stopped "); + xasprintf(&status, " stopped "); errno = 0; if (c && *c && isatty(fileno(stdout))) printf("\n"); ebracket(cols, color, status); + free(status); } static void