From nobody Wed Oct 12 16:02:00 2022 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 4Mncpw4QZPz4ff9R; Wed, 12 Oct 2022 16:02:00 +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 4Mncpw3tf5z3MmS; Wed, 12 Oct 2022 16:02:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665590520; 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=wIxpV7qkTHMYwgZgw06J9/tTn25yMxLnVS3uqKMd9FI=; b=pb/ICUHZFGSE6W4vUITwZmS4FLqqgmu9W8AEU/6JB7N4nk3QZenSFNyCABCzc0NqvKTZ/+ kT+zFpuWBreDRs6gqYa+bNnZmfXgeyp6z9Tc9KnBAm+w9hUTpVJKh/xMv4EPB2//8WcdHu V1GZbQcimc06juBlJN1FQ8YwjyexR4iItEtLnhGLt/KKBcj4mBOOMo/cLIG+bUEq2IejZc ZMsy7H7Ljrgcy6vf9q9UpZi1NKnfqUDfukt3Y1FXSJni3KKogN3f4NpuPtFwBBYxKqhPDo DPqSeOmSpJAqZyfeb5PrQKfaBGdJWynobR6qvtIcV7kfa271rqwYj74e57n2SA== 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 4Mncpw2x6dz1M56; Wed, 12 Oct 2022 16:02:00 +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 29CG20el057141; Wed, 12 Oct 2022 16:02:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29CG20QC057140; Wed, 12 Oct 2022 16:02:00 GMT (envelope-from git) Date: Wed, 12 Oct 2022 16:02:00 GMT Message-Id: <202210121602.29CG20QC057140@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 3f9e5e59bda0 - main - sort: use mkstemp(3) instead of reinventing it 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: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3f9e5e59bda05acea409fa3121c835a74672de1c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665590520; 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=wIxpV7qkTHMYwgZgw06J9/tTn25yMxLnVS3uqKMd9FI=; b=d7a0qngh8g5GZwbG+RbZI/G4+5xEH5hBwdbX1cEpY/izfCugNjK8fn6nwS1xb6k3G73s/Q ry8xCsKw04QnqrhV92TjyiuD4z7PTrbXq5A3Y6bLReVnOX/ZocJRC8XKyGN9eIHYGRiXvU i/tj/ZPW2jstuwDVwI5diMyWH+wV0F8UJSb4Ws3CA5MCUCPmpON+dOWh1jVyhs51rdliVN Fqx/7hZmQr2HmvHM/hMqygwvQ865Q0l6WBQhhpEVwV0E3qdHEalwCXdwIifKdaCEGe/6CX P0tYXInP39FSYV43oikjHcIPOQzdABtMqIyyyAk86Mv6CuLsh9BI41tSGSoggA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665590520; a=rsa-sha256; cv=none; b=V9U5wjwpOAownEIJwb6E5GGE8cBcFVh9mrCqyKXyBVTS8TalGtnxXC9aOOF6ogztPcCd28 FEWPek2kjLXxOnvIRybbQzt7P8CgPRLPrp1tsSMXXF6upYpkSu3oqTOV7eWg0Ad/c9apBl EYzVYM2kjitj35YsDB9uFeMp0dH5gi/QWWDd94Dd0sO6xynSR/DAlMXBlldX7K99VHuJPj 4y0va4ZeUyGJKJqvPRRHXq5hb2sd3yvby/fV9U2FwsflS8SD24GlVipzFHd5gNmbpRCnHr IMLJbNJAOQrOj68u340UTmT5tykmyMscBpHvOZ8RlA/ClzVgLDSOGkZGUUNRMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=3f9e5e59bda05acea409fa3121c835a74672de1c commit 3f9e5e59bda05acea409fa3121c835a74672de1c Author: Baptiste Daroussin AuthorDate: 2022-10-12 15:57:37 +0000 Commit: Baptiste Daroussin CommitDate: 2022-10-12 16:01:57 +0000 sort: use mkstemp(3) instead of reinventing it MFC After: 1 week --- usr.bin/sort/file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c index ffcd71e9f991..3e5754442ac1 100644 --- a/usr.bin/sort/file.c +++ b/usr.bin/sort/file.c @@ -195,15 +195,15 @@ file_is_tmp(const char* fn) char * new_tmp_file_name(void) { - static size_t tfcounter = 0; - static const char *fn = ".bsdsort."; char *ret; - size_t sz; + int fd; - sz = strlen(tmpdir) + 1 + strlen(fn) + 32 + 1; - ret = sort_malloc(sz); + if (asprintf(&ret, "%s/.bsdsort.XXXXXXXXXX", tmpdir) == -1) + err(2, "asprintf()"); + if ((fd = mkstemp(ret)) == -1) + err(2, "mkstemp()"); + close(fd); - sprintf(ret, "%s/%s%d.%lu", tmpdir, fn, (int) getpid(), (unsigned long)(tfcounter++)); tmp_file_atexit(ret); return (ret); }