[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#871956: lintian: false positive: binary-file-built-without-LFS-support on x32



On Sat, 2017-09-02 at 21:47:15 +0200, Boud Roukema wrote:
> On Sat, 2 Sep 2017, Adam Borowski wrote:
> > > AC_SYS_LARGEFILE on i386 (linux) for mpgrafic-0.3.15-1 apparently does *not*
> > > always do the right thing

> > Nope, you use pwrite() not pwrite64() -- on i386 you need the latter to get
> > LFS; they're aliases only on amd64, x32 and so on.

That's not correct, neither the new changes to the description of the
tag.

When you define _FILE_OFFSET_BITS=64 the interfaces are transparently
mapped to the 64-bit variants and no other code change is required. So
you *must* not be switching from foo to foo64 in the call sites. This
is IMO the preferred way to enable LFS.

The other way to enable LFS is to define _LARGEFILE64_SOURCE, which
makes visible the 64-bit variants in parallel to the 32-bit default
interfaces, so you get foo and foo64, and you can call either from the
code. This might be useful in case you are for example writing a
library and need to support entry points for both 32-bit and 64-bit
functions for backwards compatibility. Otherwise I'd strongly
discourage its use.

> OK, so config.h + p(read|write)64 should hopefully solve the mpgrafic
> bug. I initially tried hardwiring pwrite64 and pread64 (compiling on
> amd64), but got "warning: implicit declaration of function ‘pwrite64’
> [-Wimplicit-function-declaration]". My understanding is that
> _FILE_OFFSET_BITS and __USE_FILE_OFFSET64 are *not* set for amd64 by
> AC_SYS_LARGEFILE, and instead only set for some systems, such as i386.
> The following should correctly work together with AC_SYS_LARGEFILE, it
> seems to me.
> 
> Does this look OK?
> 
> #ifndef __USE_FILE_OFFSET64
>   i_stat=pwrite(fd,buffer,size,offset);
> #else
>   i_stat=pwrite64(fd,buffer,size,offset);
> #endif
> 
> #ifndef __USE_FILE_OFFSET64
>   i_stat = pread(fd,buffer,size,offset);
> #else
>   i_stat = pread64(fd,buffer,size,offset);
> #endif

Nope, that looks wrong. The __USE_* macros are internal implementation
details, and applications should not be using those. In addition you
should just be using pread() and pwrite(), which will call the correct
interfaces.

> > But in any case, even if it had been indeed a false positive, it'd be a
> > different bug.
> 
> I think I should post a lintian bug for improving the info field for
> the LFS unsafe detection - I spent quite a bit of time searching for how
> to handle this, and having more detailed information could help other
> debian contributors respond more easily to built-without-LFS-support
> warnings.

That patch needs to be reverted. I can provide a new patch explaining
in more detail this though and giving more pointers perhaps.

Thanks,
Guillem


Reply to: