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 EE0F31FF38E
	for <inbox@lore.proxmox.com>; Tue, 11 Jun 2024 12:56:12 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id BEE583557C;
	Tue, 11 Jun 2024 12:56:43 +0200 (CEST)
To: pve-devel@lists.proxmox.com
Date: Mon, 10 Jun 2024 21:05:26 +0900
In-Reply-To: <94ed3b8c-20bf-4832-9ee8-f5b74e7b55f6@proxmox.com>
References: <94ed3b8c-20bf-4832-9ee8-f5b74e7b55f6@proxmox.com>
X-Mailman-Approved-At: Tue, 11 Jun 2024 12:56:41 +0200
MIME-Version: 1.0
Message-ID: <mailman.547.1718103401.319.pve-devel@lists.proxmox.com>
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Post: <mailto:pve-devel@lists.proxmox.com>
From: Jing Luo via pve-devel <pve-devel@lists.proxmox.com>
Precedence: list
Cc: Jing Luo <jing@jing.rocks>
X-Mailman-Version: 2.1.29
X-BeenThere: pve-devel@lists.proxmox.com
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
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/>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
Subject: [pve-devel] [PATCH v2 pve-qemu-kvm] patches: pbs block driver:
 correct a data type
Content-Type: multipart/mixed; boundary="===============7564966890736985853=="
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

--===============7564966890736985853==
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <jing@jing.rocks>
X-Original-To: pve-devel@lists.proxmox.com
Delivered-To: pve-devel@lists.proxmox.com
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by lists.proxmox.com (Postfix) with ESMTPS id 3725CC925E
	for <pve-devel@lists.proxmox.com>; Mon, 10 Jun 2024 14:30:13 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 1311516AF1
	for <pve-devel@lists.proxmox.com>; Mon, 10 Jun 2024 14:29:43 +0200 (CEST)
Received: from mail-gw3.jing.rocks (mail-gw3.jing.rocks [219.117.250.209])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by firstgate.proxmox.com (Proxmox) with ESMTPS
	for <pve-devel@lists.proxmox.com>; Mon, 10 Jun 2024 14:29:40 +0200 (CEST)
