From patchwork Sat Dec 21 22:31:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 852747 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2745912wrq; Sat, 21 Dec 2024 14:32:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBphnf45bO2nt8KQLoE493lMrXBkk64oRc7wphUHc76+sBgCpIy6UGmXYCzt0gVdzbzmXT5A==@linaro.org X-Google-Smtp-Source: AGHT+IGXDXQ1HqbXvGBgP35tCoFGm5lkM9ZL7NPFhF+vsqiFtx2QLG8wAkEYq7bZVbCmZN9Mcn4b X-Received: by 2002:a05:620a:17a0:b0:7b6:dd9c:fac6 with SMTP id af79cd13be357-7b9ba79bffcmr1107365085a.24.1734820346264; Sat, 21 Dec 2024 14:32:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1734820346; cv=pass; d=google.com; s=arc-20240605; b=B11ctL8QJBcNn5cwVJblN44KaTte/bvAYdCfJyr6oPVMVnijzsMlIBdzslEUoE2npW ppQHzDR++oGmL3Ddc7YVQp48vPXcjA/DEyGQw8EbKVEjh4Iqbn/lMJN+WjzmvBHZBOzc BnK8P/EBArA29Zfo//5/6hi/l4ulKlCOV3bHKB00eKEumcIpn6qheRfCAQ2GYFBGrUA9 DLrUQ2iozSJFXWS4BpcXOeia5E3WQ0vMiynXY3hQv5ML79+V50t9hhmlRg3iACdE8jNm LByFWtvxH1LcquSah50WlRJzolFVjgfSApPJn9tXb5135Y2Dq2lGV4zjXgheiGVzGjiV Bk1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter:arc-filter:dmarc-filter:delivered-to:dkim-filter; bh=XaCvP1i0ZSmigFbGBuLfiEuC4tsM2SQJq90Jr1Z8Ydc=; fh=rJtIiWzkCr5V2GvQGQWdJX+wkLY3kEXmUtQZbZqt0f0=; b=IDrdeDApi6hFTidip4nMyK6O5t8NzthjRj8wPqZHe9gYQc8TVm30HkN8I1xYLi8RQd RIhVe9UhkR2CB3XryvrMtbVodHQ36idJEqN4Di3svWGCy545DSA/o32A5+mXkk+1Bdpq EYc/M8L8wvxRpab42EGPUJ5Kq1h8ppUW90Q2uXAdaCGJ4F+i8eu4IiCij0LkLy/eSDSu ynqyu0uwEqdPse9hFruUI3Y8TkMAabyXHwjodUM6KRkCFtOG7Fwk/B4qTAAAeEPM+BvE 4DHpowuydbTCEm3bysbvdUawMigZv7l7ULmPNfTGKuuEHxoGrXxcvk0Ek6DGLWWoC6lU aSOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=K1cXUSvp; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2ab669si783019285a.2.2024.12.21.14.32.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 14:32:26 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=K1cXUSvp; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D00113858C3A for ; Sat, 21 Dec 2024 22:32:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D00113858C3A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=K1cXUSvp X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 659093858D3C for ; Sat, 21 Dec 2024 22:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 659093858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 659093858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734820320; cv=none; b=jc5q/d9CPUSGMSYTa/qBsV7Aooom+GXkh9ugbHJCcZRruJ6rhc05LB923FBJ5htFXQVMG35MtxDzrRm/H1YZa+2o16iHkjtf8Uyi4ez4j1WLmc4ZMU4wL7xTxKN0RlllPLrb2833IpxsA0zACwQbJS06MzqdWpgcIraobbOxF1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734820320; c=relaxed/simple; bh=60aO+vqvszoqyZ99DK0Lwu7IyjMW1DU970S/HNr/dJ4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hjXCHM1R6NxVe4oIUBWZI3d6zuwOappEb+SMMYvgrtzz6xUnzQLSR35sFnrJRJoK38gcBGAGKdf+zlZx42/s3VJ72+Hrt2NBIKvwbDm1cibz4nIcFzNmvU43r0WqQi4SD67jYxf6H9sm4Xb4JsMIzCIjRCXuvGsVSPAhW7HKLEU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 659093858D3C Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2156e078563so27555395ad.2 for ; Sat, 21 Dec 2024 14:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734820319; x=1735425119; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XaCvP1i0ZSmigFbGBuLfiEuC4tsM2SQJq90Jr1Z8Ydc=; b=K1cXUSvpA0TjtTtVaRbDbaBpKby6zA+8vzQ4ceGx946xVBP7rkpnAEudMSbEWSS7sV Qgfp4wKSP09PSuFat0EFG8idYtwps/Cf2sSzwzPu7aiTLtre/4b1jrIi4mwVwuOrkK7g PWpswi2g0QBp1KSw129Ol7tHyk2gwWa7VVexFhwlYomLeDNaILfdvz/NJcvyUghiVzhR 39jZemdjsRtrtZ1yOkQnmgIt+cwsWXfwvHrRMKOnYglRwAdpcAbYhRQ00ZiljIAKn1nt c0Wfd4QadLc3zd/qiSTzH8KrTy6yMubC5j1r/fCmboOYuVFfWPgfLfKTpEh3oIpGOCUS Ungg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734820319; x=1735425119; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XaCvP1i0ZSmigFbGBuLfiEuC4tsM2SQJq90Jr1Z8Ydc=; b=Fwjto+Y4JkS/3bbxFAVjNFvwcjDaWFomm0PIrqDfZBRQwog5A09v9X/MMI5MLw051u ug8uns0Uq5QpmDD70mramkdGC5siGyJSza3+3MT/gORf2t2BhI/m9ru7jhHYyGLeQPum 0AFCoehAAWqV1iZ3nLhJ7jTo11dmjFFKlcaLK4/gtqWRadlSm7Jxch9G9mWRNj7M824p g0DsSeK0z9zG7yD7m7CFl4kuyT2gkn53z4z9JEXAf2lKkT6MXSf3ZZkIW5fDMH50e+JB NXwiKJT0S559AakQ5t+WiFHHG0kAk0F9zcTHGsk8JLlpMT0BxSg3mbblUNuzTlT7l9Kx yZ1Q== X-Gm-Message-State: AOJu0YwWoLH4eeFLpOJjG+fT8Aq4OzW+1V6nXAnM4uKJmI5xJc75kqYO UFlb+HmlhlUwIWEn0NK7u2UKrm1nP/Es/ejhWxg9yVrHASbYUkvdtWnTCljCvGPGIA== X-Gm-Gg: ASbGncuzDqy7IWKKcoOfc3h0qGO7M7tKVRMXG8UMsFTzjLCYM+Kiwv2O70ukc0XavVA RXlT7QFeHlOcN8iJ7h263XDCKv6RAvikRuaU9NX8l1GNE8o8TgsrdUEK0vUs9BCvVnH/rqfhD9b YdEB9cdDPORdcmSqa+xIu3vDWv2Sz9PkWtaobuXnb1w7vkI+C8aBMLqwNy7dSnNWEmjwx7hzGQm jdClRMh58MGEmbhwIRp9Rt3AnIgHdJ6nm3FIYeJQ0pT7/DGqNPYcxNmFZugyPHIxgGvAZ4= X-Received: by 2002:a17:903:2282:b0:216:59ed:1ab0 with SMTP id d9443c01a7336-219e6eb3b88mr90390405ad.27.1734820319391; Sat, 21 Dec 2024 14:31:59 -0800 (PST) Received: from gnu-tgl-3.localdomain ([120.204.185.181]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc972b29sm48525205ad.111.2024.12.21.14.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 14:31:59 -0800 (PST) Received: from gnu-tgl-3.lan (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 8486FC028A; Sun, 22 Dec 2024 06:31:55 +0800 (CST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH] dirent: Remove variable lenght array structure for tst-getdents64.c Date: Sun, 22 Dec 2024 06:31:51 +0800 Message-ID: <20241221223151.753925-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org From: Adhemerval Zanella Clang emits the following warnings: ../sysdeps/unix/sysv/linux/tst-getdents64.c:111:18: error: fields must have a constant size: 'variable length array in structure' extension will never be supported char buffer[buffer_size]; ^ Co-Authored-By: H.J. Lu --- sysdeps/unix/sysv/linux/tst-getdents64.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sysdeps/unix/sysv/linux/tst-getdents64.c b/sysdeps/unix/sysv/linux/tst-getdents64.c index ba66d49a2e..feba24d7b4 100644 --- a/sysdeps/unix/sysv/linux/tst-getdents64.c +++ b/sysdeps/unix/sysv/linux/tst-getdents64.c @@ -103,6 +103,8 @@ do_test_by_size (size_t buffer_size) int fd = xopen (".", O_RDONLY | O_DIRECTORY, 0); TEST_VERIFY (fd >= 0); + char *data = xposix_memalign (_Alignof (struct dirent64), buffer_size); + /* Perform two passes, with a rewind operating between passes. */ for (int pass = 0; pass < 2; ++pass) { @@ -111,23 +113,15 @@ do_test_by_size (size_t buffer_size) while (true) { - /* Simple way to make sure that the memcpy below does not read - non-existing data. */ - struct - { - char buffer[buffer_size]; - struct dirent64 pad; - } data; - - ssize_t ret = getdents64 (fd, &data.buffer, sizeof (data.buffer)); + ssize_t ret = getdents64 (fd, data, buffer_size); if (ret < 0) FAIL_EXIT1 ("getdents64: %m"); if (ret == 0) break; ++read_count; - char *current = data.buffer; - char *end = data.buffer + ret; + char *current = data; + char *end = data + ret; while (current != end) { struct dirent64 entry; @@ -170,6 +164,8 @@ do_test_by_size (size_t buffer_size) rewinddir (reference); } + free (data); + xclose (fd); closedir (reference); }