From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Filip Schauer <f.schauer@proxmox.com>
Subject: Re: [pve-devel] [PATCH v2 common] tools: file_set_contents: use syswrite instead of print
Date: Mon, 14 Oct 2024 11:26:26 +0200 [thread overview]
Message-ID: <a7e27de6-fb6a-4eb1-9a7b-58f0c147d195@proxmox.com> (raw)
In-Reply-To: <20240930114045.76730-1-f.schauer@proxmox.com>
Am 30/09/2024 um 13:40 schrieb Filip Schauer:
> + $offset += syswrite($fh, $data, $len - $offset, $offset)
> + or die "unable to write '$tmpname' - $!\n";
FYI: Wolfgang noticed something nasty with the subtle difference between
the `or` and `||` operator [0] that introduces a bug w.r.t. error handling
here.
Basically `or` has lower precedence and thus would have made the code
act like:
($offset += syswrite($fh, $data, $len - $offset, $offset))
or die "unable to write '$tmpname' - $!\n";
Thus, never taking the error path once $offset was incresead to something
to non-zero, i.e. after the first round. See my follow-up commit [1] for
more details.
[0]: https://perldoc.perl.org/perlop#Logical-or-and-Exclusive-Or
[1]: https://git.proxmox.com/?p=pve-common.git;a=commitdiff;h=f1fe7a0733570e84343f152e2409b22782feb2d3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
prev parent reply other threads:[~2024-10-14 9:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 11:40 Filip Schauer
2024-10-14 8:42 ` [pve-devel] applied: " Thomas Lamprecht
2024-10-14 9:07 ` Dominik Csapak
2024-10-14 9:22 ` Thomas Lamprecht
2024-10-14 9:26 ` Thomas Lamprecht [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7e27de6-fb6a-4eb1-9a7b-58f0c147d195@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=f.schauer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.