From nobody Wed Aug 23 03:41:18 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RVsSt3qZtz4qtJh; Wed, 23 Aug 2023 03:41:18 +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 4RVsSt3K2Pz3SSM; Wed, 23 Aug 2023 03:41:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692762078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6D4vLJK4hYmu0thxii35zPOUXRSh8KxzXeVLhersLxg=; b=wmk8HP2N/H7wuAf7lD+D71wJdUL3MKUgrqHyfkeTQW175Bvw9mQ82rq3kgnBciePY4Jvsq HMSKlJBUEfm9F8zMR6oBTcOqQ/3Kv2Ns9Y2e9e27tWC/9WRenTYqFEwC85KarBtg4haL1t bNStO11I7+a3NnpFpfg9Of1MSXg8yUG6sNwLss0rfYsIFLAF8mkvsRTwbyj9/Rq0nnQUZH eAeYtCiDQ+tl9s2dCICAJrNEgS6KpGPfMpjM6IiBGZSqXoeoD1Yp6Dq9XjRo+DVEgPDOYz CSbVCMnXqR7fgI09GwA9uhOvKN/QfH5BL3S2ryMDXMtj5gWC2u3dgA3yb9DeAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692762078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6D4vLJK4hYmu0thxii35zPOUXRSh8KxzXeVLhersLxg=; b=IFVdeu4KHr+3JLZWEuC7CQRAroUMEao5C7jSqzT7fxgbyYY9HB2vT1d6ZWimbVaszwZrtZ SqufnQRG9mYJqARd+sqjDlPPvJ8rbYrmLI804Yu9xR+jAh8tgrD8PLh6Ylhn4+F+O1KY4M kw2dsZcHEYHFPewicvkeXt4jClODIhyxFOH5A86KnlSV/GLMeMwWr5gVvbh0/zofcP2mGm kUhFFPn14E6KP+rqWuYOxgc4hXtIw33DBUqUPeowXhumWEK6WtuwMF4dz+RDbwK+YZf/YW EJvyYv6+0JttEtZdUUqrP5gUhoWFitvsT57EFKarsvOw3Q1COJMaXNiUZDGk5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692762078; a=rsa-sha256; cv=none; b=msilODM8oiUSPt+cOrd2gPRHcPyivxuENMyWVT6dxQZYUb593FAGZISnSTNE1S57DLcPpg 8ox6s/aZh+9Zqgn2geV+eXmOaQKzslh3YfkOcvI6imMHqS4xSpID6p5voFaPWuBNi+/EPY KspwSrDr2gfdsZhdL7CNggoewvkKCM6D+hH/dIUbGh5okY3PnnYncY5YeZRsftq6sXIJK8 yGFIuywcuOMqEfiaUZbIAREweh05ETrYwEQWpE0otxDLgfVjJV4kDLpx4dCKlQHMojrRNa +LQX1cJu9t+KGUAp0BS/cBPCkgvL3Ry6dp6imXBU1fHxSa0HYhh1RsIwkx7imQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RVsSt1kByzVXb; Wed, 23 Aug 2023 03:41:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37N3fIYU041144; Wed, 23 Aug 2023 03:41:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37N3fIe7041141; Wed, 23 Aug 2023 03:41:18 GMT (envelope-from git) Date: Wed, 23 Aug 2023 03:41:18 GMT Message-Id: <202308230341.37N3fIe7041141@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 939199a2b5e8 - main - libc: iconv: zero out cv_shared on allocation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 939199a2b5e8b5c793b9481401e468d19fda65ec Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=939199a2b5e8b5c793b9481401e468d19fda65ec commit 939199a2b5e8b5c793b9481401e468d19fda65ec Author: Kyle Evans AuthorDate: 2023-08-23 03:40:45 +0000 Commit: Kyle Evans CommitDate: 2023-08-23 03:40:45 +0000 libc: iconv: zero out cv_shared on allocation Right now we have to zero-initialize most fields in the varius callers, but this is a little error prone. Simplify it by zeroing it out upon allocation instead, drop the other redundant initialization. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D41546 --- lib/libc/iconv/bsd_iconv.c | 2 -- lib/libc/iconv/citrus_iconv.c | 5 +---- lib/libc/locale/cXXrtomb_iconv.h | 2 -- lib/libc/locale/mbrtocXX_iconv.h | 2 -- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/libc/iconv/bsd_iconv.c b/lib/libc/iconv/bsd_iconv.c index 744af30212a1..fe2491d665dd 100644 --- a/lib/libc/iconv/bsd_iconv.c +++ b/lib/libc/iconv/bsd_iconv.c @@ -70,8 +70,6 @@ __bsd___iconv_open(const char *out, const char *in, struct _citrus_iconv *handle } handle->cv_shared->ci_discard_ilseq = strcasestr(out, "//IGNORE"); - handle->cv_shared->ci_ilseq_invalid = false; - handle->cv_shared->ci_hooks = NULL; return ((iconv_t)(void *)handle); } diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c index ecb176c46063..a2ff7b5177c8 100644 --- a/lib/libc/iconv/citrus_iconv.c +++ b/lib/libc/iconv/citrus_iconv.c @@ -140,14 +140,11 @@ open_shared(struct _citrus_iconv_shared * __restrict * __restrict rci, /* initialize iconv handle */ len_convname = strlen(convname); - ci = malloc(sizeof(*ci) + len_convname + 1); + ci = calloc(1, sizeof(*ci) + len_convname + 1); if (!ci) { ret = errno; goto err; } - ci->ci_module = NULL; - ci->ci_ops = NULL; - ci->ci_closure = NULL; ci->ci_convname = (void *)&ci[1]; memcpy(ci->ci_convname, convname, len_convname + 1); diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h index 8f123e85c66d..cca2c1f160d4 100644 --- a/lib/libc/locale/cXXrtomb_iconv.h +++ b/lib/libc/locale/cXXrtomb_iconv.h @@ -75,8 +75,6 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps, errno = EINVAL; return (-1); } - handle->cv_shared->ci_discard_ilseq = false; - handle->cv_shared->ci_hooks = NULL; cs->srcbuf_len = 0; cs->initialized = true; if (s == NULL) diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h index 22b8a7d4031c..c3c832149617 100644 --- a/lib/libc/locale/mbrtocXX_iconv.h +++ b/lib/libc/locale/mbrtocXX_iconv.h @@ -78,8 +78,6 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n, errno = EINVAL; return (-1); } - handle->cv_shared->ci_discard_ilseq = false; - handle->cv_shared->ci_hooks = NULL; cs->srcbuf_len = cs->dstbuf_len = 0; cs->initialized = true; if (s == NULL)