ABC writes: > Hello, > > To what mktemp() should be replaced? Will there be sanei function to > drop-in replace it?
The mktemp(3) manual page suggests mkstemp (POSIX.1-2001, not in C99). That is used by the bh and pieusb backends. You can also use tmpfile (POSIX.1-2001, POSI.1-2008 and in C99), which is what I used in my patch for the avision backend (not pushed yet). I wasn't thinking of providing a sanei function for this. BTW, both open the temporary file with O_EXCL so they need to be opened by the process that needs it. This may be an issue for backends that use the SANE_Thread API because it uses fork() on some platforms to run "threads" in child processes. If the child process needs the file, the child process needs to call tmpfile() or mkstemp(). Calling it in, say, sane_init() or sane_open() with such backends will likely break things. Note that mktemp() only creates a file*name* so the O_EXCL is not an issue then and calling fopen() or open() isn't subject to this flag unless passed explicitly. Child processes inherit non-exclusive open file descriptors. > On Wed, Sep 21, 2016 at 10:12:27PM +0900, Olaf Meeuwissen wrote: >> Looking over the build log (love how clean those compile commands look, >> BTW), next are four linker warnings about the use of `mktemp`, which, as >> we all know, is racey and should be avoided. Like the plague, so I'd >> like to see these get fixed. >> >> # I have a patch for the avision backend already. By all means, tackle >> # any of the canon, canon_dr and dc25 backends' use of mktemp. Hope this helps, -- Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9 Support Free Software https://my.fsf.org/donate Join the Free Software Foundation https://my.fsf.org/join -- sane-devel mailing list: sane-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel Unsubscribe: Send mail with subject "unsubscribe your_password" to sane-devel-requ...@lists.alioth.debian.org