From patchwork Sat Dec 15 17:49:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 10732281 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-2.web.codeaurora.org (Postfix) with ESMTP id 28E7817E6 for ; Sat, 15 Dec 2018 17:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DF952A20F for ; Sat, 15 Dec 2018 17:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F207C2A226; Sat, 15 Dec 2018 17:49:39 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 912522A222 for ; Sat, 15 Dec 2018 17:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726641AbeLORtj (ORCPT ); Sat, 15 Dec 2018 12:49:39 -0500 Received: from mail.ao2.it ([92.243.12.208]:37564 "EHLO ao2.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbeLORtj (ORCPT ); Sat, 15 Dec 2018 12:49:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ao2.it; s=20180927; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=v9ZF1hKl+7QkKozZO+Ett2R6dVNzQitaHmp+DJ4hAls=; b=O5abjAhxxWm8ZWYj22v5whoKpsmtUSSYtss6MxzdxBmvYSunAiihdrLXMWt6kb/pjtl1G7rcVN5zuKVneSA2VFKo6VdU3p9srbKVLXOk21LA37QwqhNebCPx2Gi2gB8ff/tu0YiiJEjBRm/0zsbW6dbzCtFvM+DThcu3daltn2PezSp4Mjt/tA2n33A9WUyhEQu8rar+bp68EeUdFAiiaDUP/HDMrqzP4YSBf8cwmXPAK/mZe6BT5XFEbNcCgXR+tvJuC40CYLelwMZSGCjjdYgkhKMhnac81v5lYLn3L4/jqSg3XYrJHQPbjUuTIcXsVt/62h2S3mkwoOKQxYC9RA==; Received: from localhost ([::1] helo=jcn) by ao2.it with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1gYE3S-00017f-Hv; Sat, 15 Dec 2018 18:48:46 +0100 Received: from ao2 by jcn with local (Exim 4.91) (envelope-from ) id 1gYE4E-00032T-IV; Sat, 15 Dec 2018 18:49:34 +0100 From: Antonio Ospite To: dash@vger.kernel.org Cc: Antonio Ospite Subject: [PATCH 1/2] Fix clang warnings about "string plus integer" Date: Sat, 15 Dec 2018 18:49:31 +0100 Message-Id: <20181215174932.11635-2-ao2@ao2.it> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181215174932.11635-1-ao2@ao2.it> References: <20181215174932.11635-1-ao2@ao2.it> MIME-Version: 1.0 X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM/Vb;]yA5\I~93>J<_`<4)A{':UrE Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Building with clang results in some warnings about integer values being added to strings: ----------------------------------------------------------------------- eval.c:1138:13: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] p = " %s" + (1 - sep); ~~~~~~^~~~~~~~~~~ eval.c:1138:13: note: use array indexing to silence this warning p = " %s" + (1 - sep); ^ & [ ] 1 warning generated. ... jobs.c:1424:16: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int] str = "\"}" + !(quoted & 1); ~~~~~~^~~~~~~~~~~~~~~ jobs.c:1424:16: note: use array indexing to silence this warning str = "\"}" + !(quoted & 1); ^ & [ ] 1 warning generated. ----------------------------------------------------------------------- While the code itself is fine and the warnings are indeed harmless, fixing them also makes the semantic more explicit: what it is actually being increased is the address which points to the start of the string in order to skip the initial character when some conditions are met. Signed-off-by: Antonio Ospite --- src/eval.c | 3 ++- src/jobs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/eval.c b/src/eval.c index f45e2e2..5074aa9 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1135,7 +1135,8 @@ eprintlist(struct output *out, struct strlist *sp, int sep) while (sp) { const char *p; - p = " %s" + (1 - sep); + p = " %s"; + p += (1 - sep); sep |= 1; outfmt(out, p, sp->text); sp = sp->next; diff --git a/src/jobs.c b/src/jobs.c index f3a0d80..26a6248 100644 --- a/src/jobs.c +++ b/src/jobs.c @@ -1421,7 +1421,8 @@ cmdputs(const char *s) str = "${"; goto dostr; case CTLENDVAR: - str = "\"}" + !(quoted & 1); + str = "\"}"; + str += !(quoted & 1); quoted >>= 1; subtype = 0; goto dostr; From patchwork Sat Dec 15 17:49:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 10732285 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-2.web.codeaurora.org (Postfix) with ESMTP id 5940D924 for ; Sat, 15 Dec 2018 17:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 499272A20F for ; Sat, 15 Dec 2018 17:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D84E288B3; Sat, 15 Dec 2018 17:49:40 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 B1B652A224 for ; Sat, 15 Dec 2018 17:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbeLORtj (ORCPT ); Sat, 15 Dec 2018 12:49:39 -0500 Received: from mail.ao2.it ([92.243.12.208]:37565 "EHLO ao2.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727216AbeLORtj (ORCPT ); Sat, 15 Dec 2018 12:49:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ao2.it; s=20180927; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=AMWnZoBaVcXZXpP8MWV/eOIhZ3F45sL8jfpqBxOvXDw=; b=ee18nTgLSNIY/7yw70xo8up8XnkC6XKxNE93C0m2+KbriUaaSdl0fvTLVaDCO4nzDPdkJKfJw37/QvUHByU7S7LLxD3T6jRI7w3jIDvf/traWEnAWgHWazE4TGb2g45Ls99dD5hrA5zpXG+BPtV+hWOJ60nYd7Y8l1jkMgvEW54nUfNS7kiZ2saeVKysyn8Ymbor9IEbmIYjcqlRf/7VmuNPfdFgVLrs+9wnOZiVOgj90Xah87dym4UKwlehKlG/V/GwAzA4P65S7n2Q73U+MWxA48tvzkdEGOC2AGcRT9gggMvNwsiE/M6KVQRzghwvDkFo4ldmahATfqQnWlgmIQ==; Received: from localhost ([::1] helo=jcn) by ao2.it with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1gYE3S-00017g-MR; Sat, 15 Dec 2018 18:48:46 +0100 Received: from ao2 by jcn with local (Exim 4.91) (envelope-from ) id 1gYE4E-00032V-Kw; Sat, 15 Dec 2018 18:49:34 +0100 From: Antonio Ospite To: dash@vger.kernel.org Cc: Antonio Ospite Subject: [PATCH 2/2] Fix clang warnings about GNU old-style field designator Date: Sat, 15 Dec 2018 18:49:32 +0100 Message-Id: <20181215174932.11635-3-ao2@ao2.it> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181215174932.11635-1-ao2@ao2.it> References: <20181215174932.11635-1-ao2@ao2.it> MIME-Version: 1.0 X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM/Vb;]yA5\I~93>J<_`<4)A{':UrE Sender: dash-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dash@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Building with clang results in some warnings about the use of GNU old-style field designators: ----------------------------------------------------------------------- output.c:86:2: warning: use of GNU old-style field designator extension [-Wgnu-designator] nextc: 0, end: 0, buf: 0, bufsize: OUTBUFSIZ, fd: 1, flags: 0 ^~~~~~ .nextc = ... ----------------------------------------------------------------------- Fix the issue bu using C99 initializers instead. This should be safe and should not introduce any compatibility problems as it is done already in other parts of the codebase, like src/expand.c:ccmatch() and src/parser.c::readtoken1(). Signed-off-by: Antonio Ospite --- src/output.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/output.c b/src/output.c index 34243ea..e9ee9b4 100644 --- a/src/output.c +++ b/src/output.c @@ -71,27 +71,27 @@ #ifdef USE_GLIBC_STDIO struct output output = { - stream: 0, nextc: 0, end: 0, buf: 0, bufsize: 0, fd: 1, flags: 0 + .stream = 0, .nextc = 0, .end = 0, .buf = 0, .bufsize = 0, .fd = 1, .flags = 0 }; struct output errout = { - stream: 0, nextc: 0, end: 0, buf: 0, bufsize: 0, fd: 2, flags: 0 + .stream = 0, .nextc = 0, .end = 0, .buf = 0, .bufsize = 0, .fd = 2, .flags = 0 } #ifdef notyet struct output memout = { - stream: 0, nextc: 0, end: 0, buf: 0, bufsize: 0, fd: MEM_OUT, flags: 0 + .stream = 0, .nextc = 0, .end = 0, .buf = 0, .bufsize = 0, .fd = MEM_OUT, .flags = 0 }; #endif #else struct output output = { - nextc: 0, end: 0, buf: 0, bufsize: OUTBUFSIZ, fd: 1, flags: 0 + .nextc = 0, .end = 0, .buf = 0, .bufsize = OUTBUFSIZ, .fd = 1, .flags = 0 }; struct output errout = { - nextc: 0, end: 0, buf: 0, bufsize: 0, fd: 2, flags: 0 + .nextc = 0, .end = 0, .buf = 0, .bufsize = 0, .fd = 2, .flags = 0 }; struct output preverrout; #ifdef notyet struct output memout = { - nextc: 0, end: 0, buf: 0, bufsize: 0, fd: MEM_OUT, flags: 0 + .nextc = 0, .end = 0, .buf = 0, .bufsize = 0, .fd = MEM_OUT, .flags = 0 }; #endif #endif