From patchwork Mon Oct 11 11:12:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 46070 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9D893858D28 for ; Mon, 11 Oct 2021 11:16:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9D893858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633950967; bh=VoGUuaLKP6nSUCSXd+TdR0iGu3vR93KZ6ekICR1otZg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=SqswLDD7MXfaUsGTfWfSqBbzt9KmZy1q1ft7DErAoDNVVpS6KhIZlarPm5mF48K/c rcUZN7SmnYm2QBjzD9auoLc6KuW2Du5bylNI9ov+4Ejc9/D6uSKc7SQRu2C6nxxDEz 87M6DTfaj0g/OUxoN3z2q3bY3TtdXXH+z1uLFnUo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id C6C073858D28 for ; Mon, 11 Oct 2021 11:15:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C6C073858D28 Received: by mail-wr1-x42f.google.com with SMTP id o20so54892381wro.3 for ; Mon, 11 Oct 2021 04:15:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VoGUuaLKP6nSUCSXd+TdR0iGu3vR93KZ6ekICR1otZg=; b=uM4LVzQ6UbndPeqzqRxyNshO9K3xpjzJ/b1bc5Qn/t7jZwbvZylpmAJyVA0ZF/0Irg W4RYq2pSz/dwLbcVZqFwP29w9xvaWmI044kmlfIZd4S1E0Kh6nC5J/WG9pdO8S1vr7RI 0/nuiNW08+UpMvEIVBCPNeeYoLEY9azH2emNSr48jUnACi6oDRqoMgeSvOAycBOLhFNw IGrGA8hS53GPvKs0AVOvx1KcN8oe0kntdnMd9mDW3DRhdn8Qy385jt38jJ6DKWx+Tlnp TDR3Le+6s0oMNjtTNESR4WjkYlUpn2PrzZZEm5awhzJvqeUMHacvltkAYsS1Cr8MsOXP 24CQ== X-Gm-Message-State: AOAM530KxTUQPPSvsdOZexWG9tm0oYZ2ny09Fxtc02BL9P9VtoYeJY+h 3ILfK54MFRvsXT1HG2tq7oU= X-Google-Smtp-Source: ABdhPJy+thS3Kp6AzgoTQwqIrx4TdJOaJPHxVqz+0//heeSeESqIAfZZJ9nDgFk5WuM0DnW8WYR54A== X-Received: by 2002:adf:de0e:: with SMTP id b14mr16791412wrm.271.1633950941945; Mon, 11 Oct 2021 04:15:41 -0700 (PDT) Received: from sqli.sqli.com ([195.53.121.100]) by smtp.googlemail.com with ESMTPSA id p17sm1215746wrx.33.2021.10.11.04.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Oct 2021 04:15:41 -0700 (PDT) To: mtk.manpages@gmail.com, linux-man@vger.kernel.org Subject: [PATCH v2 2/2] timegm.3: Remove recommendation against use of timegm() Date: Mon, 11 Oct 2021 13:12:39 +0200 Message-Id: <20211011111237.9414-2-alx.manpages@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Cc: Alejandro Colomar , libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" It was straight after a note that they are nonstandard functions, which already tells the user that if portability is in mind, they shouldn't be used, so this recommendation adds nothing in that sense. Also, there's a note that timelocal() should _never_ be used, due to mktime(3) being identical and in the POSIX standard (it is also in C99), so this note would also add nothing in that sense. So the only uses not covered by those other notes are non-portable uses of timegm(). In that scenario, it is an excellent function, since it avoids races, which a home-made timegm(3) implementation by means of standard functions would have. A trivial implementation of timegm(3) using only standard C could be (I didn't test it; use on your own): // portable_timegm.c #include time_t portable_timegm(struct tm *tm) { tm->tm_isdst = 0; /* * If another thread modifies the timezone during the * execution of the line below, it will produce undefined * behavior. */ return mktime(tm) - timezone; } Cc: Paul Eggert Signed-off-by: Alejandro Colomar --- man3/timegm.3 | 1 - 1 file changed, 1 deletion(-) diff --git a/man3/timegm.3 b/man3/timegm.3 index b848e83e1..0e8528b26 100644 --- a/man3/timegm.3 +++ b/man3/timegm.3 @@ -97,7 +97,6 @@ T} Thread safety MT-Safe env locale .SH CONFORMING TO These functions are nonstandard GNU extensions that are also present on the BSDs. -Avoid their use. .SH NOTES The .BR timelocal ()