From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id B2A5F1FF183
	for <inbox@lore.proxmox.com>; Mon, 11 Nov 2024 11:33:12 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id B1D5E3F853;
	Mon, 11 Nov 2024 11:33:11 +0100 (CET)
Message-ID: <4dbb6ac8-de00-48d9-a214-d5a036db1844@proxmox.com>
Date: Mon, 11 Nov 2024 11:32:38 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
 Proxmox VE development discussion <pve-devel@lists.proxmox.com>
References: <20241111101758.1259669-1-d.csapak@proxmox.com>
 <20241111101758.1259669-2-d.csapak@proxmox.com>
 <b8cdbf8d-a2f1-41f7-99d3-12333d14fadc@proxmox.com>
Content-Language: en-US
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <b8cdbf8d-a2f1-41f7-99d3-12333d14fadc@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.016 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH common v4 1/2] sysfstools: file_write:
 extend with logging
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

On 11/11/24 11:29, Thomas Lamprecht wrote:
> Am 11.11.24 um 11:17 schrieb Dominik Csapak:
>> the actual error and path is useful to know when trying to debug or
>> figure out what did not work, so warn here if there was an error.
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>> changes from v3:
>> * only add the logging in this patch, not the error ignore handling
>>
>>   src/PVE/SysFSTools.pm | 12 +++++++++---
>>   1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/PVE/SysFSTools.pm b/src/PVE/SysFSTools.pm
>> index 0bde6d7..772f6d6 100644
>> --- a/src/PVE/SysFSTools.pm
>> +++ b/src/PVE/SysFSTools.pm
>> @@ -211,17 +211,23 @@ sub check_iommu_support{
>>       return PVE::Tools::dir_glob_regex('/sys/class/iommu/', "[^\.].*");
>>   }
>>   
>> +# writes $buf into $filename, on success returns 1, on error returns 0 and warns
>>   sub file_write {
>>       my ($filename, $buf) = @_;
>>   
>>       my $fh = IO::File->new($filename, "w");
>>       return undef if !$fh;
>>   
>> -    my $res = defined(syswrite($fh, $buf)) ? 1 : 0;
>> -
>> +    my $res = syswrite($fh, $buf);
>>       $fh->close();
> 
> just to be sure: and the fh->close cannot alter `$!` ?
> 
> Otherwise, we probably want to assign my $sys_err = $! before the $fh->close()
> call, and maybe comment that it only is relevant if $res is not defined.
> 

no, you're right, close can set $! too...

i'll send a v5 for extracting the syserr before


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel