public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Peng Yu <pengyu.ut@gmail.com>
Cc: libc-help <libc-help@sourceware.org>
Subject: Re: Why is st_size defined as a signed int?
Date: Tue, 27 Apr 2021 12:06:51 -0400	[thread overview]
Message-ID: <YIg2m5EikyfZwI1C@vapier> (raw)
In-Reply-To: <CABrM6wmmr_QU4Z=d8gsPMr812AWtgrf80kNs1+1Qezvn_0RN6A@mail.gmail.com>

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

  reply	other threads:[~2021-04-27 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 14:01 Peng Yu
2021-04-27 16:06 ` Mike Frysinger [this message]
2021-04-27 17:05 ` Andrew Bell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YIg2m5EikyfZwI1C@vapier \
    --to=vapier@gentoo.org \
    --cc=libc-help@sourceware.org \
    --cc=pengyu.ut@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).