[Top][All Lists]

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

Re: Use of `mktemp' is dangerous, better use `mkstemp'...

From: Ángel
Subject: Re: Use of `mktemp' is dangerous, better use `mkstemp'...
Date: Tue, 19 Jan 2021 00:40:58 +0100

On 2021-01-18 at 14:05 -0500, Chet Ramey wrote:
> On 1/17/21 7:46 PM, Ángel wrote:
> > > > [Explanation of when is mktemp() used and patch to remove the
> > > > warning]
> > > 
> > > The warning can be ignored.
> > 
> > Sure. However, actually removing the spurious warning would not
> > only make (some) build systems happier, but also produce less
> > confused users, so it seemed (potentially) valuable.
> I understand. I have a problem with changing perfectly valid code
> that serves its intended purpose to satisfy an invalid warning.

It's up to you, Chet. It was mainly moving around the same code into a
different file, but I can understand not wanting to change code for
this. I agree the warning is not useful here. 

> It's the 80-20 rule: I'm sure that this warning is valid 80% of the
> time or more. I'd like a way to turn it off for the other 20%, where
> this case falls.

It is probably right almost in every case. Yet, here comes a project
such as bash to prove it incorrect.
The warning is being spew by ld. It is probably implemented by an
attribute at libc mktemp symbol. I do not see an option to disable
those warnings.
There is a "solution" at https://stackoverflow.com/a/29205123  which
would probably work as well, but that's much uglier than my approach of
calling sh_mktmpname on the same compilation unit it is defined so the
compiler can ellide it.

Best regards

reply via email to

[Prev in Thread] Current Thread [Next in Thread]