From owner-dev-commits-src-main@freebsd.org Thu Jul 22 19:23:39 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6CE1664985; Thu, 22 Jul 2021 19:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GW2Rv4Jbpz4srH; Thu, 22 Jul 2021 19:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C768178A1; Thu, 22 Jul 2021 19:23:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16MJNd6A066420; Thu, 22 Jul 2021 19:23:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16MJNdAw066419; Thu, 22 Jul 2021 19:23:39 GMT (envelope-from git) Date: Thu, 22 Jul 2021 19:23:39 GMT Message-Id: <202107221923.16MJNdAw066419@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Pedro F. Giffuni" Subject: git: c384a27805a6 - main - patch: cleanup variable initialization a bit. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pfg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c384a27805a630ae45ca3d97614a07ebfce5515d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2021 19:23:39 -0000 The branch main has been updated by pfg: URL: https://cgit.FreeBSD.org/src/commit/?id=c384a27805a630ae45ca3d97614a07ebfce5515d commit c384a27805a630ae45ca3d97614a07ebfce5515d Author: Pedro F. Giffuni AuthorDate: 2021-07-22 19:09:17 +0000 Commit: Pedro F. Giffuni CommitDate: 2021-07-22 19:23:22 +0000 patch: cleanup variable initialization a bit. musl libc fgetln is a bit more pickier. Hinted by: chimera-linux (git 31491e1de2e1241885984cd9e4b978965f14eda4) --- usr.bin/patch/inp.c | 4 +++- usr.bin/patch/pch.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c index 6a01f782ce62..99be70957f06 100644 --- a/usr.bin/patch/inp.c +++ b/usr.bin/patch/inp.c @@ -284,7 +284,7 @@ static void plan_b(const char *filename) { FILE *ifp; - size_t i = 0, j, len, maxlen = 1; + size_t i, j, len, maxlen; char *lbuf = NULL, *p; bool found_revision = (revision == NULL); @@ -294,6 +294,8 @@ plan_b(const char *filename) unlink(TMPINNAME); if ((tifd = open(TMPINNAME, O_EXCL | O_CREAT | O_WRONLY, 0666)) < 0) pfatal("can't open file %s", TMPINNAME); + len = 0; + maxlen = 1; while ((p = fgetln(ifp, &len)) != NULL) { if (p[len - 1] == '\n') p[len - 1] = '\0'; diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index 70051640cf0c..d1d71f95644c 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -1215,7 +1215,7 @@ size_t pgets(bool do_indent) { char *line; - size_t len; + size_t len = 0; int indent = 0, skipped = 0; line = fgetln(pfp, &len);