<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED NOTOURBUG - LO on Linux crashes when accessing opend/locked File on SAMBA network share"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=127648#c32">Comment # 32</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED NOTOURBUG - LO on Linux crashes when accessing opend/locked File on SAMBA network share"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=127648">bug 127648</a>
              from <span class="vcard"><a class="email" href="mailto:mikekaganski@hotmail.com" title="Mike Kaganski <mikekaganski@hotmail.com>"> <span class="fn">Mike Kaganski</span></a>
</span></b>
        <pre>(In reply to Theofilos Intzoglou from <a href="show_bug.cgi?id=127648#c30">comment #30</a>)
<span class="quote">> (In reply to Stephan Bergmann from <a href="show_bug.cgi?id=127648#c29">comment #29</a>)
> > (In reply to Theofilos Intzoglou from <a href="show_bug.cgi?id=127648#c27">comment #27</a>)
> > > int main(void) {
> > >     int fd;
> > >     struct stat statbuf;
> > >     int res;
> > >     char buf[4096];
> > > 
> > >     fd = openat(AT_FDCWD, "/mnt/disk/cv.doc", O_RDONLY);
> > >     if (fd == -1)
> > >         printerr();
> > > 
> > >     res = fstat(fd, &statbuf);
> > >     if (res == -1)
> > >         printerr();
> > >     printf("st_mode=%d\nst_size=%ld\n", statbuf.st_mode, statbuf.st_size);
> > >     res = pread64(fd, &buf, 4096, 0);
> > >     printf("%d\n", res);
> > >     close(fd);
> > >     exit(0);
> > > }
> > 
> > The return type of pread64 is ssize_t, not int.

> Indeed but it gives the same result.</span >

Indeed, because even if you declare your res to be ssize_t, if you print it
using `printf("%d\n", res)`, you convert the ssize_t to int again here, since
"%d" (without "l" length modifier) treats the value as int [1]. The same wrong
handling of integer types seems to be the reason of this problem in the kernel.

[1] <a href="https://linux.die.net/man/3/printf">https://linux.die.net/man/3/printf</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>