Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217807/?format=api
{ "id": 2217807, "url": "http://patchwork.ozlabs.org/api/patches/2217807/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260330153802.686499-2-vikingtc4@gmail.com/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260330153802.686499-2-vikingtc4@gmail.com>", "list_archive_url": null, "date": "2026-03-30T15:38:02", "name": "[GSoC,1/1] analyzer: fix false positive -Wanalyzer-fd-use-without-check on dup2 [PR113329]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "7faa4fbb7a831808b066b6767bec0149abf959d1", "submitter": { "id": 92831, "url": "http://patchwork.ozlabs.org/api/people/92831/?format=api", "name": "Trieu Huynh", "email": "vikingtc4@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260330153802.686499-2-vikingtc4@gmail.com/mbox/", "series": [ { "id": 498061, "url": "http://patchwork.ozlabs.org/api/series/498061/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=498061", "date": "2026-03-30T15:38:01", "name": "Trieu Huynh - First Patch Submission", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498061/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217807/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217807/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=GOsi4Iqk;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=GOsi4Iqk", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", "sourceware.org; spf=pass smtp.mailfrom=gmail.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.210.181" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fkwQM6Jz6z1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 02:38:51 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id B238A4B920A5\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 30 Mar 2026 15:38:49 +0000 (GMT)", "from mail-pf1-f181.google.com (mail-pf1-f181.google.com\n [209.85.210.181])\n by sourceware.org (Postfix) with ESMTPS id 03BC34BB58E6\n for <gcc-patches@gcc.gnu.org>; Mon, 30 Mar 2026 15:38:17 +0000 (GMT)", "by mail-pf1-f181.google.com with SMTP id\n d2e1a72fcca58-829ac4670c4so3386113b3a.0\n for <gcc-patches@gcc.gnu.org>; Mon, 30 Mar 2026 08:38:16 -0700 (PDT)", "from trieu2-huynh-trieuhpn-ubuntu24.bee-live.svc.cluster.local\n ([27.122.242.65]) by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82ca80d0b6esm9250414b3a.0.2026.03.30.08.38.14\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 30 Mar 2026 08:38:15 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org B238A4B920A5", "OpenDKIM Filter v2.11.0 sourceware.org 03BC34BB58E6" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 03BC34BB58E6", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 03BC34BB58E6", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774885097; cv=none;\n b=aXZGueCAbObPXAf7ASb19Q/A0ipDUmwNxelKq249lFpYyHcyCR+TmriZNkw52unG9MWtpvw5Ay8L9FTVh9aDT9bfBEDSQJ5st2BIb0/wLhmDRGVU6W4U5SYb9PB+YiCDQnB6UGNEJQqtLj7WCNATu4JHRv983cY7nRl8IrY6YPA=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774885097; c=relaxed/simple;\n bh=vO67fCpZXKgQOnD5ihlLzbtzqSp6JYgK3+/KwWDg20k=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=tpqpER9wDoQnAVo2VuHlfzf+AfyKxmHktnz5TcejtOP44YIaElRMxHn4pL72pb0lk+OFQxEO3VJ2H8lfeGAgj40ZCFR8BM/mhJuGMrRwsuw/JJ/F/nWeo2RbQTfYPBUurrduPE0iSqhTxusJO1jfmS0inYbJnoIMso7trwqndT8=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774885096; x=1775489896; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=L4XrXIUOzxquZ6gTGGBE3ljaxPnKmxz3nLufsqR2uMo=;\n b=GOsi4Iqk8wcdFPoN6dbMTT+bYeyeXJhKl1B1B4pngL+U356rmxoFZqJgpMaxTBnDFn\n jYVvdGhdDgRuXMjRjNFhK8VTkyjI7tnBD1ghVy21PnzkkC9QJCfMaXVLRtmU7X6yC/2Y\n 6f79/Ce7LKwP5bhEBzkfcTMHhB8qT5NKdE7M3Zfa+tnneS9Ti+IXReGCcbKRs3CKB1KF\n rMd7uEOpH9tmmVlrP+X5ElbaZ4h1rKnTwacDRyB2RQnhgJ7ZIXkK4jLLTkqhmgHu8iZx\n 41ncz3BfsNYNihNYUdpt7US36G8zQNbRM7BoAP0pv2FP6eeKB+ns9A8KCHqXsFSgQE/A\n clRA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774885096; x=1775489896;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=L4XrXIUOzxquZ6gTGGBE3ljaxPnKmxz3nLufsqR2uMo=;\n b=EWhJ2ii3GL+OQ9z7iEXHDrcYt5wUwJvhnR0CVUxKexyaQL8xYz375XtxZ2BVcGsBsr\n wj+j/pXYJRWqsom0xXR+1xAS//ua8TwrLV3F+6mWUU/HOujvwMrI0OXIQHVShUxXM2W5\n LsosyyfQS3tfI8j5Xd6RuREmQi2ewhIzDq5Im1oP//zHlzXt6eAFD8owkdNL8l4LQM90\n 9zrz1TK7OHDAkdkd+GU1ZFkiI7MBaf8fYRxUNIDyDzDcJFHUf9MTM+kwRGlIO2e7pvZ8\n iv/EZF8mWz7DWrV2xfqVhPJwtMDQOhu/fTZV1TWOOHMHCwl+7ptcV+IdBbSg9toCQhlD\n ZEMw==", "X-Gm-Message-State": "AOJu0YwJB2mtai48NWIlyiTzleXUWOgKOprBq8fpcBkyZiOAIw4PSak6\n odgSy+vDrO8ZqYvzrKnYGyrqFh3+ZE/E4pdV88UK5uLG5B0pPzf/7Vf8u5WCu9MI", "X-Gm-Gg": "ATEYQzzesrk0ZZJrlTKtNCOq2EG55cvYQDXvuqWlavJeBvqlZZAG2sCnLLTu1a0aJbQ\n FJxpCS1TLsFfPOQCOquDLQuon2PV1RjFbwlCA6Ltn14zeJO65JSQzTqNf2YWugSYOmEZmT38XBW\n UxQHEUIE5yEnrLlqOWGug/zUWGLy8Wv8VvcybrWqo7/BMO/vSfMXgxZvNGB6eGvFXSGj7WbUs8j\n 1GSRT8mL7qrR3kBrgxR7TJsmOaIYrAu+zLl2Qr/aajeIIh+CF4eUYo0KV+BoUGzS49yTolWKP3b\n s/10hrcacgLqILIwrt94Cvi/RZBXilqFBmiTOezcVEHdjwSeSdKkDvh4eCSI85Hop0OzDaa4iMg\n AfMvw8MD9i0+IMWGojyE6lPCfXilb5rF5XuHF3KyYx6gux3EnngdJbtf97srsNeEVZ0CaB1OYeM\n Z6uxCByTyXemQF5oAbdHsKZJ6NDPIhgeeUNvNQzb4hxqOvf+85s0nexPUawZ0shEqNH42D5ejxT\n oUGfAWU5A==", "X-Received": "by 2002:a05:6a00:340b:b0:82c:2445:bd52 with SMTP id\n d2e1a72fcca58-82c95c111aemr12330013b3a.14.1774885095695;\n Mon, 30 Mar 2026 08:38:15 -0700 (PDT)", "From": "Trieu Huynh <vikingtc4@gmail.com>", "To": "gcc-patches@gcc.gnu.org", "Cc": "dmalcolm@redhat.com,\n\tTrieu Huynh <vikingtc4@gmail.com>", "Subject": "[GSoC PATCH 1/1] analyzer: fix false positive\n -Wanalyzer-fd-use-without-check on dup2 [PR113329]", "Date": "Tue, 31 Mar 2026 00:38:02 +0900", "Message-ID": "<20260330153802.686499-2-vikingtc4@gmail.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260330153802.686499-1-vikingtc4@gmail.com>", "References": "<20260330153802.686499-1-vikingtc4@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "The analyzer was triggering a false positive warning when dup2 was called\nwith a destination file descriptor that had just been closed. According\nto POSIX, dup2(oldfd, newfd) is perfectly valid even if newfd is closed\n(it will be silently closed if it was open).\n\nThis patch updates the state machine to allow file descriptors in the\n'closed' state to be used as the second argument to dup2.\n\ngcc/analyzer/ChangeLog:\n\tPR analyzer/113329\n\t* sm-fd.cc (fd_state_machine::check_for_dup): Allow closed file\n\tdescriptors as the second argument to dup2.\n\ngcc/testsuite/ChangeLog:\n\tPR analyzer/113329\n\t* c-c++-common/analyzer/dup2.c: New test.\n\nSigned-off-by: Trieu Huynh <vikingtc4@gmail.com>\n---\n gcc/analyzer/sm-fd.cc | 2 +-\n gcc/testsuite/c-c++-common/analyzer/dup2.c | 10 ++++++++++\n 2 files changed, 11 insertions(+), 1 deletion(-)\n create mode 100644 gcc/testsuite/c-c++-common/analyzer/dup2.c", "diff": "diff --git a/gcc/analyzer/sm-fd.cc b/gcc/analyzer/sm-fd.cc\nindex 0da4cc5d9df..7a5b582e268 100644\n--- a/gcc/analyzer/sm-fd.cc\n+++ b/gcc/analyzer/sm-fd.cc\n@@ -1594,7 +1594,7 @@ fd_state_machine::check_for_dup (sm_context &sm_ctxt, const gcall &call,\n \treturn;\n /* Check if -1 was passed as second argument to dup2. */\n if (!(is_constant_fd_p (state_arg_2) || is_valid_fd_p (state_arg_2)\n-\t || state_arg_2 == m_start))\n+\t || state_arg_2 == m_start || is_closed_fd_p (state_arg_2)))\n \t{\n \t sm_ctxt.warn\n \t (arg_2,\ndiff --git a/gcc/testsuite/c-c++-common/analyzer/dup2.c b/gcc/testsuite/c-c++-common/analyzer/dup2.c\nnew file mode 100644\nindex 00000000000..73150ba00e7\n--- /dev/null\n+++ b/gcc/testsuite/c-c++-common/analyzer/dup2.c\n@@ -0,0 +1,10 @@\n+/* { dg-do compile } */\n+/* { dg-options \"-fanalyzer\" } */\n+\n+#include <unistd.h>\n+\n+void test_dup2 (int oldfd, int newfd)\n+{\n+ close (newfd);\n+ dup2 (oldfd, newfd); /* { dg-bogus \"on possibly invalid file descriptor\" } */\n+}\n\\ No newline at end of file\n", "prefixes": [ "GSoC", "1/1" ] }