From patchwork Thu Oct 29 14:10:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 40920 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 585BC3985C02; Thu, 29 Oct 2020 14:13:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 585BC3985C02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603980784; bh=wp449LD1V//0Su1aAAh4SFHAWUtfUlnD32tPLIfCQy0=; 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=Lw2rLzsTZHJYKZcTpjsSkgcybNnpwj3EBZi51JSWNsPnLgxckKY623hp50pVFexL/ E8Kt8T9Vc7MQROrFXmgMylfd9EP/U8I7K8CLmfnnnRz5YI8qjSGQK8/9KzV3qRztCH lgX7lvib7AnxPAhtw7HAk8sklE6+cABvxhSmcc2k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by sourceware.org (Postfix) with ESMTPS id 9052D3861034 for ; Thu, 29 Oct 2020 14:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9052D3861034 Received: by mail-wm1-x342.google.com with SMTP id v5so17455wmh.1 for ; Thu, 29 Oct 2020 07:13:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wp449LD1V//0Su1aAAh4SFHAWUtfUlnD32tPLIfCQy0=; b=szrnS2nrh2ERwiheA0n3L/xuzx20OF2FlInqjlBSKwhy2AxQ91cDqxC3AdrjzAOCp6 9bvkqJYVMk8OolyoLUAJnPKNELGtYH6iP2UNdOIgS3vlJPwJT6YT+aAADxIXvatdlL4c e5/7beMSKstJBNf3qNJclGw4o6/AUj9O/6S7sL9J7290Z+efcir7715hwhVCaRayicq5 K30Z/oWiTduZs4mIHBlXJsc2CVLRbM3ELKlHBu6IUltbyEB87K8IZhySjjM+Z9bt5sPq GB50xcgYUbQxpqJoTA7FDHCBq6YvySLlT2fjUv4DLS+nwIOqGPWCytZObVJKNzg13wtW Z3Bw== X-Gm-Message-State: AOAM5308MYe/GD7UTUXcfaMGs658m7DH0rdPE5dII2C1nl9ZY5E0fvN+ IB2y5z6SirBFRLCwPZvU+wc= X-Google-Smtp-Source: ABdhPJysdWFxBoJYeaLxWjlPbEL/JwlCCmi5zijYUgQizDJk2HleJl5s93xTeMQpG/OhDnrStoTeRw== X-Received: by 2002:a1c:bdc4:: with SMTP id n187mr4831727wmf.185.1603980780446; Thu, 29 Oct 2020 07:13:00 -0700 (PDT) Received: from localhost.localdomain ([170.253.60.68]) by smtp.googlemail.com with ESMTPSA id m12sm4518670wmi.33.2020.10.29.07.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 07:12:59 -0700 (PDT) To: mtk.manpages@gmail.com Subject: [PATCH v3] getdents.2: Use appropriate types Date: Thu, 29 Oct 2020 15:10:54 +0100 Message-Id: <20201029141053.195998-1-colomar.6.4.3@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 , linux-man@vger.kernel.org, libc-alpha@sourceware.org, linux-kernel@vger.kernel.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" getdents(): This function has no glibc wrapper. As such, we should use the same types the Linux kernel uses: Use 'long' as the return type. getdents64(): The glibc wrapper uses: ssize_t getdents64(int, void *, size_t); Signed-off-by: Alejandro Colomar --- Hi Michael, Sorry, I'm being a bit distracted these days :) It should be good enough now, I think. Cheers, Alex man2/getdents.2 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/man2/getdents.2 b/man2/getdents.2 index a187fbcef..ed3bb40b1 100644 --- a/man2/getdents.2 +++ b/man2/getdents.2 @@ -33,14 +33,13 @@ getdents, getdents64 \- get directory entries .SH SYNOPSIS .nf -.BI "int getdents(unsigned int " fd ", struct linux_dirent *" dirp , +.BI "long getdents(unsigned int " fd ", struct linux_dirent *" dirp , .BI " unsigned int " count ); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .B #include .PP -.BI "int getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , -.BI " unsigned int " count ); +.BI "ssize_t getdents64(int " fd ", void *" dirp ", size_t " count ); .fi .PP .IR Note : @@ -282,7 +281,8 @@ struct linux_dirent { int main(int argc, char *argv[]) { - int fd, nread; + int fd; + long nread; char buf[BUF_SIZE]; struct linux_dirent *d; char d_type; @@ -301,7 +301,7 @@ main(int argc, char *argv[]) printf("\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=%d \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\en", nread); printf("inode# file type d_reclen d_off d_name\en"); - for (int bpos = 0; bpos < nread;) { + for (long bpos = 0; bpos < nread;) { d = (struct linux_dirent *) (buf + bpos); printf("%8ld ", d\->d_ino); d_type = *(buf + bpos + d\->d_reclen \- 1);