From patchwork Sun Dec 22 00:04:37 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: 852900 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2775281wrq; Sat, 21 Dec 2024 16:38:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVxUOmbSzaZNufdytmqKfofaF2fKr/ncCfpGMgPdOlN5vvsLkq59WJCRKpXoN7YXQnDiBJKIg==@linaro.org X-Google-Smtp-Source: AGHT+IEOqBqxbqb1pwzgV7HGEMclUcdb4+R5gorS/g8us142Ma5f5UYWX8SncTFOTiQOxK/OIT98 X-Received: by 2002:ac8:59d3:0:b0:467:6f59:e343 with SMTP id d75a77b69052e-46a4a8cc56dmr118506361cf.21.1734827887463; Sat, 21 Dec 2024 16:38:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1734827887; cv=pass; d=google.com; s=arc-20240605; b=eaB/LTVcazkg24ZGxRz+JPRBhIlD84E/sqYepxya/Kg9KOaTEXqS7atAY9v55tat7G PhjH52/dPmwZ2poQrsu4p1scltcpZ7ZkvQBR+O5pB4VtIw4O4/tqEkgl0TQS79/qBgnS C/YZAHRK4dT5h7Y1ZOo4zbcJp55cLwQGpYKlFTdUclcTEn90LccsmmITGlG+SaPe9Gm2 iJlXnr3fAnpiM8IQt0DbOzvJIFJyZUNfE53LWaISNxTWbV9Tn1TXyjQunkHA/nFC8c1N M5Rx/3aBkQBzccmIj2nKYsvwIptGyDJjvtFeWa7H8ypAGyfpYSdZGXRRdcVzmyM+yDIQ 5W1w== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=XaCvP1i0ZSmigFbGBuLfiEuC4tsM2SQJq90Jr1Z8Ydc=; fh=uKlFkH9AUukvL1xmvBA9M7Oe4ntiJIR8HCR4+3TPd4w=; b=HkJ8kUQB8jb3duqZOcPmYw2eJhLUWZWasBDa8oQH+DgSWerIuYNGdtRbCzZhaT5gzR nmMgHRXo1kbVslHCanRujkR5i0msnVBJw//s2GoISOPLhx8gF6fac4y+Xq5eJWj/nwti cb7+eg5Pz1Hos+N+adPeVdUXD958sBiTCi4lhx/gXfPU+4Vx+EU2PW3JYT+vExbCK++f tkBkpS/8uk1nQh2cEv/lg1dbc+3ppdTcKlEulfq9qFLOzRNyasxjFSJqm9Rz0pAltWUS Wb+jaaBYtMV5efBGpG5CLmuKmuIHw22LnCVLaNmlR2qiERAKtN/CJV83BB+SHdXYqxLc Q91g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L48Jzo4v; 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 d75a77b69052e-46a3eb99f9esi84404591cf.355.2024.12.21.16.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 16:38:07 -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=L48Jzo4v; 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 0ED54385840F for ; Sun, 22 Dec 2024 00:38:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ED54385840F 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=L48Jzo4v X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 8C03A385842A for ; Sun, 22 Dec 2024 00:05:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C03A385842A 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 8C03A385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734825924; cv=none; b=xRLboFEjKedVpki/rK9oXuZwL1XHv7QidIH1E9qB7EKLezO/fzY1PMRrJezJtD5BS3fY7DKAUjTo3n/KpZjl4NW1C8C3NmrKLVomyS807yZVmUfMTFDj6Much4/+rJWWy7ngwi/1RZX/L1WYrjnjQb6MqrOXXSUedtnqD4VUSDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734825924; c=relaxed/simple; bh=60aO+vqvszoqyZ99DK0Lwu7IyjMW1DU970S/HNr/dJ4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qaRArXQIgngHmc2GrhIwXISPZAevuz1Kpb98imDOBka7RBcINSl78G9q0ZL0jGRH6KSy2tI+lFa/UczcJGx5FXJZpboUniAxaMv2p9u023HFfHNsp9aHGopMsy8u7AprUk4OY/CT2Qk3P1izU4zeqrKPb449Y/XtRVO9RQ+Eyl8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C03A385842A Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2166651f752so31996825ad.3 for ; Sat, 21 Dec 2024 16:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734825922; x=1735430722; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XaCvP1i0ZSmigFbGBuLfiEuC4tsM2SQJq90Jr1Z8Ydc=; b=L48Jzo4v3VussiUSS2SD3JIsN+qYXe/2d/zWJ7NUp3KLTtSqIJ+20uVvMPk/QVj9UQ 1M7vX0kZQz0dTVjutP9wT0lGDRKPu8V+hKnt/So0Am6So6fq8+AXljrKFBEs5ltaYNyh 8Kx2RO2XMGYOdiA5SG5l/3uugViLoYw3rEOQPZZdS/bZgznBvMo0+WggPTp6pyBdEvAX qQuj1fE4UD9J3GcFV/hkpS70yVLSOrkmwBIM1f83PAFLXUumi31pUQB5pI7LvI8DFBx+ w5uJh8i0CM5Q32/UZ8gWOv0HRtPny/sCkekO4ajke3Nc2sfzAFgA1o7NWx5PlpNIVKfQ hkJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734825922; x=1735430722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XaCvP1i0ZSmigFbGBuLfiEuC4tsM2SQJq90Jr1Z8Ydc=; b=dhRwtJypRdb5OtcJNBCAF52WS5IT5LwwODhYRrq0Cw3L0JBHXjZgRIlXiGQb1dC3JO 3gM0t8ByOWTeJy8kb+62xR/Af26WJp+bXYd2bEE+4hxjUBQeMeXhIwGyaA9rFAQmZ1T7 c5Lbh2trE6MOCWKHY1I3GSCB45lnRstfUh3AoL5yQ/VzpJ/Mu7mM1DgxS8ubWl/n4ZcA u/wkc69nMrWVLo1/nx4QL9pV7wEZr/Zfj25VJjqVaPHpZr9hV/8EUj3WLv0J+phl5OwV ha920oIEgvihNL34WrS6oC1PVtwKBlOfiZIS8046wI1VImnQt4hlqnusfWvDKF6xupBt TeLg== X-Gm-Message-State: AOJu0Yx7tKTTnMbbQuVtj+lDtvqb1fnqGtFkJ2q4OUAuJ6hXFBD/KTyT cM/SADycV1gO3hW0vbeGjV5CGZ7MRIpVi/67/Ukn/Hsop2L+SgYCDflJHuc6FTImlQ== X-Gm-Gg: ASbGncsPI/zzxRSjpGECkgQCkyy/xKdxkbPP66RstRykLvvvUzXXNp+ivh0odbmTIkf S+wxYSlX8IjKhTxSeaOuBjENCS5ErZKI+JlQ6jxJMRz7gJuflk6gOiN5Zb0Nw5osdsn/jmYdIXX bIww4PkLrmabUEAxhAwN7SLYWqH2i4VVYKlg++qacWYZdYTNgP+rT2WVPMJusa5tCpN8FV0a+zT iSpb8RZVFhweOzTG/Io72XhCAxUB93zFdi2k1t2ZPPymSTonnd0R64tb5c2tXW4P4jMJI0= X-Received: by 2002:a17:903:2b10:b0:216:3e87:c9fc with SMTP id d9443c01a7336-219e6e89b91mr127127455ad.5.1734825921912; Sat, 21 Dec 2024 16:05:21 -0800 (PST) Received: from gnu-tgl-3.localdomain ([120.204.185.181]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f51c2sm48896805ad.190.2024.12.21.16.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 16:05:20 -0800 (PST) Received: from gnu-tgl-3.lan (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id C1A48C06E7; Sun, 22 Dec 2024 08:05:14 +0800 (CST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: sam@gentoo.org, Adhemerval Zanella Subject: [PATCH 14/39] dirent: Remove variable lenght array structure for tst-getdents64.c Date: Sun, 22 Dec 2024 08:04:37 +0800 Message-ID: <20241222000509.2205895-15-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241222000509.2205895-1-hjl.tools@gmail.com> References: <20241222000509.2205895-1-hjl.tools@gmail.com> 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 Reviewed-by: Sam James --- 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); }