[phobos] Making std.stdio.readf @safe

Jakub Łabaj via phobos phobos at puremagic.com
Tue Feb 7 12:19:50 PST 2017


Ouch, yes, I meant fgetc_unlocked.

Thank you for the help! As a solution I'm going to make a PR with 
the mentioned changes, i.e. copy the approach of writef and apply 
@trusted to LockingTextReader - I think I can do this, because 
its behaviour ensures that functions FGETC, FLOCK, FUNLOCK are 
invoked in a safe manner.

On Tuesday, 7 February 2017 at 20:04:51 UTC, Andrei Alexandrescu 
wrote:
> On 2/7/17 2:07 PM, Jakub Łabaj via phobos wrote:
>> I see it like this:
>> - flockfile - can be @trusted, because no matter when we call 
>> it with
>> correct argument, it won't do anything unsafe
>
> affirmative
>
>> - funlockfile - if called by not owning thread, the behaviour 
>> is
>> undefined - so potentially may do something unsafe (I don't 
>> know what
> > happens if called on not locked file, probably is ignored)
>
> affirmative - in C "undefined" implies "unsafe"
>
>> fgetc - when not guarded by lock it is not thread safe, 
>> shouldn't be
>> @trusted
>
> I think you mean fgetc_unlocked? fgetc issues its own locking 
> and unlocking.
>
>
> Andrei




More information about the phobos mailing list