From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 9A6B63893667 for ; Tue, 27 Apr 2021 16:07:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9A6B63893667 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E9854340E3D; Tue, 27 Apr 2021 16:06:51 +0000 (UTC) Date: Tue, 27 Apr 2021 12:06:51 -0400 From: Mike Frysinger To: Peng Yu Cc: libc-help Subject: Re: Why is st_size defined as a signed int? Message-ID: Mail-Followup-To: Peng Yu , libc-help References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, 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-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2021 16:07:05 -0000 On 27 Apr 2021 09:01, Peng Yu via Libc-help wrote: > https://github.com/bminor/glibc/blob/master/bits/stat.h#L47 > > I see st_size is defined as __off_t, which should be a signed int. But > can a file size be negative. If not, why not use an unsigned int to > represent the file size? Thanks. it's an offset, not a size. lseek can legitimately be negative. otherwise, at this point, the interfaces are ossified by POSIX, and glibc simply has to match whatever it has. -mike