Received: from mail-gw3.jing.rocks (localhost [127.0.0.1])
	by mail-gw3.jing.rocks (Proxmox) with ESMTP id 3E871286EA;
	Mon, 10 Jun 2024 21:29:36 +0900 (JST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jing.rocks; h=cc
	:cc:content-transfer-encoding:date:from:from:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to; s=mail-gw; bh=6vI4sgI0N/pcyDwkNNk0aylenXfg8tvO7/BNf1VpY4w=; b=
	A5eC4HXF2oHoekSfmQRvQQLEPyDkydXWRJQA9D6OtFhT3iXWS1+v4Kw4NEcwlaJq
	WaWz93iTrfM1o26pTPoE++uREyJhi3BZV7pkf/bXFZ1MFRlf7SzNJ/TY4U0rgmLY
	17xzlucrmm5ComKwcYdoT+GnRj32JfQiySMzG5lcXsIdhEbZPNK7IEGEEA46M055
	9+8HsjkCgXd36GO95XeB0otPkaVcdvmgeipUl5hmJUT+vpcdsInJ38UUeoPSBUC8
	1qCNuhkvKl6qCot7TkcdYlW2osNkM6HIEywwwnQOCZXO2IJbRrhRY7wW5VCOB7Jo
	HNzyPKE2kDnoR7iPAgeimg==
Received: from mail.jing.rocks (mail.jing.rocks [IPv6:240b:10:f00:1b00::222])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by mail-gw3.jing.rocks (Proxmox) with ESMTPS id 596BD288BB;
	Mon, 10 Jun 2024 21:29:33 +0900 (JST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=jing.rocks;
	s=default; t=1718022573;
	bh=lp+swS/XSlJCGHM47GGNBQo4vRV2u6AqbBikJxFHLxs=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=Io6W6jJcl5sRr6lezkeovIfqk4pGSwuZiiXVDH+y7195fp9FsrOjwalKhi7uEDgvb
	 2ovdpC4k1PokOZSa1Krm2zA5LUerDqDTkOL6BXDHCI1ie5T7rFeN6be/bQi5cHThka
	 3LbTz2zynR/kFd6xzyV1UPBOkdF8G/ltQwRZRi1dUTdydTe64XAbwWqRdNopybdPo+
	 P2IPDA83lpmWWB55y/Fx2Iq/k8sAc1L5BXswBzWl3lmJ6g/mfmZLj7EQ7z2MGpU15E
	 86tj5w/ztGJJlD+4TahXMx5hCqd4cHOA9tZ8LCnsVlo7qvdH1IQ902M6YRFo6B5X9v
	 e+MUzO9V9fGDg==
Received: from X570AM.jing.rocks (X570AM.jing.rocks [IPv6:240b:10:f00:1b00::7e82])
	(Authenticated sender: jing@jing.rocks)
	by mail.jing.rocks (Postfix) with ESMTPSA id 3F3B938A1F;
	Mon, 10 Jun 2024 21:29:33 +0900 (JST)
From: Jing Luo <jing@jing.rocks>
To: pve-devel@lists.proxmox.com
Cc: f.ebner@proxmox.com,
	Jing Luo <jing@jing.rocks>
Subject: [PATCH v2 pve-qemu-kvm] patches: pbs block driver: correct a data type
Date: Mon, 10 Jun 2024 21:05:26 +0900
Message-ID: <20240610122909.1216178-2-jing@jing.rocks>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <94ed3b8c-20bf-4832-9ee8-f5b74e7b55f6@proxmox.com>
References: <94ed3b8c-20bf-4832-9ee8-f5b74e7b55f6@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
	BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
	DKIM_SIGNED               0.1 Message has a DKIM or DK signature, not necessarily valid
	DKIM_VALID               -0.1 Message has at least one valid DKIM or DK signature
	DKIM_VALID_AU            -0.1 Message has a valid DKIM or DK signature from author's domain
	DKIM_VALID_EF            -0.1 Message has a valid DKIM or DK signature from envelope-from domain
	DMARC_PASS               -0.1 DMARC pass policy
	KAM_INFOUSMEBIZ          0.75 Prevalent use of .info|.us|.me|.me.uk|.biz|xyz|id|rocks|life domains in spam/malware
	KAM_OTHER_BAD_TLD        0.75 Other untrustworthy TLDs
	SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
	SPF_PASS               -0.001 SPF: sender matches SPF record
	T_SCC_BODY_TEXT_LINE    -0.01 -
X-Mailman-Approved-At: Tue, 11 Jun 2024 12:56:41 +0200

gcc warns (-Werror=type-limits) that it will always be false for the
if statement. This is because here s->aid is defined as char, while
proxmox_restore_open_image() returns an int.

This is probably because chars are treated as unsigned on arm arch but
signed on x86 arch:

https://developer.arm.com/documentation/den0013/d/Porting/Miscellaneous-C-porting-issues/unsigned-char-and-signed-char

Signed-off-by: Jing Luo <jing@jing.rocks>
--
[changes since v1]
Use uint8_t for s->aid. Check the returned value from
proxmox_restore_open_image(), then assign it to s->aid.

Fiona: the doctor found no fish bone in my throat (probably swallowed),
so here's my best try :) I did minimal testing (it built).

I also found that chars are unsigned on riscv64, powerpc64le...not that
proxomx needs to worry about those arch though.
---
 ...ock-driver-to-map-backup-archives-into.patch | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch b/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
index b9578ba..4c155c8 100644
--- a/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
+++ b/debian/patches/pve/0032-PVE-Add-PBS-block-driver-to-map-backup-archives-into.patch
@@ -15,11 +15,11 @@ Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
 ---
  block/meson.build    |   2 +
- block/pbs.c          | 307 +++++++++++++++++++++++++++++++++++++++++++
+ block/pbs.c          | 310 +++++++++++++++++++++++++++++++++++++++++++
  meson.build          |   2 +-
  qapi/block-core.json |  29 ++++
  qapi/pragma.json     |   1 +
- 5 files changed, 340 insertions(+), 1 deletion(-)
+ 5 files changed, 343 insertions(+), 1 deletion(-)
  create mode 100644 block/pbs.c
 
 diff --git a/block/meson.build b/block/meson.build
@@ -37,10 +37,10 @@ index 6bba803f94..1945e04eeb 100644
  system_ss.add(files('block-ram-registrar.c'))
 diff --git a/block/pbs.c b/block/pbs.c
 new file mode 100644
-index 0000000000..dd72356bd3
+index 0000000000..9112d4dfe6
 --- /dev/null
 +++ b/block/pbs.c
-@@ -0,0 +1,307 @@
+@@ -0,0 +1,310 @@
 +/*
 + * Proxmox Backup Server read-only block driver
 + */
@@ -68,7 +68,7 @@ index 0000000000..dd72356bd3
 +
 +typedef struct {
 +    ProxmoxRestoreHandle *conn;
-+    char aid;
++    uint8_t aid;
 +    int64_t length;
 +
 +    char *repository;
@@ -201,12 +201,15 @@ index 0000000000..dd72356bd3
 +    }
 +
 +    /* acquire handle and length */
-+    s->aid = proxmox_restore_open_image(s->conn, s->archive, &pbs_error);
-+    if (s->aid < 0) {
++    ret = proxmox_restore_open_image(s->conn, s->archive, &pbs_error);
++    if (ret < 0 || ret > UINT8_MAX) {
 +        if (pbs_error && errp) error_setg(errp, "PBS open_image failed: %s", pbs_error);
 +        if (pbs_error) proxmox_backup_free_error(pbs_error);
 +        return -ENODEV;
++    } else {
++        s->aid = ret;
 +    }
++
 +    s->length = proxmox_restore_get_image_length(s->conn, s->aid, &pbs_error);
 +    if (s->length < 0) {
 +        if (pbs_error && errp) error_setg(errp, "PBS get_image_length failed: %s", pbs_error);
-- 
2.45.2




--===============7564966890736985853==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============7564966890736985853==--