[pve-devel] [PATCH storage] api: upload: correctly test for result of unlink

Fiona Ebner f.ebner at proxmox.com
Tue Jul 30 10:21:42 CEST 2024


Am 29.07.24 um 18:50 schrieb Thomas Lamprecht:
> Am 29/07/2024 um 16:29 schrieb Fiona Ebner:
>> It's not enough to check whether $! is set. From "perldoc perlvar":
>>
>>> Many system or library calls set "errno" if they fail, to
>>> indicate the cause of failure. They usually do not set "errno"
>>> to zero if they succeed and may set "errno" to a non-zero value
>>> on success. This means "errno", hence $!, is meaningful only
>>> *immediately* after a failure:
>>
>> To protect against potential issues, check the return value of unlink
>> and only check $! if it failed.
> 
> fine by me, but out of interest: any reason for why this is done now,
> i.e., did this really cause trouble or is this done out of precaution?

Sorry, while the commit message hints at it with "protect against
potential issues", I could've been more explicit. I stumbled upon an old
branch with this patch. Most likely I wrote it after needing the same
logic with unlink for something else. I don't know about any concrete
issues.




More information about the pve-devel mailing list