From patchwork Tue May 8 07:06:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10385471 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2745D6037F for ; Tue, 8 May 2018 07:06:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15AD028C0A for ; Tue, 8 May 2018 07:06:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A33628CC0; Tue, 8 May 2018 07:06:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EBCC28C0A for ; Tue, 8 May 2018 07:06:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754231AbeEHHGe (ORCPT ); Tue, 8 May 2018 03:06:34 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:32886 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753419AbeEHHGd (ORCPT ); Tue, 8 May 2018 03:06:33 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1fFwhk-0002ZV-DB; Tue, 08 May 2018 15:06:32 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1fFwhj-0000Mt-Pa; Tue, 08 May 2018 15:06:31 +0800 Date: Tue, 8 May 2018 15:06:31 +0800 From: Herbert Xu To: DASH Mailing List Subject: jobs: Replace some uses of fmtstr with stpcpy/stpncpy Message-ID: <20180508070631.3arixdvlaxbjmuj4@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some uses of fmtstr, particularly the ones without a format string, can be replaced with stpcpy or stpncpy. This patch does that so we don't have to introduce unnecessary format strings in order to silence compiler warnings. Signed-off-by: Herbert Xu diff --git a/src/jobs.c b/src/jobs.c index 1a97c54..d991ee8 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -407,12 +407,11 @@ out: #endif STATIC int -sprint_status(char *s, int status, int sigonly) +sprint_status(char *os, int status, int sigonly) { - int col; + char *s = os; int st; - col = 0; st = WEXITSTATUS(status); if (!WIFEXITED(status)) { #if JOBS @@ -428,21 +427,21 @@ sprint_status(char *s, int status, int sigonly) goto out; #endif } - col = fmtstr(s, 32, strsignal(st)); + s = stpncpy(s, strsignal(st), 32); #ifdef WCOREDUMP if (WCOREDUMP(status)) { - col += fmtstr(s + col, 16, " (core dumped)"); + s = stpcpy(s, " (core dumped)"); } #endif } else if (!sigonly) { if (st) - col = fmtstr(s, 16, "Done(%d)", st); + s += fmtstr(s, 16, "Done(%d)", st); else - col = fmtstr(s, 16, "Done"); + s = stpcpy(s, "Done"); } out: - return col; + return s - os; } static void